The HTML parser had a problem with whitespace. It inserted implied tags
for many occurances of whitespace where it should ignore it really. This
was caused by Audrius patch for that <b>Bold</b> <i>Italic</i>
whitespace problem (it threw away the whitespace in the middle
originally). He changed it so that such whitespace is preserved. This
however confuses the parser in other places.

I fixed it so that the parser checks the DTD if textual content is
actually allowed in the context before passing on such whitespace
fragments.

2006-11-07  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/javax/swing/text/html/parser/support/Parser.java
        (_handleText): Check if text content is actually allowed before
        passing empty text fragments on to the parser callbacks.

/Roman

Index: gnu/javax/swing/text/html/parser/support/Parser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/swing/text/html/parser/support/Parser.java,v
retrieving revision 1.8
diff -u -1 -5 -r1.8 Parser.java
--- gnu/javax/swing/text/html/parser/support/Parser.java	6 Nov 2006 20:28:55 -0000	1.8
+++ gnu/javax/swing/text/html/parser/support/Parser.java	7 Nov 2006 23:43:18 -0000
@@ -650,36 +650,40 @@
    * by the single one and the result is  moved into array,
    * passing it  to handleText().
    */
   protected void _handleText()
   {
     char[] text;
 
     if (preformatted > 0)
       text = textProcessor.preprocessPreformatted(buffer);
     else
       text = textProcessor.preprocess(buffer);
 
     if (text != null && text.length > 0)
       {
         TagElement pcdata = new TagElement(dtd.getElement("#pcdata"));
-        attributes = htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
-        _handleEmptyTag(pcdata);
+        if ((text.length > 1 && text[0] != ' ')
+            || validator.tagIsValidForContext(pcdata) == Boolean.TRUE)
+          {
+            attributes = htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
+            _handleEmptyTag(pcdata);
 
-        handleText(text);
-        if (titleOpen)
-          title.append(text);
+            handleText(text);
+            if (titleOpen)
+              title.append(text);
+          }
       }
   }
 
   /**
    * Add the image of this token to the buffer.
    * @param t A token to append.
    */
   protected final void append(Token t)
   {
     if (t.kind != EOF)
       t.appendTo(buffer);
   }
 
   /**
    * Consume pattern that must match.

Reply via email to