Skip to content

Specify validation of share_target at manifest load time. #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

mgiuca
Copy link
Collaborator

@mgiuca mgiuca commented Nov 27, 2017

Closes #25


Preview | Diff

@mgiuca mgiuca force-pushed the errors-at-parse-time branch from 7281ccf to e284031 Compare November 27, 2017 05:37
</li>
<li>Let <var>test relative URL</var> be the result of running the <a>
replace placeholders</a> algorithm on <var>URL template</var> with
<code>{}</code> (the empty <a data-cite=
Copy link
Collaborator Author

@mgiuca mgiuca Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't quite correct to substitute the empty dictionary to find out whether a URL template will expand to within scope.

Consider a manifest:

{
    "scope": "/foo",
    "share_target": {
        "url_template": "/fo{text}o"
    }
}

The manifest will parse correctly, because expanding url_template with text = "" is "/foo". But if given any non-empty text, it will expand to be out of scope.

There are a few solutions to this:

  1. Fix the scope checking algorithm (this) to somehow make sure it fails if any substitution would move it outside the scope.
  2. Prevent template parameters from appearing in the path part (i.e., before the query) entirely.

@@ -377,6 +458,12 @@ <h3>
empty <var>features</var>.
</li>
</ol>
<p class="note">
This algorithm never aborts if <var>manifest</var> has had the
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't strictly true, due to the above problem.

@pkotwicz
Copy link

pkotwicz commented Dec 6, 2017

I think this scenario might be problematic:

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

If we do validation at parse time, it seems like |url_template| would fall under the scope. However, if a user wants to share ".." the URL will fall out of scope

@mgiuca
Copy link
Collaborator Author

mgiuca commented Dec 6, 2017

That's a good point. (Note that other problematic characters such as '/' and '?' are not an issue because we encode the placeholders with the userinfo percent encode set, but '.' and '..' are a problem.)

I was going to suggest that we add U+002E to the encode set, but it turns out that won't help -- "%2e" is considered equivalent to ".". So I'm not sure exactly how we can prevent this: either prevent all placeholders from appearing before the '?' (would be the big hammer approach), or otherwise somehow ban these path segments.

@mgiuca mgiuca force-pushed the errors-at-parse-time branch from e284031 to 69fba2b Compare December 7, 2017 07:31
@mgiuca mgiuca closed this Feb 9, 2018
@mgiuca mgiuca deleted the errors-at-parse-time branch February 9, 2018 00:12
@mgiuca
Copy link
Collaborator Author

mgiuca commented Feb 9, 2018

I've closed this and moved the work to a new branch: https://github.com/mgiuca/web-share-target/tree/parse-at-parse-time which will actually parse the URL template as a URL instead of just validating it at load time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants