Author: lslezak
Date: Wed Apr 8 15:31:08 2009
New Revision: 56703
URL: http://svn.opensuse.org/viewcvs/yast?rev=56703&view=rev
Log:
- fixed SLP config - escape special characters and use [] brackets
instead of (), they have special meaning (bnc#492367)
Modified:
branches/tmp/SLE-11-SP1-Stash/instserver/package/yast2-instserver.changes
branches/tmp/SLE-11-SP1-Stash/instserver/src/Instserver.ycp
branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.out
branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.ycp
Modified: branches/tmp/SLE-11-SP1-Stash/instserver/package/yast2-instserver.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/instserver/package/yast2-instserver.changes?rev=56703&r1=56702&r2=56703&view=diff
==============================================================================
--- branches/tmp/SLE-11-SP1-Stash/instserver/package/yast2-instserver.changes (original)
+++ branches/tmp/SLE-11-SP1-Stash/instserver/package/yast2-instserver.changes Wed Apr 8 15:31:08 2009
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Apr 8 14:48:26 CEST 2009 - lslezak@suse.cz
+
+- 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@suse.cz
- write correct IP address to SLP config file when there is no eth0
Modified: branches/tmp/SLE-11-SP1-Stash/instserver/src/Instserver.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/instserver/src/Instserver.ycp?rev=56703&r1=56702&r2=56703&view=diff
==============================================================================
--- branches/tmp/SLE-11-SP1-Stash/instserver/src/Instserver.ycp (original)
+++ branches/tmp/SLE-11-SP1-Stash/instserver/src/Instserver.ycp Wed Apr 8 15:31:08 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 EscapeSLPData(map a)
+{
+ map 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/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.out
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.out?rev=56703&r1=56702&r2=56703&view=diff
==============================================================================
--- branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.out (original)
+++ branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.out Wed Apr 8 15:31:08 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/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.ycp?rev=56703&r1=56702&r2=56703&view=diff
==============================================================================
--- branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.ycp (original)
+++ branches/tmp/SLE-11-SP1-Stash/instserver/testsuite/tests/Instserver.ycp Wed Apr 8 15:31:08 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@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org