Author: michael_meeks
Date: Fri Feb 13 12:35:49 2009
New Revision: 55491
URL: http://svn.opensuse.org/viewcvs/yast?rev=55491&view=rev
Log:
2009-02-13 Michael Meeks
* src/YGUtils.cc (ygutils_convert_to_xhtml): handle
mangled entities appearing in URLs around the place:
bug 475275.
* src/test.cc (testXHtmlConvert): upd. regression tests.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGUtils.cc
trunk/gtk/src/test.cc
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=55491&r1=55490&r2=55491&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Fri Feb 13 12:35:49 2009
@@ -1,3 +1,11 @@
+2009-02-13 Michael Meeks
+
+ * src/YGUtils.cc (ygutils_convert_to_xhtml): handle
+ mangled entities appearing in URLs around the place:
+ bug 475275.
+
+ * src/test.cc (testXHtmlConvert): upd. regression tests.
+
2009-01-26 Ricardo Cruz
* src/YGSelectionModel.h: decoupled doSelectItem(NULL) into
Modified: trunk/gtk/src/YGUtils.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUtils.cc?rev=55491&r1=55490&r2=55491&view=diff
==============================================================================
--- trunk/gtk/src/YGUtils.cc (original)
+++ trunk/gtk/src/YGUtils.cc Fri Feb 13 12:35:49 2009
@@ -246,8 +246,18 @@
i += strlen (entity->html);
if (instr[i+1] == ';') i++;
}
- else
- g_string_append_c (outp, instr[i]);
+ else {
+ int j;
+ // check it is a valid entity - not a floating '&' in a <pre> tag eg.
+ for (j = i + 1; instr[j] != '\0'; j++) {
+ if (!g_ascii_isalnum (instr[j]) && instr[j] != '#')
+ break;
+ }
+ if (instr[j] != ';') // entity terminator
+ g_string_append (outp, "&");
+ else
+ g_string_append_c (outp, instr[i]);
+ }
was_space = FALSE;
}
Modified: trunk/gtk/src/test.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/test.cc?rev=55491&r1=55490&r2=55491&view=diff
==============================================================================
--- trunk/gtk/src/test.cc (original)
+++ trunk/gtk/src/test.cc Fri Feb 13 12:35:49 2009
@@ -41,6 +41,22 @@
#include "ygtkrichtext.h"
+bool testParse(const char *xml)
+{
+ GError *error = NULL;
+ GMarkupParser parser = { 0, };
+ GMarkupParseContext *ctx = g_markup_parse_context_new (&parser, GMarkupParseFlags (0), NULL, NULL);
+
+ if (!g_markup_parse_context_parse (ctx, xml, -1, &error))
+ {
+ fprintf (stderr, "Invalid XML: '%s'\n '%s'\n", xml, error->message);
+ return false;
+ }
+ g_markup_parse_context_free (ctx);
+
+ return true;
+}
+
bool testXHtmlConvert()
{
fprintf (stderr, "Test HTML->XML rewrite \t");
@@ -76,6 +92,12 @@
// comment
{ "we need <b>to <!-- really need to? --> do something</b> about it.",
"<body>we need <b>to do something</b> about it.</body>" },
+ { "&", "<body>&</body>" },
+ { "&", "<body>&</body>" },
+ { "& foo", "<body>& foo</body>" },
+ { "& foo", "<body>& foo</body>" },
+ { "<pre>https://foo.com/regsvc-1.0/?lang=de-DE&guid=1529f49dc701449fbd854aebf7e40806&command=interactive</pre>\n",
+ "<body><pre>https://foo.com/regsvc-1.0/?lang=de-DE&guid=1529f49dc701449fbd854aebf7e4...</pre> </body>" },
{ NULL, NULL }
};
for (int i = 0; aTests[i].in; i++) {
@@ -85,6 +107,9 @@
i, out, aTests[i].out);
return false;
}
+ if (!testParse (out))
+ return false;
+
fprintf (stderr, "%d ", i);
g_free (out);
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org