<?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>266866</bug_id>
          
          <creation_ts>2023-12-24 09:48:30 -0800</creation_ts>
          <short_desc>Dash character in character range breaks &lt;input&gt; pattern regex</short_desc>
          <delta_ts>2023-12-25 07:27:52 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Forms</component>
          <version>Safari 17</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 14</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=183361</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ian Timothy">webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>akeerthi</cc>
    
    <cc>annevk</cc>
    
    <cc>cdumez</cc>
    
    <cc>karlcow</cc>
    
    <cc>msaboff</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2001822</commentid>
    <comment_count>0</comment_count>
    <who name="Ian Timothy">webkit</who>
    <bug_when>2023-12-24 09:48:30 -0800</bug_when>
    <thetext>OVERVIEW

When the regex of a &lt;input&gt; pattern contains a character range with a actual dash character (not a range operator), the validation for the form element is always true. Dash characters recognized as range operators are not an issue (like: [0-9]), only dash characters recognized as an actual character in a set (like: [0-9-]).

This is a regression because it works as expected on older versions.

Is similar to, if not same as:
https://github.com/GoogleChrome/chromium-dashboard/issues/3106


STEPS TO REPRODUCE

i = document.createElement(&apos;input&apos;);
i.value = &apos;asdf&apos;;

i.pattern = &apos;^[0-9-]{4}$&apos;;
v1 = i.checkValidity();   // returns true instead of false

i.pattern = &apos;^[0-9]{4}$&apos;;
v2 = i.checkValidity();   // returns false as expected

console.log(v1, v2);


ACTUAL RESULTS

Safari 17:
true - false

Safari 15:
false - false


EXPECTED RESULTS

false - false</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001851</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-12-24 19:57:24 -0800</bug_when>
    <thetext>I wonder if it could be because of this change by Anne
https://searchfox.org/wubkat/diff/092303e2abb1e89254f64b301953ac0fbf36c681/Source/WebCore/html/BaseTextInputType.cpp#43</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001852</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-12-24 19:57:34 -0800</bug_when>
    <thetext>&lt;rdar://problem/120106089&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2001911</commentid>
    <comment_count>3</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-25 07:27:52 -0800</bug_when>
    <thetext>Hey Ian, thank you for reporting this. This is an intentional change in behavior: see bug 251675.

You can fix this by escaping - as \\-, although if you set it from script you might need even more backslashes. I suspect \\\\-.

As such closing this as INVALID.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>