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

Handle '+' as space in URI #313

Merged
merged 1 commit into from
Jun 16, 2019
Merged

Handle '+' as space in URI #313

merged 1 commit into from
Jun 16, 2019

Conversation

jacobrose
Copy link
Contributor

Traditional URI encoding uses '+' instead of '%20' to represent
spaces in URI parameters, but the decodeURIComponent method
does not recognize this representation.

This is significant because Chrome's "Manage Search Engines"
settings page, which lets users add arbitrary search engines
as shortcuts in that browser's location bar, represents spaces
using the '+' character. So, if you try to add a local Hound
instance to your Chrome search engines, any multi-word search
will be replaced by a weird regular expression, as the '+'
characters will be retained in the search box.

For instance, without this change, if you were to set 'hound'
as the shortcut term, then entering 'hound some thing' will
send the search parameter '?q=some+thing' to Hound, resulting
in a search for the regular expression /some+thing/, matching
'something', 'someething', 'someeeeeeeeething', etc.

Regular expression search is not affected by this change,
because an actual "+" character entered using this Chrome
feature will be encoded as %2B, and the '+' will appear in
Hound's search box correctly.

Traditional URI encoding uses '+' instead of '%20' to represent
spaces in URI parameters, but the decodeURIComponent method
does not recognize this representation.

This is significant because Chrome's "Manage Search Engines"
settings page, which lets users add arbitrary search engines
as shortcuts in that browser's location bar, represents spaces
using the '+' character. So, if you try to add a local Hound
instance to your Chrome search engines, any multi-word search
will be replaced by a weird regular expression, as the '+'
characters will be retained in the search box.

For instance, without this change, if you were to set 'hound'
as the shortcut term, then entering 'hound some thing' will
send the search parameter '?q=some+thing' to Hound, resulting
in a search for the regular expression /some+thing/, matching
'something', 'someething', 'someeeeeeeeething', etc.

Regular expression search is not affected by this change,
because an actual "+" character entered using this Chrome
feature will be encoded as %2B, and the '+' will appear in
Hound's search box correctly.
@kellegous kellegous merged commit c75143d into hound-search:master Jun 16, 2019
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