Changeset 170735 in webkit


Ignore:
Timestamp:
Jul 2, 2014 4:02:45 PM (10 years ago)
Author:
mrowe@apple.com
Message:

Ensure that the WebKit bundle version in the user agent string continues to match the current format.
<https://webkit.org/b/134524> / <rdar://problem/17447771>

Reviewed by Simon Fraser.

  • page/cocoa/UserAgent.h:
  • page/cocoa/UserAgent.mm:

(WebCore::userVisibleWebKitBundleVersionFromFullVersion): Updated to take an NSString now that it's internal
to the file.
(WebCore::userAgentBundleVersionFromFullVersionString): Limit the bundle version included in the user agent
string to three components.

  • page/ios/UserAgentIOS.mm:

(WebCore::standardUserAgentWithApplicationName): Update to call userAgentBundleVersionFromFullVersionString.

  • page/mac/UserAgentMac.mm:

(WebCore::standardUserAgentWithApplicationName): Ditto.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r170734 r170735  
     12014-07-01  Mark Rowe  <mrowe@apple.com>
     2
     3        Ensure that the WebKit bundle version in the user agent string continues to match the current format.
     4        <https://webkit.org/b/134524> / <rdar://problem/17447771>
     5
     6        Reviewed by Simon Fraser.
     7
     8        * page/cocoa/UserAgent.h:
     9        * page/cocoa/UserAgent.mm:
     10        (WebCore::userVisibleWebKitBundleVersionFromFullVersion): Updated to take an NSString now that it's internal
     11        to the file.
     12        (WebCore::userAgentBundleVersionFromFullVersionString): Limit the bundle version included in the user agent
     13        string to three components.
     14        * page/ios/UserAgentIOS.mm:
     15        (WebCore::standardUserAgentWithApplicationName): Update to call userAgentBundleVersionFromFullVersionString.
     16        * page/mac/UserAgentMac.mm:
     17        (WebCore::standardUserAgentWithApplicationName): Ditto.
     18
    1192014-07-01  Mark Rowe  <mrowe@apple.com>
    220
  • trunk/Source/WebCore/page/cocoa/UserAgent.h

    r170734 r170735  
    3434
    3535String systemMarketingVersionForUserAgentString();
    36 String userVisibleWebKitBundleVersionFromFullVersion(const String&);
     36String userAgentBundleVersionFromFullVersionString(const String&);
    3737
    3838}
  • trunk/Source/WebCore/page/cocoa/UserAgent.mm

    r170734 r170735  
    3939}
    4040
    41 String userVisibleWebKitBundleVersionFromFullVersion(const String& fullWebKitVersionString)
     41static NSString *userVisibleWebKitBundleVersionFromFullVersion(NSString *fullWebKitVersion)
    4242{
    43     NSString *fullWebKitVersion = fullWebKitVersionString;
    44 
    4543    // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
    4644    // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
     
    5351}
    5452
     53String userAgentBundleVersionFromFullVersionString(const String& fullWebKitVersion)
     54{
     55    // We include at most three components of the bundle version in the user agent string.
     56    NSString *bundleVersion = userVisibleWebKitBundleVersionFromFullVersion(fullWebKitVersion);
     57    NSScanner *scanner = [NSScanner scannerWithString:bundleVersion];
     58    NSInteger periodCount = 0;
     59    while (true) {
     60        if (![scanner scanUpToString:@"." intoString:nullptr] || scanner.isAtEnd)
     61            return bundleVersion;
     62
     63        if (++periodCount == 3)
     64            return [bundleVersion substringToIndex:scanner.scanLocation];
     65
     66        ++scanner.scanLocation;
     67    }
     68
     69    ASSERT_NOT_REACHED();
     70}
     71
    5572} // namespace WebCore
  • trunk/Source/WebCore/page/ios/UserAgentIOS.mm

    r170734 r170735  
    4545    }
    4646
    47     NSString *webKitVersion = userVisibleWebKitBundleVersionFromFullVersion(fullWebKitVersionString);
     47    NSString *webKitVersion = userAgentBundleVersionFromFullVersionString(fullWebKitVersionString);
    4848    CFStringRef deviceName = wkGetDeviceName();
    4949    CFStringRef osNameForUserAgent = wkGetOSNameForUserAgent();
  • trunk/Source/WebCore/page/mac/UserAgentMac.mm

    r170734 r170735  
    4242{
    4343    String osVersion = systemMarketingVersionForUserAgentString();
    44     String webKitVersionString = userVisibleWebKitBundleVersionFromFullVersion(fullWebKitVersionString);
     44    String webKitVersionString = userAgentBundleVersionFromFullVersionString(fullWebKitVersionString);
    4545
    4646    if (applicationName.isEmpty())
Note: See TracChangeset for help on using the changeset viewer.