<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>265420</bug_id>
          
          <creation_ts>2023-11-27 19:58:29 -0800</creation_ts>
          <short_desc>Parsing stop-color with invalid values (i.e., Numbers &quot;1234&quot;)</short_desc>
          <delta_ts>2025-09-21 08:22:12 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=293616</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar, WPTImpact</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ahmad Saleem">ahmad.saleem792</reporter>
          <assigned_to name="Rob Buis">rbuis</assigned_to>
          <cc>kiet.ho</cc>
    
    <cc>ntim</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zakr</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1995144</commentid>
    <comment_count>0</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-11-27 19:58:29 -0800</bug_when>
    <thetext>Hi Team,

While going through Browser Specific Failures, I came across one lone failing tests in SVG, so I thought to raise bugs since I couldn&apos;t find any other.

WPT Test Case: https://wpt.fyi/results/svg/pservers/parsing/stop-color-invalid.svg?label=master&amp;label=experimental&amp;aligned=&amp;q=safari%3Afail

WPT Test Case Live Link: http://wpt.live/svg/pservers/parsing/stop-color-invalid.svg

Just wanted to raise so we can fix it.

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996971</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-12-04 19:59:13 -0800</bug_when>
    <thetext>&lt;rdar://problem/119166640&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2096959</commentid>
    <comment_count>2</comment_count>
    <who name="Kiet Ho">kiet.ho</who>
    <bug_when>2025-02-21 17:23:41 -0800</bug_when>
    <thetext>Drive-by comment as I happen to stumble upon this.

The test case sets &quot;stop-color&quot; to &quot;123&quot; and expects it to fail, but got &quot;rgb(17, 34, 51)&quot; instead.
tldr: we&apos;re interpreting this as a 3 digit hex string and interpret it as &quot;#112233&quot; or &quot;rgb(17, 34, 51)&quot;

This value is parsed by the fast path CSS parser (CSSParserFastPaths::maybeParseValue), which calls the fast path color parser routine (parseColor). It then parses it as a numeric color (parseNumericColor). This SVG document is parsed in HTMLQuirksMode, so not strict, and this code runs:

    if (!strict &amp;&amp; (characters.size() == 3 || characters.size() == 6)) {
        if (auto hexColor = parseHexColorInternal(characters))
            return *hexColor;
    }

which parses &quot;123&quot;. I&apos;d imagine if we&apos;re not doing quirks parsing, then &quot;123&quot; would not be accepted.

