[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags ScriptTag.java,1.35,1.36 Tag.java,1.61,1.62
Brought to you by:
derrickoswald
From: <der...@us...> - 2004-02-28 16:10:08
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv977/tags Modified Files: ScriptTag.java Tag.java Log Message: Fix bug #902121 StringBean throws NullPointerException. Added ScriptDecoder to handle Microsoft Script Encoder encrypted tags. Added accessor to ScriptTag's scriptCode property to be able to override it. Ensured that a Tag always has a non-null name. Skip STYLE tags in StringBean, just like SCRIPT. Index: ScriptTag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/ScriptTag.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** ScriptTag.java 2 Jan 2004 16:24:55 -0000 1.35 --- ScriptTag.java 28 Feb 2004 15:52:43 -0000 1.36 *************** *** 45,48 **** --- 45,53 ---- /** + * Script code if different from the page contents. + */ + protected String mCode; + + /** * Create a new script tag. */ *************** *** 79,87 **** /** ! * Get the contents of the tag's children. */ ! public String getScriptCode() { ! return (getChildrenHTML ()); } --- 84,111 ---- /** ! * Get the script code. ! * Normally this is the contents of the children, but in the rare case that ! * the script is encoded, this is the plaintext decrypted code. ! * @return The plaintext or overridden code contents of the tag. */ ! public String getScriptCode () { ! String ret; ! ! if (null != mCode) ! ret = mCode; ! else ! ret = getChildrenHTML (); ! ! return (ret); ! } ! ! /** ! * Set the code contents. ! * @param code The new code contents of this tag. ! */ ! public void setScriptCode (String code) ! { ! mCode = code; } *************** *** 113,116 **** --- 137,164 ---- /** + * Render the tag as HTML. + * @return The tag as an HTML fragment. + * @see org.htmlparser.Node#toHtml() + */ + public String toHtml() + { + StringBuffer ret; + + ret = new StringBuffer (); + ret.append (super.toHtml ()); + if (!isEmptyXmlTag ()) + { + if (null != getScriptCode ()) + ret.append (getScriptCode ()); + else + putChildrenInto (ret); + if (null != getEndTag ()) + putEndTagInto (ret); + } + + return (ret.toString()); + } + + /** * Print the contents of the script tag. */ Index: Tag.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Tag.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** Tag.java 14 Jan 2004 02:53:46 -0000 1.61 --- Tag.java 28 Feb 2004 15:52:43 -0000 1.62 *************** *** 64,67 **** --- 64,69 ---- if ((null != names) && (0 != names.length)) setTagName (names[0]); + else + setTagName (""); // make sure it's not null setThisScanner (mDefaultScanner); } *************** *** 71,74 **** --- 73,78 ---- super (node.getPage (), node.getTagBegin (), node.getTagEnd (), node.getAttributesEx ()); mScanner = scanner; + if (null == getTagName ()) + setTagName (""); // make sure it's not null } *************** *** 77,80 **** --- 81,86 ---- super (page, start, end, attributes); mScanner = null; + if (null == getTagName ()) + setTagName (""); // make sure it's not null } |