Author: lslezak
Date: Tue Apr 28 15:57:28 2009
New Revision: 57005
URL: http://svn.opensuse.org/viewcvs/yast?rev=57005&view=rev
Log:
- URL.ycp - escape also non-ASCII characters in URL, added
URLRecode.pm module (bnc#446395)
Added:
trunk/yast2/library/types/src/URLRecode.pm
Modified:
trunk/yast2/library/types/src/Makefile.am
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/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/src/Makefile.am?rev=57005&r1=57004&r2=57005&view=diff
==============================================================================
--- trunk/yast2/library/types/src/Makefile.am (original)
+++ trunk/yast2/library/types/src/Makefile.am Tue Apr 28 15:57:28 2009
@@ -1,6 +1,6 @@
# Makefile.am for yast2/library/types/src
-module_DATA = $(wildcard *.ycp)
+module_DATA = $(wildcard *.ycp) $(wildcard *.pm)
EXTRA_DIST = $(module_DATA)
include $(top_srcdir)/Makefile.am.common
Modified: trunk/yast2/library/types/src/URL.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/src/URL.ycp?rev=57005&r1=57004&r2=57005&view=diff
==============================================================================
--- trunk/yast2/library/types/src/URL.ycp (original)
+++ trunk/yast2/library/types/src/URL.ycp Tue Apr 28 15:57:28 2009
@@ -17,6 +17,7 @@
import "Hostname";
import "String";
import "IP";
+import "URLRecode";
/**
* TODO:
@@ -200,9 +201,9 @@
pth = substring (pth, 1);
}
}
- tokens["path"] = UnEscapeString(pth, transform_map_filename);
- tokens["query"] = UnEscapeString(rawtokens[5]:"", transform_map_query);
- tokens["fragment"] = UnEscapeString(rawtokens[7]:"", transform_map_passwd);
+ tokens["path"] = URLRecode::UnEscape(pth);
+ tokens["query"] = URLRecode::UnEscape(rawtokens[5]:"");
+ tokens["fragment"] = URLRecode::UnEscape(rawtokens[7]:"");
/* Extract username:pass@host:port */
list userpass = regexptokenize(rawtokens[2]:"", "^" +
@@ -216,8 +217,8 @@
);
y2debug("userpass=%1", userpass);
- tokens["user"] = UnEscapeString(userpass[1]:"", transform_map_passwd);
- tokens["pass"] = UnEscapeString(userpass[3]:"", transform_map_passwd);
+ tokens["user"] = URLRecode::UnEscape(userpass[1]:"");
+ tokens["pass"] = URLRecode::UnEscape(userpass[3]:"");
tokens["port"] = userpass[7]:"";
if(userpass[5]:"" != "")
@@ -310,6 +311,8 @@
string url = "";
string userpass = "";
+ y2debug("URL::Build(): input: %1", tokens);
+
if(regexpmatch(tokens["scheme"]:"", "^[[:alpha:]]*$"))
{
/* if (tokens["scheme"]:"" == "samba") url="smb";
@@ -318,12 +321,12 @@
y2debug("url: %1", url);
if (tokens["user"]:"" != "")
{
- userpass = EscapeString(tokens["user"]:"", transform_map_passwd);
+ userpass = URLRecode::EscapePassword(tokens["user"]:"");
y2milestone("Escaped username '%1' => '%2'", tokens["user"]:"", userpass);
}
if (size(userpass) != 0 && tokens["pass"]:"" != "" )
{
- userpass = sformat("%1:%2", userpass, EscapeString(tokens["pass"]:"", transform_map_passwd) );
+ userpass = sformat("%1:%2", userpass, URLRecode::EscapePassword(tokens["pass"]:"") );
}
if (size(userpass) > 0 ) userpass = userpass + "@";
@@ -351,25 +354,25 @@
// path is not empty and doesn't start with "/"
if (tokens["path"]:"" != "" && ! regexpmatch (tokens["path"]:"", "^/"))
- url = sformat("%1/%2", url, EscapeString(tokens["path"]:"", transform_map_filename));
+ url = sformat("%1/%2", url, URLRecode::EscapePath(tokens["path"]:""));
// patch is not empty and starts with "/"
else if (tokens["path"]:"" != "" && regexpmatch (tokens["path"]:"", "^/"))
{
while (substring (tokens["path"]:"", 0, 2) == "//")
tokens["path"] = substring (tokens["path"]:"", 1);
if (tokens["scheme"]:"" == "ftp") {
- url = sformat("%1/%%2f%2", url, substring(EscapeString(tokens["path"]:"", transform_map_filename), 1));
+ url = sformat("%1/%%2f%2", url, substring(URLRecode::EscapePath(tokens["path"]:""), 1));
}
else {
- url = sformat("%1%2", url, EscapeString(tokens["path"]:"", transform_map_filename));
+ url = sformat("%1%2", url, URLRecode::EscapePath(tokens["path"]:""));
}
}
y2debug("url: %1", url);
if (tokens["query"]:"" != "" )
- url = sformat("%1?%2", url, EscapeString(tokens["query"]:"", transform_map_query));
+ url = sformat("%1?%2", url, URLRecode::EscapeQuery(tokens["query"]:""));
if (tokens["fragment"]:"" != "" )
- url = sformat("%1#%2", url, EscapeString(tokens["fragment"]:"", transform_map_passwd));
+ url = sformat("%1#%2", url, URLRecode::EscapePassword(tokens["fragment"]:""));
y2debug("url: %1", url);
if (!Check(url)) {
@@ -377,6 +380,8 @@
return "";
}
+ y2debug("URL::Build(): result: %1", url);
+
return url;
}
Added: trunk/yast2/library/types/src/URLRecode.pm
URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/types/src/URLRecode.pm?rev=57005&view=auto
==============================================================================
--- trunk/yast2/library/types/src/URLRecode.pm (added)
+++ trunk/yast2/library/types/src/URLRecode.pm Tue Apr 28 15:57:28 2009
@@ -0,0 +1,87 @@
+#!/usr/bin/perl -w
+#
+# Author: Ladislav Slezák