w3c / web-share-target

Web API proposal for receiving shared data
https://w3c.github.io/web-share-target/
Other
191 stars 20 forks source link

Path escape if template parameter in path segment #30

Closed mgiuca closed 6 years ago

mgiuca commented 6 years ago

Consider a manifest with:

"share_target": {
  "url_template": "/foo/{text}"
}

If the third-party app supplies text "..", it would allow the sharer to path-escape and direct the user to URLs that the share target never intended.

It's not clear how to resolve this; escaping '.' to "%2e" doesn't help because the URL Standard explicitly says that "%2e%2e" also means parent directory.

The easiest solution is to simply prevent placeholders from appearing before the '?' (so they have to be in the query or fragment). This is a bit restrictive but may be the only reliable method. Perhaps a more targeted solution is to say that it's illegal to have a placeholder in a path segment by itself, so you could have "/foo-{text}" but not "/{text}".

Related to #25, because if we banned placeholders in the path, we could reliably resolve the URL template at parse time.