⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280957 in webkit


Ignore:
Timestamp:
Aug 11, 2021, 9:35:22 PM (5 years ago)
Author:
Peng Liu
Message:

Function _os_feature_enabled_impl() expects compile-time static strings as arguments
https://bugs.webkit.org/show_bug.cgi?id=229017
<rdar://81813732>

Reviewed by Tim Horton.

There are multiple issues in the current implementation of isFeatureFlagEnabled().

  1. _os_feature_enabled_impl() expects compile-time static strings as arguments.

So we should not use String here.

  1. As Simon Fraser pointed out, String::characters8() is not null terminated.

Source/WebKit:

  • Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:

(WebKit::isFeatureFlagEnabled):

  • Shared/WebPreferencesDefaultValues.cpp:

(WebKit::isFeatureFlagEnabled):

  • Shared/WebPreferencesDefaultValues.h:

Source/WebKitLegacy/mac:

  • WebView/WebPreferencesDefaultValues.h:
  • WebView/WebPreferencesDefaultValues.mm:

(WebKit::isFeatureFlagEnabled):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r280955 r280957  
     12021-08-11  Peng Liu  <peng.liu6@apple.com>
     2
     3        Function _os_feature_enabled_impl() expects compile-time static strings as arguments
     4        https://bugs.webkit.org/show_bug.cgi?id=229017
     5        <rdar://81813732>
     6
     7        Reviewed by Tim Horton.
     8
     9        There are multiple issues in the current implementation of `isFeatureFlagEnabled()`.
     10        1. `_os_feature_enabled_impl()` expects compile-time static strings as arguments.
     11        So we should not use `String` here.
     12        2. As Simon Fraser pointed out, `String::characters8()` is not null terminated.
     13
     14        * Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:
     15        (WebKit::isFeatureFlagEnabled):
     16        * Shared/WebPreferencesDefaultValues.cpp:
     17        (WebKit::isFeatureFlagEnabled):
     18        * Shared/WebPreferencesDefaultValues.h:
     19
    1202021-08-11  Jean-Yves Avenard  <jya@apple.com>
    221
  • trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm

    r280726 r280957  
    3939
    4040// Because of <rdar://problem/60608008>, WebKit has to parse the feature flags plist file
    41 bool isFeatureFlagEnabled(const String& featureName, bool defaultValue)
     41bool isFeatureFlagEnabled(const char* featureName, bool defaultValue)
    4242{
    4343#if HAVE(SYSTEM_FEATURE_FLAGS)
     
    5050
    5151    if (isSystemWebKit)
    52         return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
     52        return _os_feature_enabled_impl("WebKit", featureName);
    5353
    5454    return defaultValue;
    5555#else
    5656    UNUSED_PARAM(defaultValue);
    57     return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
     57    return _os_feature_enabled_impl("WebKit", featureName);
    5858#endif // PLATFORM(MAC)
    5959
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp

    r280726 r280957  
    4343
    4444#if !PLATFORM(COCOA)
    45 bool isFeatureFlagEnabled(const String&, bool defaultValue)
     45bool isFeatureFlagEnabled(const char*, bool defaultValue)
    4646{
    4747    return defaultValue;
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r280726 r280957  
    3636namespace WebKit {
    3737
    38 bool isFeatureFlagEnabled(const String&, bool defaultValue = false);
     38bool isFeatureFlagEnabled(const char*, bool defaultValue = false);
    3939
    4040#if PLATFORM(IOS_FAMILY)
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r280884 r280957  
     12021-08-11  Peng Liu  <peng.liu6@apple.com>
     2
     3        Function _os_feature_enabled_impl() expects compile-time static strings as arguments
     4        https://bugs.webkit.org/show_bug.cgi?id=229017
     5        <rdar://81813732>
     6
     7        Reviewed by Tim Horton.
     8
     9        There are multiple issues in the current implementation of `isFeatureFlagEnabled()`.
     10        1. `_os_feature_enabled_impl()` expects compile-time static strings as arguments.
     11        So we should not use `String` here.
     12        2. As Simon Fraser pointed out, `String::characters8()` is not null terminated.
     13
     14        * WebView/WebPreferencesDefaultValues.h:
     15        * WebView/WebPreferencesDefaultValues.mm:
     16        (WebKit::isFeatureFlagEnabled):
     17
    1182021-08-10  Peng Liu  <peng.liu6@apple.com>
    219
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h

    r280726 r280957  
    3737
    3838#if PLATFORM(COCOA)
    39 bool isFeatureFlagEnabled(const String&, bool defaultValue = false);
     39bool isFeatureFlagEnabled(const char*, bool defaultValue = false);
    4040#endif
    4141
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm

    r280884 r280957  
    4646
    4747// Because of <rdar://problem/60608008>, WebKit has to parse the feature flags plist file
    48 bool isFeatureFlagEnabled(const String& featureName, bool defaultValue)
     48bool isFeatureFlagEnabled(const char* featureName, bool defaultValue)
    4949{
    5050#if HAVE(SYSTEM_FEATURE_FLAGS)
     
    5454#if PLATFORM(COCOA)
    5555    UNUSED_PARAM(defaultValue);
    56     return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
     56    return _os_feature_enabled_impl("WebKit", featureName);
    5757#endif // PLATFORM(MAC)
    5858
Note: See TracChangeset for help on using the changeset viewer.