Reviewers: MikeSamuel,

Description:
Prior to r3844, html with an invalid attr like
  <div title='bob's foo'>
would have the bad "foo'" attribute deleted with a warning.

r3844 changed that to be a fatal error.

Bad attributes are unfortunately common, for many reasons.
Usually because they're typos of some sort.

This CL downgrades the error to a warning.

Please review this at http://codereview.appspot.com/164070

Affected files:
  M     src/com/google/caja/parser/html/Html5ElementStack.java
  M     tests/com/google/caja/parser/html/DomParserTest.java


Index: tests/com/google/caja/parser/html/DomParserTest.java
===================================================================
--- tests/com/google/caja/parser/html/DomParserTest.java        (revision 3883)
+++ tests/com/google/caja/parser/html/DomParserTest.java        (working copy)
@@ -2009,7 +2009,7 @@
             "    Text : first part of the text</> second part 1+15-1+52"
             ),
         Arrays.asList(
-            "ERROR testShortTags:1+3 - 5: Malformed identifier <a"),
+            "WARNING testShortTags:1+3 - 5: Malformed identifier <a"),
         Arrays.asList(
             "<p href=\"/\">"
             + "first part of the text&lt;/&gt; second part</p>"
Index: src/com/google/caja/parser/html/Html5ElementStack.java
===================================================================
--- src/com/google/caja/parser/html/Html5ElementStack.java      (revision 3883)
+++ src/com/google/caja/parser/html/Html5ElementStack.java      (working copy)
@@ -327,9 +327,11 @@
             }
             attrs.add(attrNode);
           } catch (DOMException ex) {
-            ex.printStackTrace();
-            mq.addMessage(MessageType.INVALID_IDENTIFIER, as.nameTok.pos,
-                          MessagePart.Factory.valueOf(as.nameTok.text));
+            mq.addMessage(
+                MessageType.INVALID_IDENTIFIER,
+                MessageLevel.WARNING,
+                as.nameTok.pos,
+                MessagePart.Factory.valueOf(as.nameTok.text));
           }
         }
         attrImpl = new AttributesImpl(attrs);


Reply via email to