[yast-commit] r57013 - in /trunk/yast2: library/types/src/URL.ycp library/types/testsuite/tests/URL.out library/types/testsuite/tests/URL.ycp package/yast2.changes
Author: lslezak Date: Tue Apr 28 17:09:55 2009 New Revision: 57013 URL: http://svn.opensuse.org/viewcvs/yast?rev=57013&view=rev Log: - URL.ycp - fixed processing of smb:// URLs (bnc#495109) Modified: trunk/yast2/library/types/src/URL.ycp trunk/yast2/library/types/testsuite/tests/URL.out trunk/yast2/library/types/testsuite/tests/URL.ycp trunk/yast2/package/yast2.changes Modified: trunk/yast2/library/types/src/URL.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/src/URL.ycp?rev=57013&r1=57012&r2=57013&view=diff ============================================================================== --- trunk/yast2/library/types/src/URL.ycp (original) +++ trunk/yast2/library/types/src/URL.ycp Tue Apr 28 17:09:55 2009 @@ -150,6 +150,9 @@ return ret; } +global map <string, string> MakeMapFromParams (string params); +global string MakeParamsFromMap (map <string, string> params_map); + /** * Tokenize URL * @param url URL to be parsed @@ -242,14 +245,19 @@ } // some exceptions for samba scheme (there is optional extra option "domain") - if (tokens["scheme"]:""=="samba" || tokens["scheme"]:""=="smb"){ - list<string> tmp_list = filter(string row, splitstring(tokens["path"]:"", "/"), {return (size(row)>0);}); - if (size(tmp_list)>1){ - tokens["domain"] = tokens["host"]:""; - tokens["host"] = tmp_list[0]:""; - tokens["path"] = tmp_list[1]:""; - } - else tokens["path"] = deletechars(tokens["path"]:"", "/"); + if (tokens["scheme"]:""=="samba" || tokens["scheme"]:""=="smb") + { + // Note: CUPS uses different URL syntax for Samba printers: + // smb://username:password@workgroup/server/printer + // Fortunately yast2-printer does not use URL.ycp, so we can safely support libzypp syntax only: + // smb://username:passwd@servername/share/path/on/the/share?workgroup=mygroup + + map<string,string> options = MakeMapFromParams(tokens["query"]:""); + + if (haskey(options, "workgroup")) + { + tokens["domain"] = options["workgroup"]:""; + } } y2debug("tokens=%1", tokens); return tokens; @@ -333,10 +341,6 @@ url = sformat("%1://%2", url, userpass); y2debug("url: %1", url); - if (tokens["scheme"]:"" == "smb" && size(tokens["domain"]:"")>0 ){ - url = sformat("%1%2/", url, tokens["domain"]:""); - } - if(Hostname::CheckFQ(tokens["host"]:"") || IP::Check(tokens["host"]:"")) { // enclose an IPv6 address in square brackets @@ -369,8 +373,19 @@ } y2debug("url: %1", url); + + map<string,string> query_map = MakeMapFromParams(tokens["query"]:""); + + if (tokens["scheme"]:"" == "smb" && size(tokens["domain"]:"")>0 && query_map["workgroup"]:"" != tokens["domain"]:"") + { + query_map["workgroup"] = tokens["domain"]:""; + + tokens["query"] = MakeParamsFromMap(query_map); + } + if (tokens["query"]:"" != "" ) url = sformat("%1?%2", url, URLRecode::EscapeQuery(tokens["query"]:"")); + if (tokens["fragment"]:"" != "" ) url = sformat("%1#%2", url, URLRecode::EscapePassword(tokens["fragment"]:"")); y2debug("url: %1", url); Modified: trunk/yast2/library/types/testsuite/tests/URL.out URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/testsuite/tests/URL.out?rev=57013&r1=57012&r2=57013&view=diff ============================================================================== --- trunk/yast2/library/types/testsuite/tests/URL.out (original) +++ trunk/yast2/library/types/testsuite/tests/URL.out Tue Apr 28 17:09:55 2009 @@ -28,6 +28,9 @@ Return $["fragment":"", "host":"2001:de8:0:f123::1", "pass":"", "path":"/path/to/dir", "port":"", "query":"", "scheme":"http", "user":""] Return $["fragment":"", "host":"2001:de8:0:f123::1", "pass":"password", "path":"/path/to/dir", "port":"8080", "query":"", "scheme":"http", "user":"user"] Return http://user:password@[2001:de8:0:f123::1]:8080/path/to/dir +Return $["domain":"group", "fragment":"", "host":"servername", "pass":"passwd", "path":"/share/path/on/the/share", "port":"", "query":"mountoptions=ro&workgroup=group", "scheme":"smb", "user":"username"] +Return true +Return smb://username:passwd@myserver.com/share%24%24share/path/on/the/share?workgroup=workgroup Return dir:/// Return http://download.opensuse.org/very/log/path/which/will/be/truncated/target_fi... Return http://download.opensuse.org/.../target_file Modified: trunk/yast2/library/types/testsuite/tests/URL.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/testsuite/tests/URL.ycp?rev=57013&r1=57012&r2=57013&view=diff ============================================================================== --- trunk/yast2/library/types/testsuite/tests/URL.ycp (original) +++ trunk/yast2/library/types/testsuite/tests/URL.ycp Tue Apr 28 17:09:55 2009 @@ -62,6 +62,13 @@ TEST(``(URL::Parse("http://user:password@[2001:de8:0:f123::1]:8080/path/to/dir")), [], nil); TEST(``(URL::Build(URL::Parse("http://user:password@[2001:de8:0:f123::1]:8080/path/to/dir"))), [], nil); +// smb:// tests +string smb_url = "smb://username:passwd@servername/share/path/on/the/share?mountoptions=ro&workgroup=group"; +TEST(``(URL::Parse(smb_url)), [], nil); +// parse->build must return the orginal value +TEST(``(URL::Build(URL::Parse(smb_url)) == smb_url), [], nil); +// bnc#491482 +TEST(``(URL::Build( $["domain":"workgroup", "host":"myserver.com", "pass":"passwd", "path":"/share$$share/path/on/the/share", "scheme":"smb", "user":"username"])), [], nil); TEST(``(URL::Build(URL::Parse("dir:///"))), [], nil); Modified: trunk/yast2/package/yast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=57013&r1=57012&r2=57013&view=diff ============================================================================== --- trunk/yast2/package/yast2.changes (original) +++ trunk/yast2/package/yast2.changes Tue Apr 28 17:09:55 2009 @@ -3,6 +3,7 @@ - URL.ycp - escape also non-ASCII characters in URL, added URLRecode.pm module (bnc#446395) +- URL.ycp - fixed processing of smb:// URLs (bnc#495109) ------------------------------------------------------------------- Mon Apr 20 16:11:35 CEST 2009 - jsrain@suse.cz -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn.opensuse.org