diff options
author | Matthias Clasen <maclas@gmx.de> | 2002-05-18 22:06:54 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-05-18 22:06:54 +0000 |
commit | 60f59976d909a2d77a47ef09140ffcdac2187d92 (patch) | |
tree | b98dd59a6dcfddf8f6fed79b48503228c710419a | |
parent | ed8f19b4c649b79f6eea12ed60ffd6c0cfb8c0e8 (diff) |
New testcases.
2002-05-18 Matthias Clasen <maclas@gmx.de>
* tests/markups/fail-36.gmarkup:
* tests/markups/fail-35.gmarkup:
* tests/markups/valid-8.gmarkup:
* tests/markups/valid-7.gmarkup:
* tests/markups/valid-6.gmarkup:
* tests/markups/valid-5.gmarkup: New testcases.
* tests/markup-test.c (passthrough_handler):
(text_handler): Don't ignore the text_len parameter.
* glib/gmarkup.c (find_current_text_end): Don't hang on embedded
nuls. (#81977)
(g_markup_parse_context_parse): Fix passthrough handling to
correctly skip processing instructions, comments, doctype
declarations and CDATA marked sections. (#81977)
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 18 | ||||
-rw-r--r-- | glib/gmarkup.c | 29 | ||||
-rw-r--r-- | tests/markup-test.c | 5 | ||||
-rw-r--r-- | tests/markups/fail-35.gmarkup | 1 | ||||
-rw-r--r-- | tests/markups/fail-36.gmarkup | bin | 0 -> 13 bytes | |||
-rw-r--r-- | tests/markups/valid-5.gmarkup | 2 | ||||
-rw-r--r-- | tests/markups/valid-6.gmarkup | 4 | ||||
-rw-r--r-- | tests/markups/valid-7.gmarkup | 2 | ||||
-rw-r--r-- | tests/markups/valid-8.gmarkup | 1 | ||||
-rwxr-xr-x | tests/run-markup-tests.sh | 3 |
16 files changed, 167 insertions, 6 deletions
@@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 024e7a57e..311a2c73b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 024e7a57e..311a2c73b 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 024e7a57e..311a2c73b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 024e7a57e..311a2c73b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 024e7a57e..311a2c73b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 024e7a57e..311a2c73b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +2002-05-18 Matthias Clasen <maclas@gmx.de> + + * tests/markups/fail-36.gmarkup: + * tests/markups/fail-35.gmarkup: + * tests/markups/valid-8.gmarkup: + * tests/markups/valid-7.gmarkup: + * tests/markups/valid-6.gmarkup: + * tests/markups/valid-5.gmarkup: New testcases. + + * tests/markup-test.c (passthrough_handler): + (text_handler): Don't ignore the text_len parameter. + + * glib/gmarkup.c (find_current_text_end): Don't hang on embedded + nuls. (#81977) + (g_markup_parse_context_parse): Fix passthrough handling to + correctly skip processing instructions, comments, doctype + declarations and CDATA marked sections. (#81977) + Sat May 18 00:21:51 2002 Tim Janik <timj@gtk.org> [merged from stable] diff --git a/glib/gmarkup.c b/glib/gmarkup.c index 8f5c6b861..f7a2cbf48 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -97,6 +97,7 @@ struct _GMarkupParseContext guint document_empty : 1; guint parsing : 1; + gint balance; }; /** @@ -154,6 +155,8 @@ g_markup_parse_context_new (const GMarkupParser *parser, context->document_empty = TRUE; context->parsing = FALSE; + context->balance = 0; + return context; } @@ -722,8 +725,10 @@ find_current_text_end (GMarkupParseContext *context) p = context->current_text; next = g_utf8_find_next_char (p, end); - while (next) + while (next && *next) { + if (p == next) + next++; p = next; next = g_utf8_find_next_char (p, end); } @@ -963,6 +968,7 @@ g_markup_parse_context_parse (GMarkupParseContext *context, const gchar *openangle = "<"; add_to_partial (context, openangle, openangle + 1); context->start = context->iter; + context->balance = 1; context->state = STATE_INSIDE_PASSTHROUGH; } else if (*context->iter == '/') @@ -1493,13 +1499,28 @@ g_markup_parse_context_parse (GMarkupParseContext *context, g_free (close_name); } break; - + case STATE_INSIDE_PASSTHROUGH: /* Possible next state: AFTER_CLOSE_ANGLE */ do { - if (*context->iter == '>') - break; + if (*context->iter == '<') + context->balance++; + if (*context->iter == '>') + { + context->balance--; + add_to_partial (context, context->start, context->iter); + context->start = context->iter; + if ((g_str_has_prefix (context->partial_chunk->str, "<?") + && g_str_has_suffix (context->partial_chunk->str, "?")) || + (g_str_has_prefix (context->partial_chunk->str, "<!--") + && g_str_has_suffix (context->partial_chunk->str, "--")) || + (g_str_has_prefix (context->partial_chunk->str, "<![CDATA[") + && g_str_has_suffix (context->partial_chunk->str, "]]")) || + (g_str_has_prefix (context->partial_chunk->str, "<!DOCTYPE") + && context->balance == 0)) + break; + } } while (advance_char (context)); diff --git a/tests/markup-test.c b/tests/markup-test.c index 53b86c2cd..c174066ec 100644 --- a/tests/markup-test.c +++ b/tests/markup-test.c @@ -61,7 +61,7 @@ text_handler (GMarkupParseContext *context, GError **error) { indent (0); - printf ("TEXT '%s'\n", text); + printf ("TEXT '%.*s'\n", (int)text_len, text); } @@ -74,7 +74,7 @@ passthrough_handler (GMarkupParseContext *context, { indent (0); - printf ("PASS '%s'\n", passthrough_text); + printf ("PASS '%.*s'\n", (int)text_len, passthrough_text); } static void @@ -200,3 +200,4 @@ main (int argc, return 1; } } + diff --git a/tests/markups/fail-35.gmarkup b/tests/markups/fail-35.gmarkup new file mode 100644 index 000000000..d7f35120a --- /dev/null +++ b/tests/markups/fail-35.gmarkup @@ -0,0 +1 @@ +<foo>gedit&</foo> diff --git a/tests/markups/fail-36.gmarkup b/tests/markups/fail-36.gmarkup Binary files differnew file mode 100644 index 000000000..110ce48bb --- /dev/null +++ b/tests/markups/fail-36.gmarkup diff --git a/tests/markups/valid-5.gmarkup b/tests/markups/valid-5.gmarkup new file mode 100644 index 000000000..3b861de5a --- /dev/null +++ b/tests/markups/valid-5.gmarkup @@ -0,0 +1,2 @@ +<?xml version="1.0" ?> +<foo></foo> diff --git a/tests/markups/valid-6.gmarkup b/tests/markups/valid-6.gmarkup new file mode 100644 index 000000000..d7c065a32 --- /dev/null +++ b/tests/markups/valid-6.gmarkup @@ -0,0 +1,4 @@ +<!DOCTYPE foo "foo" [ +<!ELEMENT foo ANY > +]> +<foo></foo> diff --git a/tests/markups/valid-7.gmarkup b/tests/markups/valid-7.gmarkup new file mode 100644 index 000000000..832445d6d --- /dev/null +++ b/tests/markups/valid-7.gmarkup @@ -0,0 +1,2 @@ +<!-- a comment --> +<foo></foo> diff --git a/tests/markups/valid-8.gmarkup b/tests/markups/valid-8.gmarkup new file mode 100644 index 000000000..a75aee055 --- /dev/null +++ b/tests/markups/valid-8.gmarkup @@ -0,0 +1 @@ +<foo><![CDATA[ some <<<<>>>> CDATA ]]></foo> diff --git a/tests/run-markup-tests.sh b/tests/run-markup-tests.sh index 2078330ee..fb6508622 100755 --- a/tests/run-markup-tests.sh +++ b/tests/run-markup-tests.sh @@ -9,6 +9,9 @@ fail () for I in $srcdir/markups/fail-*.gmarkup; do echo "Parsing $I, should fail" ./markup-test $I > /dev/null && fail "failed to generate error on $I" + if test "$?" != "1"; then + fail "unexpected error on $I" + fi done for I in $srcdir/markups/valid-*.gmarkup; do |