Bug 134524 - [Cocoa] Ensure that the WebKit bundle version in the user agent string continues to match the current format
Summary: [Cocoa] Ensure that the WebKit bundle version in the user agent string contin...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Rowe (bdash)
URL:
Keywords:
Depends on: 134521 134522
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-01 16:48 PDT by Mark Rowe (bdash)
Modified: 2014-07-02 16:04 PDT (History)
0 users

See Also:


Attachments
Patch (5.75 KB, patch)
2014-07-01 16:50 PDT, Mark Rowe (bdash)
no flags Details | Formatted Diff | Diff
Patch (5.53 KB, patch)
2014-07-02 11:37 PDT, Mark Rowe (bdash)
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Rowe (bdash) 2014-07-01 16:48:19 PDT
The WebKit version portion of the user agent string has historically had at most three components. There's no guarantee that the WebKit framework's bundle version will be limited in this fashion. We should ensure that the version inserted in to the user agent string continues to match the historical format.

<rdar://problem/17447771>
Comment 1 Mark Rowe (bdash) 2014-07-01 16:50:48 PDT
Created attachment 234217 [details]
Patch
Comment 2 Mark Rowe (bdash) 2014-07-02 11:37:12 PDT
Created attachment 234271 [details]
Patch
Comment 3 Simon Fraser (smfr) 2014-07-02 14:53:13 PDT
Comment on attachment 234271 [details]
Patch

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

> Source/WebCore/page/cocoa/UserAgent.mm:69
> +    // We include at most three components of the bundle version in the user agent string.
> +    NSString *bundleVersion = userVisibleWebKitBundleVersionFromFullVersion(fullWebKitVersion);
> +    NSScanner *scanner = [NSScanner scannerWithString:bundleVersion];
> +    NSInteger periodCount = 0;
> +    while (true) {
> +        if (![scanner scanUpToString:@"." intoString:nullptr] || scanner.isAtEnd)
> +            return bundleVersion;
> +
> +        if (++periodCount == 3)
> +            return [bundleVersion substringToIndex:scanner.scanLocation];
> +
> +        ++scanner.scanLocation;
> +    }
> +
> +    ASSERT_NOT_REACHED();

Can we do this in C++?
Comment 4 Mark Rowe (bdash) 2014-07-02 14:57:28 PDT
(In reply to comment #3)
> (From update of attachment 234271 [details])
> Can we do this in C++?

It seemed preferable for the code to match our other internal implementation rather than writing it twice.
Comment 5 Mark Rowe (bdash) 2014-07-02 16:04:29 PDT
Landed in r170735.
<https://trac.webkit.org/r170735>