WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
101678
WTFString::utf8() should have a mode of conversion to use replacement character
https://bugs.webkit.org/show_bug.cgi?id=101678
Summary
WTFString::utf8() should have a mode of conversion to use replacement character
Kenichi Ishibashi
Reported
2012-11-08 18:08:44 PST
WebIDL defines a way to convert a DOMString to a sequence of Unicode characters:
http://dev.w3.org/2006/webapi/WebIDL/#dfn-obtain-unicode
This algorithm is needed to fix
https://bugs.webkit.org/show_bug.cgi?id=101569
. In
https://bugs.webkit.org/show_bug.cgi?id=101569#c4
, Alexey suggested me implementing it under WTF. I think changing String::utf8() to take mode argument is a reasonable approach.
Attachments
Patch
(16.33 KB, patch)
2012-11-08 20:16 PST
,
Kenichi Ishibashi
no flags
Details
Formatted Diff
Diff
Patch
(18.71 KB, patch)
2012-11-08 22:19 PST
,
Kenichi Ishibashi
no flags
Details
Formatted Diff
Diff
Patch for landing
(19.05 KB, patch)
2012-11-11 05:27 PST
,
Kenichi Ishibashi
no flags
Details
Formatted Diff
Diff
Patch for landing
(19.05 KB, patch)
2012-11-11 05:31 PST
,
Kenichi Ishibashi
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Kenichi Ishibashi
Comment 1
2012-11-08 20:16:27 PST
Created
attachment 173184
[details]
Patch
Kenichi Ishibashi
Comment 2
2012-11-08 20:17:56 PST
Hi Alexey, Could you take a look (or could you suggest a reviewer)?
WebKit Review Bot
Comment 3
2012-11-08 20:22:53 PST
Attachment 173184
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1 Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:753: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 1 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alexey Proskuryakov
Comment 4
2012-11-08 20:53:28 PST
Comment on
attachment 173184
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=173184&action=review
I haven't looked in detail yet. This approach seems much nicer than adding code to WebSocket.
> Source/WTF/wtf/text/WTFString.cpp:795 > + // Conversion fails when there is an unpaired surrogate.
How did you confirm that this is the only possible reason for failure?
> Source/WTF/wtf/text/WTFString.h:218 > + ReplacementConversion,
This name is not descriptive. When exactly is the replacement character used? Is this actually StrictConversionReplacingUnpairedSurrogatesWithFFFD?
Build Bot
Comment 5
2012-11-08 20:57:18 PST
Comment on
attachment 173184
[details]
Patch
Attachment 173184
[details]
did not pass win-ews (win): Output:
http://queues.webkit.org/results/14775372
Kenichi Ishibashi
Comment 6
2012-11-08 21:46:12 PST
Comment on
attachment 173184
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=173184&action=review
>> Source/WTF/wtf/text/WTFString.cpp:795 >> + // Conversion fails when there is an unpaired surrogate. > > How did you confirm that this is the only possible reason for failure?
I read the comments and implementation of convertUTF16ToUTF8(). All failures except for "targetExhausted" caused by an unpaired surrogate.
>> Source/WTF/wtf/text/WTFString.h:218 >> + ReplacementConversion, > > This name is not descriptive. When exactly is the replacement character used? Is this actually StrictConversionReplacingUnpairedSurrogatesWithFFFD?
Will change.
Kenichi Ishibashi
Comment 7
2012-11-08 21:47:45 PST
(In reply to
comment #5
)
> (From update of
attachment 173184
[details]
) >
Attachment 173184
[details]
did not pass win-ews (win): > Output:
http://queues.webkit.org/results/14775372
15>WebKit.exp : error LNK2001: unresolved external symbol "public: class WTF::CString __thiscall WTF::String::utf8(bool)const " (?utf8@String@WTF@@QBE?AVCString@
2@_N@Z
) It seems that I need to update Source/WebKit2/win/{WebKit2,WebKit2CFLite}.def How can I generate the entry for "CString utf8(ConversionMode = LenientConversion) const;" ?
Kenichi Ishibashi
Comment 8
2012-11-08 22:19:10 PST
Created
attachment 173204
[details]
Patch
WebKit Review Bot
Comment 9
2012-11-08 22:24:23 PST
Attachment 173204
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1 Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:753: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 1 in 15 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alexey Proskuryakov
Comment 10
2012-11-09 09:57:19 PST
Comment on
attachment 173204
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=173204&action=review
I would have structured this code differently, not adding a branch for StrictConversionReplacingUnpairedSurrogatesWithFFFD unless a failure is returned from convertUTF16ToUTF8(). Seems acceptable to leave as is.
> Source/WTF/wtf/text/WTFString.cpp:795 > + // Conversion fails when there is an unpaired surrogate.
Can you add an ASSERT to that effect?
> Source/WTF/wtf/text/WTFString.cpp:799 > + ASSERT((buffer + 3) <= (buffer + bufferVector.size()));
You can use bufferEnd at the right side.
> Source/WTF/wtf/text/WTFString.cpp:809 > + // Only produced from strict conversion.
Can you add an ASSERT to that effect?
>> Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:753 >> + credential.password().utf8(String::StrictConversion).data(), > > Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3]
Style bot is correct, we do not try to align source code like this. Continuation line should be just indented additional 4 spaces.
Kenichi Ishibashi
Comment 11
2012-11-11 05:27:21 PST
Created
attachment 173498
[details]
Patch for landing
Kenichi Ishibashi
Comment 12
2012-11-11 05:28:25 PST
Comment on
attachment 173204
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=173204&action=review
Thank you for review!
>> Source/WTF/wtf/text/WTFString.cpp:795 >> + // Conversion fails when there is an unpaired surrogate. > > Can you add an ASSERT to that effect?
Done.
>> Source/WTF/wtf/text/WTFString.cpp:799 >> + ASSERT((buffer + 3) <= (buffer + bufferVector.size())); > > You can use bufferEnd at the right side.
Done.
>> Source/WTF/wtf/text/WTFString.cpp:809 >> + // Only produced from strict conversion. > > Can you add an ASSERT to that effect?
Done.
>>> Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:753 >>> + credential.password().utf8(String::StrictConversion).data(), >> >> Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] > > Style bot is correct, we do not try to align source code like this. Continuation line should be just indented additional 4 spaces.
Done.
WebKit Review Bot
Comment 13
2012-11-11 05:29:23 PST
Comment on
attachment 173498
[details]
Patch for landing Rejecting
attachment 173498
[details]
from commit-queue. Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 1 ERROR: /mnt/git/webkit-commit-queue/Source/JavaScriptCore/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive). Full output:
http://queues.webkit.org/results/14810071
Kenichi Ishibashi
Comment 14
2012-11-11 05:31:53 PST
Created
attachment 173499
[details]
Patch for landing
WebKit Review Bot
Comment 15
2012-11-11 06:18:18 PST
Comment on
attachment 173499
[details]
Patch for landing Clearing flags on attachment: 173499 Committed
r134173
: <
http://trac.webkit.org/changeset/134173
>
WebKit Review Bot
Comment 16
2012-11-11 06:18:22 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug