Skip to content
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

Error with canonicalize a protocol getting called with an empty string #118

Closed
crowlKats opened this issue Sep 3, 2021 · 4 comments
Closed

Comments

@crowlKats
Copy link

Given testdata

  {
    "pattern": [{ "pathname": "/foo/bar" }],
    "inputs": [{ "pathname": "/foo/bar" }],
    "expected_match": {
      "pathname": { "input": "/foo/bar", "groups": {} }
    }
  },

we are getting an error in the constructor at compile a component for protocol, as the call to canonicalize a protocol is happening with an empty string as argument. that call is happening in maybe add a part from the pending fixed value, which is getting called in add a part, which is called at https://wicg.github.io/urlpattern/#ref-for-add-a-part.
This does seem a bug with the spec since we re-checked our code regarding the steps involved and everything seems correct, though we might have overlooked something.

The steps defined for canonicalize a protocol can never succeed for an empty string input.

@wanderview
Copy link
Member

Step 1 of "maybe add a part from the pending fixed value":

https://wicg.github.io/urlpattern/#maybe-add-a-part-from-the-pending-fixed-value

Has an early return for empty string. Is that not catching this case?

@wanderview
Copy link
Member

However, I do see in the c++ implementation that I have empty string checks in all the encoding callback implementations. That's probably the most expedient fix here as well.

@wanderview
Copy link
Member

To clarify, there are other places in "add a part" where we invoke the encoding callback without checking to see if the value is empty first or not. I can see in the c++ implementation that we do pass empty strings to the encoding callbacks.

@crowlKats
Copy link
Author

Has an early return for empty string. Is that not catching this case?

it isn't

To clarify, there are other places in "add a part" where we invoke the encoding callback without checking to see if the value is empty first or not. I can see in the c++ implementation that we do pass empty strings to the encoding callbacks.

Oh I see, i guess that is most likely what the issue is

wanderview added a commit that referenced this issue Sep 3, 2021
Make encoding callbacks short circuit on empty strings. (Fixes #118)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants