Test attribute value delimiters.
authorMatthias Clasen <matthiasc@src.gnome.org>
Sat, 9 Feb 2002 22:08:10 +0000 (22:08 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 9 Feb 2002 22:08:10 +0000 (22:08 +0000)
* tests/markups/valid-4.gmarkup: Test attribute value delimiters.

* glib/gmarkup.c (g_markup_parse_context_parse): Support
' and " as attribute value delimiters.  (#70677)

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gmarkup.c
tests/markups/valid-4.gmarkup [new file with mode: 0644]

index 0f6a28a..2a100e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 0f6a28a..2a100e4 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-09  Matthias Clasen  <matthias@local>
+
+       * tests/markups/valid-4.gmarkup: Test attribute value delimiters.
+
+       * glib/gmarkup.c (g_markup_parse_context_parse): Support 
+       ' and " as attribute value delimiters.  (#70677)
+
 2002-02-09  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>
 
        * configure.in: Make --disable-threads work again. (#71034)
index 4381bdb..4386b04 100644 (file)
@@ -48,7 +48,8 @@ typedef enum
   STATE_INSIDE_ATTRIBUTE_NAME,
   STATE_BETWEEN_ATTRIBUTES,
   STATE_AFTER_ATTRIBUTE_EQUALS_SIGN,
-  STATE_INSIDE_ATTRIBUTE_VALUE,
+  STATE_INSIDE_ATTRIBUTE_VALUE_SQ,
+  STATE_INSIDE_ATTRIBUTE_VALUE_DQ,
   STATE_INSIDE_TEXT,
   STATE_AFTER_CLOSE_TAG_SLASH,
   STATE_INSIDE_CLOSE_TAG_NAME,
@@ -1213,11 +1214,17 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
           break;
 
         case STATE_AFTER_ATTRIBUTE_EQUALS_SIGN:
-          /* Possible next state: INSIDE_ATTRIBUTE_VALUE */
+          /* Possible next state: INSIDE_ATTRIBUTE_VALUE_[SQ/DQ] */
           if (*context->iter == '"')
             {
               advance_char (context);
-              context->state = STATE_INSIDE_ATTRIBUTE_VALUE;
+              context->state = STATE_INSIDE_ATTRIBUTE_VALUE_DQ;
+              context->start = context->iter;
+            }
+          else if (*context->iter == '\'')
+            {
+              advance_char (context);
+              context->state = STATE_INSIDE_ATTRIBUTE_VALUE_SQ;
               context->start = context->iter;
             }
           else
@@ -1235,15 +1242,28 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
             }
           break;
 
-        case STATE_INSIDE_ATTRIBUTE_VALUE:
+        case STATE_INSIDE_ATTRIBUTE_VALUE_SQ:
+        case STATE_INSIDE_ATTRIBUTE_VALUE_DQ:
           /* Possible next states: BETWEEN_ATTRIBUTES */
-          do
-            {
-              if (*context->iter == '"')
-                break;
-            }
-          while (advance_char (context));
-
+         {
+           gchar delim;
+
+           if (context->state == STATE_INSIDE_ATTRIBUTE_VALUE_SQ) 
+             {
+               delim = '\'';
+             }
+           else 
+             {
+               delim = '"';
+             }
+
+           do
+             {
+               if (*context->iter == delim)
+                 break;
+             }
+           while (advance_char (context));
+         }
           if (context->iter == context->current_text_end)
             {
               /* The value hasn't necessarily ended. Merge with
@@ -1599,7 +1619,8 @@ g_markup_parse_context_end_parse (GMarkupParseContext *context,
                    "following an attribute name; no attribute value"));
       break;
 
-    case STATE_INSIDE_ATTRIBUTE_VALUE:
+    case STATE_INSIDE_ATTRIBUTE_VALUE_SQ:
+    case STATE_INSIDE_ATTRIBUTE_VALUE_DQ:
       set_error (context, error, G_MARKUP_ERROR_PARSE,
                  _("Document ended unexpectedly while inside an attribute "
                    "value"));
diff --git a/tests/markups/valid-4.gmarkup b/tests/markups/valid-4.gmarkup
new file mode 100644 (file)
index 0000000..2036162
--- /dev/null
@@ -0,0 +1,8 @@
+<foo>
+<bar a='1'/>
+<bar a="2"/>
+<bar a='3"'/>
+<bar a="4'"/>
+<bar a="5''''"/>
+</foo>
+