Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] r57903 - in /branches/SuSE-Code-11-Branch/instserver: package/yast2-instserver.changes src/Instserver.ycp testsuite/tests/Instserver.out testsuite/tests/Instserver.ycp
  • From: lslezak@xxxxxxxxxxxxxxxx
  • Date: Tue, 07 Jul 2009 12:52:59 -0000
  • Message-id: <E1MOAAN-0001Xz-6D@xxxxxxxxxxxxxxxx>
Author: lslezak
Date: Tue Jul 7 14:52:58 2009
New Revision: 57903

URL: http://svn.opensuse.org/viewcvs/yast?rev=57903&view=rev
Log:
- fixed SLP config - escape special characters and use [] brackets
instead of (), they have special meaning (bnc#492367)

Modified:
branches/SuSE-Code-11-Branch/instserver/package/yast2-instserver.changes
branches/SuSE-Code-11-Branch/instserver/src/Instserver.ycp
branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.out
branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.ycp

Modified:
branches/SuSE-Code-11-Branch/instserver/package/yast2-instserver.changes
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/instserver/package/yast2-instserver.changes?rev=57903&r1=57902&r2=57903&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/instserver/package/yast2-instserver.changes
(original)
+++ branches/SuSE-Code-11-Branch/instserver/package/yast2-instserver.changes
Tue Jul 7 14:52:58 2009
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Apr 8 14:48:26 CEST 2009 - lslezak@xxxxxxx
+
+- fixed SLP config - escape special characters and use [] brackets
+ instead of (), they have special meaning (bnc#492367)
+
+-------------------------------------------------------------------
Wed Mar 18 09:05:43 CET 2009 - lslezak@xxxxxxx

- write correct IP address to SLP config file when there is no eth0

Modified: branches/SuSE-Code-11-Branch/instserver/src/Instserver.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/instserver/src/Instserver.ycp?rev=57903&r1=57902&r2=57903&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/instserver/src/Instserver.ycp (original)
+++ branches/SuSE-Code-11-Branch/instserver/src/Instserver.ycp Tue Jul 7
14:52:58 2009
@@ -539,6 +539,39 @@
return true;
}

+// some values are not allowed in SLP attributes
+// and must be escaped ('\' followed by two hex numbers)
+// see RFC2614 (http://www.openslp.org/doc/rfc/rfc2614.txt)
+map<string, string> EscapeSLPData(map<string, string> a)
+{
+ map<string, string> ret = $[];
+
+ foreach(string key, string value, a,
+ {
+ // String::Replace() enters endless loop in '\' -> '\5c' conversion
+ // use splitstring() and mergestring() builtins instead
+ string new_key = mergestring(splitstring(key, "\\"), "\\5c");
+ new_key = String::Replace(new_key, ".", "\\2e");
+ new_key = String::Replace(new_key, "=", "\\3d");
+ new_key = String::Replace(new_key, "#", "\\23");
+ new_key = String::Replace(new_key, ";", "\\3b");
+
+ string new_value = mergestring(splitstring(value, "\\"), "\\5c");
+ new_value = String::Replace(new_value, "(", "\\28");
+ new_value = String::Replace(new_value, ")", "\\29");
+ new_value = String::Replace(new_value, ",", "\\2c");
+ new_value = String::Replace(new_value, "#", "\\23");
+ new_value = String::Replace(new_value, ";", "\\3b");
+
+ ret[new_key] = new_value;
+ }
+ );
+
+ y2milestone("Escaped SLP attributes: %1 -> %2", a, ret);
+
+ return ret;
+}
+
/*
* Return the IP address of the local machine
* @return string IP Address
@@ -622,7 +655,12 @@
hostname_reg = hostname + ": ";
}

- string descr = hostname_reg + sformat("%1 (%2)", cm["LABEL"]:"" ,
cm["DISTPRODUCT"]:"" );
+ string descr = hostname_reg + cm["LABEL"]:"";
+ if (cm["DISTPRODUCT"]:"" != "")
+ {
+ descr = descr + sformat(" [%2]", cm["DISTPRODUCT"]:"");
+ }
+
attr["description"] = descr;

string read_file = targetfile;
@@ -686,6 +724,9 @@
*/
}

+ // escape invalid characters
+ attr = EscapeSLPData(attr);
+
y2milestone("registering SLP service: serv: %1, attr: %2, regfile: %3",
serv, attr, regfile);

boolean ret = SLP::RegFile(serv, attr, regfile );

Modified: branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.out
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.out?rev=57903&r1=57902&r2=57903&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.out
(original)
+++ branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.out Tue
Jul 7 14:52:58 2009
@@ -1,2 +1,6 @@
Dump Instserver::Modified
Return false
+Dump Instserver::EscapeSLPData()
+Return $["description":"No need to escpace anything."]
+Return $["description":"Rounded brackets \\28\\29\\2c \\5c backslash and comma
\\2c must be escpaced."]
+Return $["escaped\\2e\\3dname":"value\\5c\\5c\\5c."]

Modified: branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.ycp?rev=57903&r1=57902&r2=57903&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.ycp
(original)
+++ branches/SuSE-Code-11-Branch/instserver/testsuite/tests/Instserver.ycp Tue
Jul 7 14:52:58 2009
@@ -10,4 +10,8 @@
DUMP("Instserver::Modified");
TEST(``(Instserver::Modified()), [], nil);

+DUMP("Instserver::EscapeSLPData()");
+TEST(``(Instserver::EscapeSLPData($["description" : "No need to escpace
anything."])), [], nil);
+TEST(``(Instserver::EscapeSLPData($["description" : "Rounded brackets (), \\
backslash and comma , must be escpaced."])), [], nil);
+TEST(``(Instserver::EscapeSLPData($["escaped.=name" : "value\\\\\\."])), [],
nil);
}

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

< Previous Next >
This Thread
  • No further messages