summaryrefslogtreecommitdiff
path: root/gnu/javax/swing/text/html/parser/support/Parser.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/javax/swing/text/html/parser/support/Parser.java')
-rw-r--r--gnu/javax/swing/text/html/parser/support/Parser.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/gnu/javax/swing/text/html/parser/support/Parser.java b/gnu/javax/swing/text/html/parser/support/Parser.java
index f1f25fad0..98058e503 100644
--- a/gnu/javax/swing/text/html/parser/support/Parser.java
+++ b/gnu/javax/swing/text/html/parser/support/Parser.java
@@ -659,19 +659,18 @@ public class Parser
else
text = textProcessor.preprocess(buffer);
- if (text != null && text.length > 0)
+ if (text != null && text.length > 0
+ // According to the specs we need to discard whitespace immediately
+ // before a closing tag.
+ && (text.length > 1 || text[0] != ' ' || ! TAG_CLOSE.matches(this)))
{
TagElement pcdata = new TagElement(dtd.getElement("#pcdata"));
- if ((text.length > 1 && text[0] != ' ')
- || validator.tagIsValidForContext(pcdata) == Boolean.TRUE)
- {
- attributes = htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
- _handleEmptyTag(pcdata);
+ attributes = htmlAttributeSet.EMPTY_HTML_ATTRIBUTE_SET;
+ _handleEmptyTag(pcdata);
- handleText(text);
- if (titleOpen)
- title.append(text);
- }
+ handleText(text);
+ if (titleOpen)
+ title.append(text);
}
}
@@ -1197,8 +1196,8 @@ public class Parser
*/
private void _handleEndTag(TagElement tag)
{
- validator.closeTag(tag);
- _handleEndTag_remaining(tag);
+ if (validator.closeTag(tag))
+ _handleEndTag_remaining(tag);
}
/**
@@ -1218,6 +1217,11 @@ public class Parser
if (preformatted < 0)
preformatted = 0;
+ // When a block tag is closed, consume whitespace that follows after
+ // it.
+ if (h.isBlock())
+ optional(WS);
+
if (h == HTML.Tag.TITLE)
{
titleOpen = false;
@@ -1460,7 +1464,12 @@ public class Parser
if (te.getElement().type == DTDConstants.EMPTY)
_handleEmptyTag(te);
else
- _handleStartTag(te);
+ {
+ // According to the specs we need to consume whitespace following
+ // immediately after a opening tag.
+ optional(WS);
+ _handleStartTag(te);
+ }
}
}