Author: lslezak Date: Fri Nov 7 13:18:24 2008 New Revision: 53058 URL: http://svn.opensuse.org/viewcvs/yast?rev=53058&view=rev Log: - added URL::HidePassword() and URL::HidePasswordToken() functions (bnc#441944) - 2.17.47 Modified: trunk/yast2/VERSION trunk/yast2/library/types/src/URL.ycp trunk/yast2/package/yast2.changes Modified: trunk/yast2/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/VERSION?rev=53058&r1=53057&r2=53058&view=diff ============================================================================== --- trunk/yast2/VERSION (original) +++ trunk/yast2/VERSION Fri Nov 7 13:18:24 2008 @@ -1 +1 @@ -2.17.46 +2.17.47 Modified: trunk/yast2/library/types/src/URL.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/src/URL.ycp?rev=53058&r1=53057&r2=53058&view=diff ============================================================================== --- trunk/yast2/library/types/src/URL.ycp (original) +++ trunk/yast2/library/types/src/URL.ycp Fri Nov 7 13:18:24 2008 @@ -509,4 +509,37 @@ ); } +/** + * Hide password in an URL - replaces the password in the URL by 'PASSWORD' string. + * If there is no password in the URL the original URL is returned. + * It should be used when an URL is logged to y2log or when it is displayed to user. + * @param url original URL + * @return string new URL with 'PASSWORD' password or unmodified URL if there is no password + */ +global string HidePassword(string url) { + // Url::Build(Url::Parse) transforms the URL too much, see #247249#c41 + // replace ://user:password@ by ://user:PASSWORD@ + string subd = regexpsub (url, "(.*)(://[^/:]*):[^/@]*@(.*)", "\\1\\2:PASSWORD@\\3"); + return subd == nil? url: subd; +} + +/** + * Hide password token in parsed URL (by URL::Parse()) - the password is replaced by 'PASSWORD' string. + * Similar to HidePassword() but uses a parsed URL as the input. + * @param tokens input + * @return map map with replaced password + */ +global map HidePasswordToken(map tokens) +{ + map ret = tokens; + + // hide the password if it's there + if (haskey(ret, "pass") && size(ret["pass"]:"") > 0) + { + ret["pass"] = "PASSWORD"; + } + + return ret; +} + } Modified: trunk/yast2/package/yast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=53058&r1=53057&r2=53058&view=diff ============================================================================== --- trunk/yast2/package/yast2.changes (original) +++ trunk/yast2/package/yast2.changes Fri Nov 7 13:18:24 2008 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Nov 7 12:40:08 CET 2008 - lslezak@suse.cz + +- added URL::HidePassword() and URL::HidePasswordToken() functions + (bnc#441944) +- 2.17.47 + +------------------------------------------------------------------- Thu Nov 6 18:45:38 CET 2008 - jdsn@suse.de - disable x11 setup on Itanium/ia64 (bnc#439612) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org