Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] r57893 - in /branches/SuSE-Code-11-Branch/yast2: library/types/src/URL.ycp library/types/testsuite/tests/URL.out library/types/testsuite/tests/URL.ycp package/yast2.changes
  • From: lslezak@xxxxxxxxxxxxxxxx
  • Date: Tue, 07 Jul 2009 11:54:50 -0000
  • Message-id: <E1MO9G7-0000Kh-2p@xxxxxxxxxxxxxxxx>
Author: lslezak
Date: Tue Jul 7 13:54:50 2009
New Revision: 57893

URL: http://svn.opensuse.org/viewcvs/yast?rev=57893&view=rev
Log:
- URL.ycp - fixed processing of smb:// URLs (bnc#495109)

Modified:
branches/SuSE-Code-11-Branch/yast2/library/types/src/URL.ycp
branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.out
branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.ycp
branches/SuSE-Code-11-Branch/yast2/package/yast2.changes

Modified: branches/SuSE-Code-11-Branch/yast2/library/types/src/URL.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/yast2/library/types/src/URL.ycp?rev=57893&r1=57892&r2=57893&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/yast2/library/types/src/URL.ycp (original)
+++ branches/SuSE-Code-11-Branch/yast2/library/types/src/URL.ycp Tue Jul 7
13:54:50 2009
@@ -149,6 +149,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
@@ -241,14 +244,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;
@@ -330,10 +338,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
@@ -366,6 +370,15 @@
}
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, EscapeString(tokens["query"]:"",
transform_map_query));
if (tokens["fragment"]:"" != "" )

Modified:
branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.out
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.out?rev=57893&r1=57892&r2=57893&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.out
(original)
+++ branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.out
Tue Jul 7 13:54:50 2009
@@ -26,6 +26,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@xxxxxxxxxxxx/share%24%24share/path/on/the/share?workgroup=workgroup
Return dir:///
Return
http://download.opensuse.org/very/log/path/which/will/be/truncated/target_file
Return http://download.opensuse.org/.../target_file

Modified:
branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.ycp?rev=57893&r1=57892&r2=57893&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.ycp
(original)
+++ branches/SuSE-Code-11-Branch/yast2/library/types/testsuite/tests/URL.ycp
Tue Jul 7 13:54:50 2009
@@ -58,6 +58,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: branches/SuSE-Code-11-Branch/yast2/package/yast2.changes
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/yast2/package/yast2.changes?rev=57893&r1=57892&r2=57893&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/yast2/package/yast2.changes (original)
+++ branches/SuSE-Code-11-Branch/yast2/package/yast2.changes Tue Jul 7
13:54:50 2009
@@ -3,6 +3,7 @@

- Do not display "No package source" popup, just log a warning
(bnc#485587)
+- URL.ycp - fixed processing of smb:// URLs (bnc#495109)

-------------------------------------------------------------------
Thu Jul 2 12:14:53 CEST 2009 - jsuchome@xxxxxxx

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages