summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAudrius Meskauskas <audriusa@Bioinformatics.org>2006-09-03 20:42:41 +0000
committerAudrius Meskauskas <audriusa@Bioinformatics.org>2006-09-03 20:42:41 +0000
commitcd7581946c7aa6c94611ce57083e25d47e246918 (patch)
tree61736d476a38cfb5c0e2240c628e0447c8373e3d
parent07994ff1ea635fd8de324f090fdc9c12db2f944e (diff)
downloadclasspath-cd7581946c7aa6c94611ce57083e25d47e246918.tar.gz
2006-09-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>generics-merge-20060903
* gnu/javax/swing/text/html/parser/HTML_401F.java (defineElements): Disallow H1 - H6 in the paragraphs. * gnu/javax/swing/text/html/parser/support/textPreProcessor.java (preprocess): Leave at most one leading and/or trailing space. * javax/swing/text/html/HTMLDocument.java (HTMLReader.handleText): Do not add any text after closing the HTML tag.
-rw-r--r--ChangeLog9
-rw-r--r--gnu/javax/swing/text/html/parser/HTML_401F.java4
-rw-r--r--gnu/javax/swing/text/html/parser/support/textPreProcessor.java30
-rw-r--r--javax/swing/text/html/HTMLDocument.java2
4 files changed, 30 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 1e76416ca..ea695bbbe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-09-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/swing/text/html/parser/HTML_401F.java (defineElements):
+ Disallow H1 - H6 in the paragraphs.
+ * gnu/javax/swing/text/html/parser/support/textPreProcessor.java
+ (preprocess): Leave at most one leading and/or trailing space.
+ * javax/swing/text/html/HTMLDocument.java (HTMLReader.handleText):
+ Do not add any text after closing the HTML tag.
+
2006-09-02 Roman Kennke <kennke@aicas.com>
PR 28928
diff --git a/gnu/javax/swing/text/html/parser/HTML_401F.java b/gnu/javax/swing/text/html/parser/HTML_401F.java
index c3c347e36..1894b6a1a 100644
--- a/gnu/javax/swing/text/html/parser/HTML_401F.java
+++ b/gnu/javax/swing/text/html/parser/HTML_401F.java
@@ -2445,8 +2445,10 @@ public class HTML_401F
attr(VALUE, null, null, 0, IMPLIED)
}
);
+
+ // Headers in the paragraph are not allowed.
defElement(P, 0, false, true, new ContentModel( 0,
- new noTagModel(P), null),
+ new noTagModel(new String[] { P, H1, H2, H3, H4, H5, H6 }), null),
NONE
,
new String[] {
diff --git a/gnu/javax/swing/text/html/parser/support/textPreProcessor.java b/gnu/javax/swing/text/html/parser/support/textPreProcessor.java
index cc1610585..b81275b1f 100644
--- a/gnu/javax/swing/text/html/parser/support/textPreProcessor.java
+++ b/gnu/javax/swing/text/html/parser/support/textPreProcessor.java
@@ -42,17 +42,17 @@ import gnu.javax.swing.text.html.parser.support.low.Constants;
/**
* Pre - processes text in text parts of the html document.
- * Not thread - safe.
+ *
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class textPreProcessor
{
/**
- * Pre - process non-preformatted text.
- * \t, \r and \n mutate into spaces, then multiple spaces mutate
- * into single one, all whitespace around tags is consumed.
- * The content of the passed buffer is destroyed.
- * @param text A text to pre-process.
+ * Pre - process non-preformatted text. \t, \r and \n mutate into spaces, then
+ * multiple spaces mutate into single one, all whitespace around tags is
+ * consumed. The content of the passed buffer is destroyed.
+ *
+ * @param a_text A text to pre-process.
*/
public char[] preprocess(StringBuffer a_text)
{
@@ -64,17 +64,22 @@ public class textPreProcessor
int a = 0;
int b = text.length - 1;
+ // Remove leading/trailing whitespace, leaving at most one character
try
{
- while (Constants.bWHITESPACE.get(text [ a ]))
+ while (Constants.bWHITESPACE.get(text[a])
+ && Constants.bWHITESPACE.get(text[a + 1]))
a++;
- while (Constants.bWHITESPACE.get(text [ b ]))
+
+ while (b > a && Constants.bWHITESPACE.get(text[b])
+ && Constants.bWHITESPACE.get(text[b - 1]))
b--;
}
catch (ArrayIndexOutOfBoundsException sx)
{
- // A text fragment, consisting from line breaks only.
- return null;
+ // A text fragment, consisting from spaces and line breaks only,
+ // mutates into single space.
+ return new char[] { ' ' };
}
a_text.setLength(0);
@@ -83,10 +88,9 @@ public class textPreProcessor
boolean spaceNow;
char c;
- chars:
- for (int i = a; i <= b; i++)
+ chars: for (int i = a; i <= b; i++)
{
- c = text [ i ];
+ c = text[i];
spaceNow = Constants.bWHITESPACE.get(c);
if (spacesWere && spaceNow)
continue chars;
diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java
index 7a80bf7db..8933f7b06 100644
--- a/javax/swing/text/html/HTMLDocument.java
+++ b/javax/swing/text/html/HTMLDocument.java
@@ -1181,7 +1181,7 @@ public class HTMLDocument extends DefaultStyledDocument
*/
public void handleText(char[] data, int pos)
{
- if (data != null && data.length > 0)
+ if (shouldInsert() && data != null && data.length > 0)
addContent(data, 0, data.length);
}