<?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>238475</bug_id>
          
          <creation_ts>2022-03-28 16:01:01 -0700</creation_ts>
          <short_desc>UTF-8 handling in MediaFragmentURIParser::parseFragments() seems wrong</short_desc>
          <delta_ts>2024-01-14 16:59:31 -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>Media</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=238408</see_also>
          <bug_file_loc>https://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#processing-name-value-components</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>annevk</cc>
    
    <cc>darin</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>jer.noble</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1855819</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-03-28 16:01:01 -0700</bug_when>
    <thetext>UTF-8 handling in MediaFragmentURIParser::parseFragments() seems wrong:

```
        //  b. Convert name and value to Unicode strings by interpreting them as UTF-8. If either
        //     name or value are not valid UTF-8 strings, then remove the name-value pair from the list.
        bool validUTF8 = false;
        if (!name.isEmpty() &amp;&amp; !value.isEmpty()) {
            name = String { name.utf8(StrictConversion).data() };
            validUTF8 = !name.isEmpty();

            if (validUTF8) {
                value = String { value.utf8(StrictConversion).data() };
                validUTF8 = !value.isEmpty();
            }
        }
```

Note that `String { }` parses the input string as latin1, not UTF-8. So we&apos;re converting to UTF-8 and then back as latin1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1855828</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-03-28 16:15:43 -0700</bug_when>
    <thetext>imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/media_fragment_seek.html seems to be this only WPT test we have that exercises this logic, but doesn&apos;t actually seem to cover UTF-8 cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1855830</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2022-03-28 16:23:55 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #1)
&gt; imported/w3c/web-platform-tests/html/semantics/embedded-content/media-
&gt; elements/media_fragment_seek.html seems to be this only WPT test we have
&gt; that exercises this logic, but doesn&apos;t actually seem to cover UTF-8 cases.

Looks like there are quite a few related tests in media/media-fragments though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1858127</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-04-04 16:01:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/91266173&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>