RESOLVED FIXED Bug 101003
RegExp.prototype.toString Should Produce an 8 bit JSString if possible.
https://bugs.webkit.org/show_bug.cgi?id=101003
Summary RegExp.prototype.toString Should Produce an 8 bit JSString if possible.
Michael Saboff
Reported 2012-11-01 18:10:38 PDT
regExpObjectSource() in RegExpObject.cpp uses a StringBuilder appending UChar characters of the source regular expression when creating the string to return via RegExp.prototype.toString. This will always create a 16 bit string. The code should be changed to create an 8 bit string where possible.
Attachments
Patch (4.24 KB, patch)
2012-11-01 18:15 PDT, Michael Saboff
darin: review-
webkit-ews: commit-queue-
Factored out the line terminator escape logic to fix qt builds (4.92 KB, patch)
2012-11-02 11:44 PDT, Michael Saboff
no flags
Michael Saboff
Comment 1 2012-11-01 18:15:34 PDT
Early Warning System Bot
Comment 2 2012-11-01 18:21:38 PDT
Early Warning System Bot
Comment 3 2012-11-01 18:21:42 PDT
Darin Adler
Comment 4 2012-11-02 10:52:32 PDT
Comment on attachment 171964 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=171964&action=review > Source/JavaScriptCore/runtime/RegExpObject.cpp:258 > + else if (sizeof(CharacterType) > 1) { > + if (ch == 0x2028) > + result.appendLiteral("u2028"); > + else > + result.appendLiteral("u2029"); > + } I don’t think this technique is going to work portably; we’ll get warnings on some compilers. I think we need a separate inline function for this that we overload for the 8-bit and 16-bit character types. Patch otherwise looks fine.
Michael Saboff
Comment 5 2012-11-02 11:44:23 PDT
Created attachment 172096 [details] Factored out the line terminator escape logic to fix qt builds (In reply to comment #4) > (From update of attachment 171964 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=171964&action=review > > > Source/JavaScriptCore/runtime/RegExpObject.cpp:258 > > + else if (sizeof(CharacterType) > 1) { > > + if (ch == 0x2028) > > + result.appendLiteral("u2028"); > > + else > > + result.appendLiteral("u2029"); > > + } > > I don’t think this technique is going to work portably; we’ll get warnings on some compilers. I think we need a separate inline function for this that we overload for the 8-bit and 16-bit character types. I saw this last night as it broke the qt builds. I factored out as suggested. > Patch otherwise looks fine.
Geoffrey Garen
Comment 6 2012-11-02 12:53:56 PDT
Comment on attachment 172096 [details] Factored out the line terminator escape logic to fix qt builds r=me
WebKit Review Bot
Comment 7 2012-11-02 13:21:12 PDT
Comment on attachment 172096 [details] Factored out the line terminator escape logic to fix qt builds Clearing flags on attachment: 172096 Committed r133333: <http://trac.webkit.org/changeset/133333>
WebKit Review Bot
Comment 8 2012-11-02 13:21:18 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 9 2012-11-02 16:05:20 PDT
Comment on attachment 172096 [details] Factored out the line terminator escape logic to fix qt builds View in context: https://bugs.webkit.org/attachment.cgi?id=172096&action=review > Source/JavaScriptCore/runtime/RegExpObject.cpp:182 > +template <typename CharacterType> > +static inline void appendLineTerminatorEscape(StringBuilder&, CharacterType); I suggest we just use function overloading instead of templates for these two functions. Should be a simple change: Just remove all the template stuff and put "static" before "inline".
Note You need to log in before you can comment on or make changes to this bug.