Bug 101254 - extractMIMETypeFromMediaType() should process argument string characters using native bitness
Summary: extractMIMETypeFromMediaType() should process argument string characters usin...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-05 13:54 PST by Michael Saboff
Modified: 2013-01-04 00:51 PST (History)
1 user (show)

See Also:


Attachments
Patch (2.33 KB, patch)
2012-11-05 14:04 PST, Michael Saboff
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2012-11-05 13:54:58 PST
extractMIMETypeFromMediaType() creates a StringBuilder using UChars which could result in a 16 bit result from an 8 bit argument.
Comment 1 Michael Saboff 2012-11-05 14:04:13 PST
Created attachment 172400 [details]
Patch
Comment 2 Darin Adler 2012-11-06 09:39:08 PST
Comment on attachment 172400 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=172400&action=review

What is the point of this change? Does it improve performance? Does it cause the function to create 8-bit strings instead of 16-bit strings? If so, how?

> Source/WebCore/ChangeLog:3
> +        extractMIMETypeFromMediaType() should process argument string characters using native bitness

Why?
Comment 3 Darin Adler 2012-11-06 09:39:32 PST
(In reply to comment #0)
> extractMIMETypeFromMediaType() creates a StringBuilder using UChars which could result in a 16 bit result from an 8 bit argument.

Why doesn’t StringBuilder just handle this correctly? I think this should be fixed in StringBuilder, not here.
Comment 4 Michael Saboff 2012-11-06 13:24:06 PST
(In reply to comment #2)
> (From update of attachment 172400 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=172400&action=review
> 
> What is the point of this change? Does it improve performance? Does it cause the function to create 8-bit strings instead of 16-bit strings? If so, how?

Sorry, I should have provided more detail. This code creates 16 bit strings in all cases due to the way StringBuilder works.

> > Source/WebCore/ChangeLog:3
> > +        extractMIMETypeFromMediaType() should process argument string characters using native bitness
> 
> Why?

To avoid making 16 bit strings.

(In reply to comment #3)
> (In reply to comment #0)
> > extractMIMETypeFromMediaType() creates a StringBuilder using UChars which could result in a 16 bit result from an 8 bit argument.
> 
> Why doesn’t StringBuilder just handle this correctly? I think this should be fixed in StringBuilder, not here.

When appending a UChar to a StringBuilder, the StringBuilder becomes "16 bit".  I will look into changing StringBuilder instead of this code, including performance implications.
Comment 5 Michael Saboff 2012-11-07 15:24:33 PST
The bug is no longer valid with change r133726: <http://trac.webkit.org/changeset/133726> from https://bugs.webkit.org/show_bug.cgi?id=101421.
Comment 6 Eric Seidel (no email) 2013-01-04 00:51:40 PST
Comment on attachment 172400 [details]
Patch

Cleared review? from attachment 172400 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).