Stack trace from the beginning of the JS call, if it helps.
  * frame #0: 0x0000000304800d5c WebCore`WebCore::finishParsingHexColor(value=291, length=3) at CSSParserFastPaths.cpp:468:16
    frame #1: 0x00000003047dc7b0 WebCore`std::__1::optional&lt;WebCore::BoundedGammaEncoded&lt;unsigned char, WebCore::SRGBADescriptor&gt;&gt; WebCore::parseHexColorInternal&lt;unsigned char&gt;(characters=size=3) at CSSParserFastPaths.cpp:503:12
    frame #2: 0x00000003047f4c90 WebCore`std::__1::optional&lt;WebCore::BoundedGammaEncoded&lt;unsigned char, WebCore::SRGBADescriptor&gt;&gt; WebCore::parseNumericColor&lt;unsigned char&gt;(characters=size=3, strict=false) at CSSParserFastPaths.cpp:610:29
    frame #3: 0x00000003047f4b10 WebCore`WebCore::parseNumericColor(string={ length = 3, contents = &apos;123&apos; }, context=0x000000016b359968) at CSSParserFastPaths.cpp:669:16
    frame #4: 0x00000003047dd320 WebCore`WebCore::parseColor(string={ length = 3, contents = &apos;123&apos; }, context=0x000000016b359968) at CSSParserFastPaths.cpp:682:22
    frame #5: 0x00000003047da084 WebCore`WebCore::CSSParserFastPaths::maybeParseValue(propertyID=CSSPropertyStopColor, string={ length = 3, contents = &apos;123&apos; }, context=0x000000016b359968) at CSSParserFastPaths.cpp:1079:16
    frame #6: 0x00000003047da274 WebCore`WebCore::CSSParser::parseValue(declaration=0x0000000118395800, propertyID=CSSPropertyStopColor, string={ length = 3, contents = &apos;123&apos; }, important=No, context=0x000000016b359968) at CSSParser.cpp:131:24
    frame #7: 0x00000003045e5284 WebCore`WebCore::MutableStyleProperties::setProperty(this=0x0000000118395800, propertyID=CSSPropertyStopColor, value={ length = 3, contents = &apos;123&apos; }, parserContext=CSSParserContext @ 0x000000016b359968, important=No, didFailParsing=0x0000000000000000) at MutableStyleProperties.cpp:155:24
    frame #8: 0x00000003045e7ecc WebCore`WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal(this=0x0000000142008bb0, propertyID=CSSPropertyStopColor, value={ length = 3, contents = &apos;123&apos; }, important=No) at PropertySetCSSStyleDeclaration.cpp:230:24
    frame #9: 0x00000003044ba5f8 WebCore`WebCore::CSSStyleDeclaration::setPropertyValueForDashedIDLAttribute(this=0x0000000142008bb0, attribute={ length = 10, contents = &apos;stop-color&apos; }, value={ length = 3, contents = &apos;123&apos; }) at CSSStyleDeclaration.cpp:277:12
    frame #10: 0x0000000300d77468 WebCore`WebCore::setJSCSSStyleDeclaration_propertyValueForDashedIDLAttributeSetter(this=0x000000016b359b70)::&apos;lambda&apos;()::operator()() const at JSCSSStyleDeclaration.cpp:3024:21
    frame #11: 0x0000000300d77398 WebCore`void WebCore::invokeFunctorPropagatingExceptionIfNecessary&lt;WebCore::setJSCSSStyleDeclaration_propertyValueForDashedIDLAttributeSetter(JSC::JSGlobalObject&amp;, WebCore::JSCSSStyleDeclaration&amp;, JSC::JSValue, JSC::PropertyName)::&apos;lambda&apos;()&gt;(lexicalGlobalObject=0x00000001191c8088, throwScope=0x000000016b359c28, functor=0x000000016b359b70) at JSDOMExceptionHandling.h:97:23
    frame #12: 0x0000000300d77324 WebCore`WebCore::setJSCSSStyleDeclaration_propertyValueForDashedIDLAttributeSetter(lexicalGlobalObject=0x00000001191c8088, thisObject=0x00000001185ce308, value=JSValue @ 0x000000016b359c80, propertyName=PropertyName @ 0x000000016b359c78) at JSCSSStyleDeclaration.cpp:3023:5
    frame #13: 0x0000000300ca3bb0 WebCore`bool WebCore::IDLAttribute&lt;WebCore::JSCSSStyleDeclaration&gt;::setPassingPropertyName&lt;&amp;WebCore::setJSCSSStyleDeclaration_propertyValueForDashedIDLAttributeSetter(JSC::JSGlobalObject&amp;, WebCore::JSCSSStyleDeclaration&amp;, JSC::JSValue, JSC::PropertyName), (WebCore::CastedThisErrorBehavior)0&gt;(lexicalGlobalObject=0x00000001191c8088, thisValue=4703707912, encodedValue=4715458448, attributeName=PropertyName @ 0x000000016b359d80) at JSDOMAttribute.h:72:9
    frame #14: 0x0000000300ca3a84 WebCore`WebCore::setJSCSSStyleDeclaration_propertyValueForDashedIDLAttribute(lexicalGlobalObject=0x00000001191c8088, thisValue=4703707912, encodedValue=4715458448, attributeName=PropertyName @ 0x000000016b359dc8) at JSCSSStyleDeclaration.cpp:3031:12
    frame #15: 0x0000000133386208 JavaScriptCore`WTF::FunctionPtr&lt;(WTF::PtrTag)28258, bool (JSC::JSGlobalObject*, long long, long long, JSC::PropertyName), (WTF::FunctionAttributes)1&gt;::operator()(this=0x000000016b359ff0, in=0x00000001191c8088, in=4703707912, in=4715458448, in=PropertyName @ 0x000000016b359e18) const at FunctionPtr.h:114:16
    frame #16: 0x00000001334a5e00 JavaScriptCore`JSC::JSObject::putInlineSlow(this=0x00000001185ce308, globalObject=0x00000001191c8088, propertyName=PropertyName @ 0x000000016b35a0c0, value=JSValue @ 0x000000016b35a0b8, slot=0x000000016b35a590) at JSObject.cpp:867:17
    frame #17: 0x00000001329f8944 JavaScriptCore`JSC::JSObject::putInlineForJSObject(cell=0x00000001185ce308, globalObject=0x00000001191c8088, propertyName=PropertyName @ 0x000000016b35a1f0, value=JSValue @ 0x000000016b35a1e8, slot=0x000000016b35a590) at JSObjectInlines.h:317:28
    frame #18: 0x00000001334a0f9c JavaScriptCore`JSC::JSObject::put(cell=0x00000001185ce308, globalObject=0x00000001191c8088, propertyName=PropertyName @ 0x000000016b35a258, value=JSValue @ 0x000000016b35a250, slot=0x000000016b35a590) at JSObject.cpp:805:12
    frame #19: 0x0000000300ca1200 WebCore`WebCore::JSCSSStyleDeclaration::put(cell=0x00000001185ce308, lexicalGlobalObject=0x00000001191c8088, propertyName=PropertyName @ 0x000000016b35a460, value=JSValue @ 0x000000016b35a458, putPropertySlot=0x000000016b35a590) at JSCSSStyleDeclaration.cpp:2841:9
    frame #20: 0x000000013292e4d8 JavaScriptCore`JSC::JSValue::put(this=0x000000016b35a658, globalObject=0x00000001191c8088, propertyName=PropertyName @ 0x000000016b35a4f0, value=JSValue @ 0x000000016b35a4e8, slot=0x000000016b35a590) at JSCJSValueInlines.h:1184:12
    frame #21: 0x0000000133062308 JavaScriptCore`llint_slow_path_put_by_val(callFrame=0x000000016b35a7d0, pc=0x0000000118187c09) at LLIntSlowPaths.cpp:1368:15
    frame #22: 0x0000000133f82330 JavaScriptCore`jsc_llint_begin + 86320</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2120979</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-05-31 20:56:52 -0700</bug_when>
    <thetext>Thanks @Kiet for pointer, I just got some time to look back into it and this fixes the test case:

if ((isQuirksModeBehavior(context.mode) &amp;&amp; isUnitlessValueParsingForcedForMode(context.mode)) &amp;&amp; (characters.size() == 3 || characters.size() == 6)) {
        if (auto hexColor = parseHexColorInternal(characters))
            return *hexColor;
    }

Can do draft PR to see, if it leads to any other failures or not but at least, this test is fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2121005</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-06-01 11:58:50 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/46192</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2144668</commentid>
    <comment_count>5</comment_count>
    <who name="Rob Buis">rbuis</who>
    <bug_when>2025-09-20 10:48:27 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/51073</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2144706</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-09-21 08:22:09 -0700</bug_when>
    <thetext>Committed 300296@main (dc1800749842): &lt;https://commits.webkit.org/300296@main&gt;

Reviewed commits have been landed. Closing PR #51073 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>