Bug 24883 - Bad success test in parseXMLDocumentFragment in XMLTokenizerLibxml2.cpp
Summary: Bad success test in parseXMLDocumentFragment in XMLTokenizerLibxml2.cpp
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-27 06:50 PDT by Kai Brüning
Modified: 2009-05-04 17:22 PDT (History)
0 users

See Also:


Attachments
Fix with test case (4.20 KB, patch)
2009-03-27 07:07 PDT, Kai Brüning
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Brüning 2009-03-27 06:50:56 PDT
parseXMLDocumentFragment in XMLTokenizerLibxml2.cpp contains the following clause:

    if (bytesProcessed == -1 || ((unsigned long)bytesProcessed) == sizeof(UChar) * chunk.length())
        return false;

The second term probably meant to test for !=. As it stands, this term almost never evaluates to true due to a second mistake: 'chunk' is UTF8, therefore multiplying with sizeof(UChar) is wrong.

I hit a case in which the term evaluates to true and thereby makes the function fail: if 'chunk' contains a single non breaking space (or any other character which use two bytes in UTF8).
Comment 1 Kai Brüning 2009-03-27 07:07:55 PDT
Created attachment 29010 [details]
Fix with test case
Comment 2 Eric Seidel (no email) 2009-05-04 01:43:35 PDT
Comment on attachment 29010 [details]
Fix with test case

This looks correct to me.  Thanks for the patch and layout test!
Comment 3 Eric Seidel (no email) 2009-05-04 01:46:28 PDT
Comment on attachment 29010 [details]
Fix with test case

Actually, I should be more clear:

This patch is fantastic.  You clearly read and understood the instructions on how to submit a patch!   I look forward to reviewing more patches from you soon!

A few nits:
1.  You are missing EMAIL_ADDRESS on your LayoutTest Changelog
2.  We probably don't want these:
Added: svn:eol-style
   + native
if anything we want LF (unix style)
3.  The test would be slightly better if it just output PASS or FAIL instead of the actual dumped chars:
+This test checks to see if setting innerHTML to a single non-breaking space works.
+Original: Â 
+Result:   Â 


Otherwise, again, this is a fantastic patch.  Very easy to review!
Comment 4 Eric Seidel (no email) 2009-05-04 17:22:23 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
        M       LayoutTests/ChangeLog
        A       LayoutTests/fast/innerHTML/innerHTML-nbsp-expected.txt
        A       LayoutTests/fast/innerHTML/innerHTML-nbsp.xhtml
        M       WebCore/ChangeLog
        M       WebCore/dom/XMLTokenizerLibxml2.cpp
Committed r43195

I modified the test case slightly when landing so that it says PASS/FAIL:
http://trac.webkit.org/changeset/43195