Changeset 225562 in webkit


Ignore:
Timestamp:
Dec 5, 2017 5:59:53 PM (6 years ago)
Author:
Brent Fulgham
Message:

Limit user agent versioning to an upper bound
https://bugs.webkit.org/show_bug.cgi?id=180365
<rdar://problem/34550617>

Reviewed by Joseph Pecoraro.

Source/WebCore:

Freeze the version reported as User Agent to OS 10.13.4 (OS 11.3 on iOS) and WebKit 605.1.15
for User Agent purposes.

Test: fast/dom/navigator-userAgent-frozen.html

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

(WebCore::versionPredatesFreeze): Helper function. Returns true for Version 10.13.3 or older.
(WebCore::systemMarketingVersionForUserAgentString):
(WebCore::userAgentBundleVersion):
(WebCore::userVisibleWebKitBundleVersionFromFullVersion): Deleted.
(WebCore::userAgentBundleVersionFromFullVersionString): Deleted.

  • page/ios/UserAgentIOS.mm:

(WebCore::standardUserAgentWithApplicationName): Don't take the WebKit bundle version
as an argument, or pass it to the user agent string generator.

  • page/mac/UserAgentMac.mm:

(WebCore::standardUserAgentWithApplicationName): Ditto.

Source/WebKit:

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::standardUserAgent): Don't pass the WebKit bundle version when
creatin the User Agent string.
(WebKit::webKitBundleVersionString): Deleted.

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::WebPageProxy::standardUserAgent): Ditto.
(WebKit::webKitBundleVersionString): Deleted.

Source/WebKitLegacy/mac:

  • WebView/WebView.mm:

(+[WebView _standardUserAgentWithApplicationName:]): Don't pass the WebKit bundle version when
creating the User Agent string.
(webKitBundleVersionString): Deleted.

