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

Can't have parameterized queries in quotes containing ampersand #5

Closed
christopherdude opened this issue Oct 23, 2016 · 9 comments
Closed
Labels

Comments

@christopherdude
Copy link

<a href="http://www.domain.com?x=1&b=3">asdfas</a> Cannot parse with ampersand in the parameterized query.

@anthonyjb
Copy link
Member

Shouldn't that be &amp;, the ampersand needs to be encoded?

@christopherdude
Copy link
Author

Not in a URL unless the developer "encodes" the Url. The Url should be able to accept & symbols by itself.

@christopherdude
Copy link
Author

Please let me know when there's a fix to this as I enjoy your library.

@anthonyjb
Copy link
Member

Hi @christopherdengler you're right I hadn't realised the spec had changed in HTML5 to allow ambsersands, just been reading about it here https://mathiasbynens.be/notes/ambiguous-ampersands

I'll look at implementing ambiguous ampersands in the next release :+

@anthonyjb anthonyjb added bug and removed question labels Oct 26, 2016
@christopherdude
Copy link
Author

It's actually been around since before 1996, but as a PARAMETER DELIMITER. The ampersand is just a simple way to separate parameters such as http://mydomain.com/testpage?a=1&b=2&c=3

In that case, a=1, b=2, and c=3. However, you're right if you're referring to it as TEXT in the Url.

http://example.com/Alice&Bob
would have to be
http://example.com/?arg=Alice%26Bob

But there's really no way for your parser to know what the developer is trying to do. I would just allow it. Is there a simple fix you're putting in that I could manually code into the code that I have?

@anthonyjb
Copy link
Member

@christopherdengler according to the article I referenced (as far as I understand it) and if I attempt to validate a document as HTML4 on the W3C then you can't use the following in 'http://mydomain.com/testpage?a=1&b=2&c=3' without it raising a validation error.

So I think it's worth while having the default support ambiguous ampersands, but having a setting that allows for older behaviour such as displayed by HTML4 (perhaps XHTML not sure what this does).

@christopherdude
Copy link
Author

I'm wondering if you could send me your fix sooner than later? I'm implementing this in a project..? Much appreciated..

@anthonyjb
Copy link
Member

anthonyjb commented Oct 27, 2016

Hi @christopherdengler - really sorry I've taken a look this morning and the fix isn't immediately obvious to me (I need to modify the parser transitions that are handling entities and that's going to take me an hour or two I suspect to do and test) - unfortunately I'm stacked on work projects until the weekend but it'll be first on my list Saturday (or if things go better than expected I'll try to get it done this evening or tomorrow evening but I can't promise).

@anthonyjb
Copy link
Member

Hi @christopherdengler as promised I've pushed a new release which caters for ambiguous ampersands. I've put in place a test to check for the various forms that from my understanding need to be supported but let me know if you have any issues.

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

No branches or pull requests

2 participants