<?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>229490</bug_id>
          
          <creation_ts>2021-08-25 02:03:58 -0700</creation_ts>
          <short_desc>Invalid URL are treated as valid in navigator.canShare()</short_desc>
          <delta_ts>2021-08-25 23:38:06 -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>New Bugs</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcos Caceres">marcos</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>hi</cc>
    
    <cc>thorton</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1787116</commentid>
    <comment_count>0</comment_count>
    <who name="Marcos Caceres">marcos</who>
    <bug_when>2021-08-25 02:03:58 -0700</bug_when>
    <thetext>In Web Share&apos;s navigator.canShare() method, when passed:

  navigator.canShare({ url: &quot;http://a.b:65536&quot; })

WebKit returns true via URL::isValid(). However, the port is invalid.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1787185</commentid>
    <comment_count>1</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2021-08-25 09:30:25 -0700</bug_when>
    <thetext>navigator.canShare({ url: &quot;http://a.b:65536&quot; })
&gt; false
(not supported in Chrome and Firefox)

new URL(&quot;http://a.b:65536&quot;)
&gt; TypeError
new URL(&quot;http://a.b:65536&quot;)
&gt; URL {href: &quot;http://a.b.65535/&quot;, ...}
(Same as Chrome and Firefox.)

C++
auto url = URL(URL(), &quot;http://a.b:65536&quot;);
WTFLogAlways(&quot;valid? %d&quot;, url.isValid());
&gt; valid? 0

Maybe you&apos;re using WebKit that is several years old, or maybe you&apos;re looking at the wrong thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1787468</commentid>
    <comment_count>2</comment_count>
    <who name="Marcos Caceres">marcos</who>
    <bug_when>2021-08-25 22:11:23 -0700</bug_when>
    <thetext>Sorry, yes. Seems I misread which test was failing. 

It was one to do with data: URLs rather:
https://wpt.fyi/results/web-share/share-url-invalid.https.html?label=experimental&amp;label=master&amp;aligned

I&apos;ll follow up in a different bug for that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1787475</commentid>
    <comment_count>3</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2021-08-25 22:57:32 -0700</bug_when>
    <thetext>I think the relevant sentence in the spec is this:
&quot;If |url| is a URL the user agent deems potentially hostile (e.g., &quot;file:&quot;) or wouldn&apos;t make sense to outside the scope of the document (e.g., &quot;blob:&quot;), return false.&quot;
from https://w3c.github.io/web-share/

I&apos;m wondering why Edge and the web platform tests think that include data URLs.  They make sense outside the scope of the document and it&apos;s a judgement call as to whether the user agent deems them potentially hostile.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1787480</commentid>
    <comment_count>4</comment_count>
    <who name="Marcos Caceres">marcos</who>
    <bug_when>2021-08-25 23:38:06 -0700</bug_when>
    <thetext>(In reply to Alex Christensen from comment #3)
&gt; I think the relevant sentence in the spec is this:
&gt; &quot;If |url| is a URL the user agent deems potentially hostile (e.g., &quot;file:&quot;)
&gt; or wouldn&apos;t make sense to outside the scope of the document (e.g., &quot;blob:&quot;),
&gt; return false.&quot;
&gt; from https://w3c.github.io/web-share/

Yes, I added that a few days ago - but it&apos;s a bit of a stop-gap for the reason you mention: 

&gt; I&apos;m wondering why Edge and the web platform tests think that include data
&gt; URLs.  They make sense outside the scope of the document and it&apos;s a
&gt; judgement call as to whether the user agent deems them potentially hostile.

I made the following proposal: 
https://github.com/w3c/web-share/issues/178#issuecomment-904241285

&quot;&quot;&quot;
Disallow sharing to &quot;local scheme&quot; (&quot;about&quot;, &quot;blob&quot;, or &quot;data&quot;), file, and &quot;javascript&quot;, and any other scheme the UA doesn&apos;t want to share (e.g., internal &quot;moz-icon:&quot; or whatever).

Allow sharing HTTP(S) scheme and, optionally, any of the &quot;safe-listed schemes&quot;.

That should give us broad coverage, while allowing the UA to retain control over what&apos;s actually shared, while excluding the &quot;bad ones&quot;.
&quot;&quot;&quot;

&quot;safe-listed schemes&quot; are:
https://html.spec.whatwg.org/#safelisted-scheme

That&apos;s basically what I implemented in Gecko.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>