[Httpunit-commit] SF.net SVN: httpunit:[1093] trunk/httpunit/src
Brought to you by:
russgold
|
From: <wol...@us...> - 2012-09-12 20:41:01
|
Revision: 1093
http://httpunit.svn.sourceforge.net/httpunit/?rev=1093&view=rev
Author: wolfgang_fahl
Date: 2012-09-12 20:40:55 +0000 (Wed, 12 Sep 2012)
Log Message:
-----------
fixes BR 2883515 noscript tag parsing incorrect
by Matthias Hanisch
Modified Paths:
--------------
trunk/httpunit/src/main/java/com/meterware/httpunit/WebResponse.java
trunk/httpunit/src/test/java/com/meterware/httpunit/WebPageTest.java
Modified: trunk/httpunit/src/main/java/com/meterware/httpunit/WebResponse.java
===================================================================
--- trunk/httpunit/src/main/java/com/meterware/httpunit/WebResponse.java 2012-09-12 20:16:44 UTC (rev 1092)
+++ trunk/httpunit/src/main/java/com/meterware/httpunit/WebResponse.java 2012-09-12 20:40:55 UTC (rev 1093)
@@ -1031,6 +1031,11 @@
}
+ /**
+ * replace the given text
+ * @param text - the text to replace
+ * @param contentType - the contenttype
+ */
public boolean replaceText( String text, String contentType ) {
if (_parsingPage) return false;
_responseText = text;
@@ -1174,18 +1179,24 @@
return available;
}
-
+ /**
+ * read the tags from the given message
+ * @param rawMessage
+ * @throws UnsupportedEncodingException
+ * @throws MalformedURLException
+ */
private void readTags( byte[] rawMessage ) throws UnsupportedEncodingException, MalformedURLException {
ByteTagParser parser = new ByteTagParser( rawMessage );
ByteTag tag = parser.getNextTag();
while (tag != null ) {
if (tag.getName().equalsIgnoreCase( "meta" )) processMetaTag( tag );
if (tag.getName().equalsIgnoreCase( "base" )) processBaseTag( tag );
+ // loop over a noscript region
if (tag.getName().equalsIgnoreCase( "noscript") && HttpUnitOptions.isScriptingEnabled()) {
do {
tag = parser.getNextTag();
}
- while (tag.getName().equalsIgnoreCase( "/noscript") );
+ while (!tag.getName().equalsIgnoreCase( "/noscript") );
}
tag = parser.getNextTag();
}
Modified: trunk/httpunit/src/test/java/com/meterware/httpunit/WebPageTest.java
===================================================================
--- trunk/httpunit/src/test/java/com/meterware/httpunit/WebPageTest.java 2012-09-12 20:16:44 UTC (rev 1092)
+++ trunk/httpunit/src/test/java/com/meterware/httpunit/WebPageTest.java 2012-09-12 20:40:55 UTC (rev 1093)
@@ -26,10 +26,12 @@
import java.io.IOException;
import java.net.URL;
+import org.junit.Ignore;
import org.junit.Test;
import org.w3c.dom.html.HTMLDocument;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
import static org.junit.Assert.*;
@@ -173,10 +175,10 @@
assertEquals("", text);
}
-
+ //@Ignore
@Test
public void testTitle() throws Exception {
- defineResource("SimpleTitlePage.html",
+ defineResource("/SimpleTitlePage.html",
"<html><head><title>A Sample Page</title></head>\n" +
"<body>This has no forms but it does\n" +
"have <a href=\"/other.html\">an <b>active</b> link</A>\n" +
@@ -191,7 +193,6 @@
assertNull("No refresh request should have been found", simplePage.getRefreshRequest());
}
-
@Test
public void testLocalFile() throws Exception {
File file = new File("temp.html");
@@ -591,6 +592,20 @@
//check the response
assertTrue(resp.getText().indexOf("Success") >= 0);
}
+
+ /**
+ * test case for BR 2883515
+ * @throws SAXException
+ * @throws IOException
+ */
+ @Test
+ public void testInvalidNoScriptHandling() throws IOException, SAXException {
+ defineResource("/InvalidNoScriptPage.html","<html><body></body></html><noscript>t</noscript>");
+ WebConversation wc = new WebConversation();
+ WebResponse resp = wc.getResponse(getHostPath() + "/InvalidNoScriptPage.html");
+ // indirectly invoke readTags
+ resp.replaceText("dummy", "dummy");
+ }
/**
* Create a fragment of HTML defining JavaScript that writes a document into a different window.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|