@@ -483,8 +483,8 @@ public class HTMLScanner implements XMLDocumentSource, XMLLocator, HTMLComponent
483483
484484 /**
485485 * Special scanner used for elements whose content needs to be scanned as plain
486- * text, ignoring markup such as elements and entity references. For example:
487- * <SCRIPT > and <COMMENT >.
486+ * text, ignoring markup such as elements and entity references. (<TITLE>,
487+ * <STYLE >, <TEXTAREA> and <XMP >) .
488488 */
489489 protected final SpecialScanner fSpecialScanner = new SpecialScanner ();
490490
@@ -3518,24 +3518,19 @@ protected void scanEndElement() throws IOException {
35183518
35193519 /**
35203520 * Special scanner used for elements whose content needs to be scanned as plain
3521- * text, ignoring markup such as elements and entity references. For example:
3522- * <SCRIPT > and <COMMENT >.
3521+ * text, ignoring markup such as elements and entity references.(<TITLE>,
3522+ * <STYLE >, <TEXTAREA> and <XMP >)
35233523 */
3524- public class SpecialScanner implements Scanner {
3524+ public final class SpecialScanner implements Scanner {
35253525
35263526 /** Name of element whose content needs to be scanned as text. */
3527- protected String fElementName ;
3527+ private String fElementName ;
35283528
35293529 /** True if <style> element. */
3530- protected boolean fStyle ;
3530+ private boolean fStyle ;
35313531
3532- /** True if <textarea> element. */
3533- protected boolean fTextarea ;
3534-
3535- /** True if <title> element. */
3536- protected boolean fTitle ;
3537-
3538- // temp vars
3532+ /** True if <textarea> or <title> element. */
3533+ private boolean fTextareaOrTitle ;
35393534
35403535 /** A qualified name. */
35413536 private final QName fQName_ = new QName ();
@@ -3546,9 +3541,12 @@ public class SpecialScanner implements Scanner {
35463541 // Sets the element name.
35473542 public Scanner setElementName (final String ename , final String enameLC ) {
35483543 fElementName = ename ;
3544+
35493545 fStyle = "style" .equals (enameLC );
3550- fTextarea = "textarea" .equals (enameLC );
3551- fTitle = "title" .equals (enameLC );
3546+ fTextareaOrTitle = "textarea" .equals (enameLC ) || "title" .equals (enameLC );
3547+
3548+ charBuffer_ .clear ();
3549+
35523550 return this ;
35533551 }
35543552
@@ -3582,7 +3580,7 @@ public int scan(final boolean complete) throws IOException {
35823580 continue ;
35833581 }
35843582 if (c == '&' ) {
3585- if (fTextarea || fTitle ) {
3583+ if (fTextareaOrTitle ) {
35863584 scanEntityRef (charBuffer_ , null , true );
35873585 continue ;
35883586 }
@@ -3638,6 +3636,7 @@ public int scan(final boolean complete) throws IOException {
36383636 }
36393637 }
36403638 while (complete );
3639+
36413640 return SCAN_TRUE ;
36423641 }
36433642
0 commit comments