LayoutTests:

  • fast/dom/navigator-userAgent-frozen-expected.txt: Added.
  • fast/dom/navigator-userAgent-frozen.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r225561 r225562  
     12017-12-05  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Limit user agent versioning to an upper bound
     4        https://bugs.webkit.org/show_bug.cgi?id=180365
     5        <rdar://problem/34550617>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * fast/dom/navigator-userAgent-frozen-expected.txt: Added.
     10        * fast/dom/navigator-userAgent-frozen.html: Added.
     11
    1122017-12-05  Javier Fernandez  <jfernandez@igalia.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r225555 r225562  
     12017-12-05  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Limit user agent versioning to an upper bound
     4        https://bugs.webkit.org/show_bug.cgi?id=180365
     5        <rdar://problem/34550617>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Freeze the version reported as User Agent to OS 10.13.4 (OS 11.3 on iOS) and WebKit 605.1.15
     10        for User Agent purposes.
     11
     12        Test: fast/dom/navigator-userAgent-frozen.html
     13
     14        * page/cocoa/UserAgent.h:
     15        * page/cocoa/UserAgent.mm:
     16        (WebCore::versionPredatesFreeze): Helper function. Returns true for Version 10.13.3 or older.
     17        (WebCore::systemMarketingVersionForUserAgentString):
     18        (WebCore::userAgentBundleVersion):
     19        (WebCore::userVisibleWebKitBundleVersionFromFullVersion): Deleted.
     20        (WebCore::userAgentBundleVersionFromFullVersionString): Deleted.
     21        * page/ios/UserAgentIOS.mm:
     22        (WebCore::standardUserAgentWithApplicationName): Don't take the WebKit bundle version
     23        as an argument, or pass it to the user agent string generator.
     24        * page/mac/UserAgentMac.mm:
     25        (WebCore::standardUserAgentWithApplicationName): Ditto.
     26
    1272017-12-05  Matt Lewis  <jlewis3@apple.com>
    228
  • trunk/Source/WebCore/page/cocoa/UserAgent.h

    r172849 r225562  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131namespace WebCore {
    3232
    33 WEBCORE_EXPORT String standardUserAgentWithApplicationName(const String& applicationName, const String& webkitVersionString);
     33WEBCORE_EXPORT String standardUserAgentWithApplicationName(const String& applicationName);
    3434
    3535String systemMarketingVersionForUserAgentString();
    36 String userAgentBundleVersionFromFullVersionString(const String&);
     36String userAgentBundleVersion();
    3737
    3838}
  • trunk/Source/WebCore/page/cocoa/UserAgent.mm

    r170735 r225562  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727#import "UserAgent.h"
    2828
    29 #import "SystemVersion.h"
    30 
    3129namespace WebCore {
    3230
     
    3634    // we were concerned about old DHTML libraries interpreting "4." as Netscape 4. That's no longer a concern for us
    3735    // but we're sticking with the underscores for compatibility with the format used by older versions of Safari.
    38     return [systemMarketingVersion() stringByReplacingOccurrencesOfString:@"." withString:@"_"];
     36#if PLATFORM(MAC)
     37#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     38    return ASCIILiteral("10_13_4");
     39#elif __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     40    return ASCIILiteral("10_12_6");
     41#else
     42    return ASCIILiteral("10_11_6");
     43#endif
     44#else
     45    return ASCIILiteral("11_3");
     46#endif
    3947}
    4048
    41 static NSString *userVisibleWebKitBundleVersionFromFullVersion(NSString *fullWebKitVersion)
     49String userAgentBundleVersion()
    4250{
    43     // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
    44     // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
    45     NSRange nonDigitRange = [fullWebKitVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
    46     if (nonDigitRange.location == NSNotFound && fullWebKitVersion.length > 3)
    47         return [fullWebKitVersion substringFromIndex:fullWebKitVersion.length - 3];
    48     if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
    49         return [fullWebKitVersion substringFromIndex:nonDigitRange.location - 3];
    50     return fullWebKitVersion;
    51 }
    52 
    53 String 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();
     51    return ASCIILiteral("605.1.15");
    7052}
    7153
  • trunk/Source/WebCore/page/ios/UserAgentIOS.mm

    r222898 r225562  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7878}
    7979
    80 String standardUserAgentWithApplicationName(const String& applicationName, const String& fullWebKitVersionString)
     80String standardUserAgentWithApplicationName(const String& applicationName)
    8181{
    8282    // Check to see if there is a user agent override for all WebKit clients.
     
    8989
    9090    // FIXME: We should implement this with String and/or StringBuilder instead.
    91     NSString *webKitVersion = userAgentBundleVersionFromFullVersionString(fullWebKitVersionString);
     91    NSString *webKitVersion = userAgentBundleVersion();
    9292    NSString *osMarketingVersionString = systemMarketingVersionForUserAgentString();
    9393    if (applicationName.isEmpty())
  • trunk/Source/WebCore/page/mac/UserAgentMac.mm

    r170735 r225562  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3939#endif
    4040
    41 String standardUserAgentWithApplicationName(const String& applicationName, const String& fullWebKitVersionString)
     41String standardUserAgentWithApplicationName(const String& applicationName)
    4242{
    4343    String osVersion = systemMarketingVersionForUserAgentString();
    44     String webKitVersionString = userAgentBundleVersionFromFullVersionString(fullWebKitVersionString);
     44    String webKitVersionString = userAgentBundleVersion();
    4545
    4646    if (applicationName.isEmpty())
  • trunk/Source/WebKit/ChangeLog

    r225553 r225562  
     12017-12-05  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Limit user agent versioning to an upper bound
     4        https://bugs.webkit.org/show_bug.cgi?id=180365
     5        <rdar://problem/34550617>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * UIProcess/ios/WebPageProxyIOS.mm:
     10        (WebKit::WebPageProxy::standardUserAgent): Don't pass the WebKit bundle version when
     11        creatin the User Agent string.
     12        (WebKit::webKitBundleVersionString): Deleted.
     13        * UIProcess/mac/WebPageProxyMac.mm:
     14        (WebKit::WebPageProxy::standardUserAgent): Ditto.
     15        (WebKit::webKitBundleVersionString): Deleted.
     16
    1172017-12-05  Alex Christensen  <achristensen@webkit.org>
    218
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r224029 r225562  
    11/*
    2  * Copyright (C) 2012-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6969}
    7070
    71 static String webKitBundleVersionString()
    72 {
    73     return [[NSBundle bundleForClass:NSClassFromString(@"WKWebView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    74 }
    75 
    7671String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
    7772{
    78     return standardUserAgentWithApplicationName(applicationNameForUserAgent, webKitBundleVersionString());
     73    return standardUserAgentWithApplicationName(applicationNameForUserAgent);
    7974}
    8075
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r225117 r225562  
    11/*
    2  * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9292}
    9393
    94 static String webKitBundleVersionString()
    95 {
    96     return [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    97 }
    98 
    9994String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
    10095{
    101     return standardUserAgentWithApplicationName(applicationNameForUserAgent, webKitBundleVersionString());
     96    return standardUserAgentWithApplicationName(applicationNameForUserAgent);
    10297}
    10398
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r225559 r225562  
     12017-12-05  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Limit user agent versioning to an upper bound
     4        https://bugs.webkit.org/show_bug.cgi?id=180365
     5        <rdar://problem/34550617>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * WebView/WebView.mm:
     10        (+[WebView _standardUserAgentWithApplicationName:]): Don't pass the WebKit bundle version when
     11        creating the User Agent string.
     12        (webKitBundleVersionString): Deleted.
     13
    1142017-12-05  Andy Estes  <aestes@apple.com>
    215
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r225369 r225562  
    11331133@implementation WebView (WebPrivate)
    11341134
    1135 static String webKitBundleVersionString()
    1136 {
    1137     return [[NSBundle bundleForClass:[WebView class]] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    1138 }
    1139 
    11401135+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName
    11411136{
    1142     return standardUserAgentWithApplicationName(applicationName, webKitBundleVersionString());
     1137    return standardUserAgentWithApplicationName(applicationName);
    11431138}
    11441139
Note: See TracChangeset for help on using the changeset viewer.