[ htmlunit-Bugs-1541150 ] set innerHTML uses 8bits for all chars and ignores some HTML

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ htmlunit-Bugs-1541150 ] set innerHTML uses 8bits for all chars and ignores some HTML

SourceForge.net
Bugs item #1541150, was opened at 2006-08-16 11:10
Message generated for change (Comment added) made by mguillem
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1541150&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sam Hough (salk31)
Assigned to: Nobody/Anonymous (nobody)
Summary: set innerHTML uses 8bits for all chars and ignores some HTML

Initial Comment:
jsxSet_innerHTML will not parse content as HTML if it
does not contain < so will ignore entities etc. It also
uses StringWebResponse which loses wide characters.

I'm keen to try and fix this myself. My best guess is
that creating a simpler fragment parser that doesn't go
 via StringWebResponse etc would be the best bet. Am I
missing some complexity related to setting innerHTML?

Please find below a patch to add a test for these two
problems.


Index: HTMLElementTest.java
===================================================================
RCS file:
/cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/HTMLElementTest.java,v
retrieving revision 1.39
diff -u -r1.39 HTMLElementTest.java
--- HTMLElementTest.java 27 Apr 2006 20:26:24 -0000 1.39
+++ HTMLElementTest.java 16 Aug 2006 08:59:47 -0000
@@ -368,6 +368,33 @@
         });
         assertEquals(expectedAlerts, collectedAlerts);
     }
+    
+    public void testGetSetInnerHTMLChar() throws
Exception {
+        final String content = "<html>\n" +
+                "<head>\n" +
+                "    <title>test</title>\n" +
+                "    <script>\n" +
+                "    function doTest(){\n" +
+                "       var myNode =
document.getElementById('myNode');\n" +
+                "       alert('Old = ' +
myNode.innerHTML);\n" +
+                "       myNode.innerHTML = 'New  cell
value &amp; \u0110 &#272;';\n" +
+                "       alert('New = ' +
myNode.innerHTML);\n" +
+                "   }\n" +
+                "    </script>\n" +
+                "</head>\n" +
+                "<body onload='doTest()'>\n" +
+                "<p id='myNode'><b>Old
innerHTML</b></p>\n" +
+                "</body>\n" +
+                "</html>\n" +
+                "";
+        final List collectedAlerts = new ArrayList();
+        loadPage(content, collectedAlerts);
+        final List expectedAlerts = Arrays.asList(new
String[]{
+            "Old = <b>Old innerHTML</b>",
+            "New = New cell value &amp; \u0110 \u0110"
+        });
+        assertEquals(expectedAlerts, collectedAlerts);
+    }
 
     /**
      *


----------------------------------------------------------------------

>Comment By: Marc Guillemot (mguillem)
Date: 2006-10-30 11:20

Message:
Logged In: YES
user_id=402164

Sorry I didn't see the patch before.

I've problems applying it and failed doing the merge
manually (I guess that my manual merge missed something as
some unit test fail).

Is your patch really in unified diff format?

Btw, please use maven htmlunit:checkstyle to be sure to
respect htmlunit's convention.

Yes, next release should have this patch in it... if I'm
able to apply it ;-(

----------------------------------------------------------------------

Comment By: Sam Hough (salk31)
Date: 2006-10-29 22:30

Message:
Logged In: YES
user_id=561289

kriszyp,

Have you tried my patch? Might help get it accepted if you
could comment on how well it worked for you.

Cheers

Sam

----------------------------------------------------------------------

Comment By: Kris Zyp (kriszyp)
Date: 2006-10-28 19:44

Message:
Logged In: YES
user_id=1542119

Is this bug fixed?  I would really like to have a fix for this bug.  Will HTMLUnit 1.10 have
this fix in it?

----------------------------------------------------------------------

Comment By: Sam Hough (salk31)
Date: 2006-08-28 01:27

Message:
Logged In: YES
user_id=561289

Please find attached v1 of my patch. It is more extensive
than I would like but I think it makes sense. Seems to fix
1192854. It might also fix 1495132 but server is down at the
moment so I can't read the details.

----------------------------------------------------------------------

Comment By: Sam Hough (salk31)
Date: 2006-08-19 12:19

Message:
Logged In: YES
user_id=561289

I've got a patch working that doesn't use a fake WebResponse
so avoids the character encoding problem. However the
version I had that parsed a fragment into the existing page
broke on test
"testDocumentWriteFrameRelativeURLMultipleFrameset".

Anyway, I'm away for the next week. If nobody has a better
idea before then I'll tidy up what I have and submit a patch.

----------------------------------------------------------------------

Comment By: Sam Hough (salk31)
Date: 2006-08-18 11:32

Message:
Logged In: YES
user_id=561289

Nearly got a possible patch ready and found that my unit
test  has a mistake. Might be best to wait till I have a
patch containing new version and fix. In the test JavaScript
I should have double escaped the character. So \\u0110
rather than \u0110.

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2006-08-17 21:20

Message:
Logged In: YES
user_id=402164

I agree that a fragment parser would be better than using a
StringWebResponse. Thanks for the unit test, I will
integrate asap.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1541150&group_id=47038

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop