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

channels: support non-knot text in searches #3274

Merged
merged 3 commits into from
Feb 26, 2024
Merged

Conversation

Fang-
Copy link
Member

@Fang- Fang- commented Feb 21, 2024

On the backend, we were taking the search query directly out of the path. Assuming all paths are well-formed, this meant we had no way of receiving text that didn't fit into the path's @ta (aka knot) character limitations.
Here, we first try to decode the query part of the search scry path as a knot-encoded string. Only if that fails do we take the path element as-is. (That way, we maintain backwards compatibility, and continue supporting trivial search cases trivially.)

On the frontend, we were injecting the search query into the scry url directly, even if it contained non-url-safe characters. Something further down the stack would url-encode the url string, but the backend wasn't prepared to handle this (and shouldn't have been). Here, we add a "stringToTa()" utility for knot-encoding strings, and make sure to do that to the query before putting it into the url.

With the combination of these, we now support arbitrary text (including unicode!) in the search.

Fixes LAND-1581.

On the backend, we were taking the search query directly out of the
path. Assuming all paths are well-formed, this meant we had no way of
receiving text that didn't fit into the path's @ta (aka knot) character
limitations.
Here, we first try to decode the query part of the search scry path as a
knot-encoded string. Only if that fails do we take the path element
as-is. (That way, we maintain backwards compatibility, and continue
supporting trivial search cases trivially.)

On the frontend, we were injecting the search query into the scry url
directly, even if it contained non-url-safe characters. Something
further down the stack would url-encode the url string, but the backend
wasn't prepared to handle this (and shouldn't have been).
Here, we add a "stringToTa()" utility for knot-encoding strings, and
make sure to do that to the query before putting it into the url.

With the combination of these, we now support arbitrary text (including
unicode!) in the search.
Copy link

linear bot commented Feb 21, 2024

Obviously chat implements its own (similar) search logic, so we need to
update that to match. (The frontend code was already updated in
46313da.)
@Fang-
Copy link
Member Author

Fang- commented Feb 21, 2024

There's some frontend bug, where searching for "Abc" returns results for both "Abc" and "abc" (lowercase), but searching for "abc" only returns the "abc". (If you look at the requests themselves, their responses both contain the same results...)

I thought that was introduced by this PR, but it happens on both old and new backends, and using the frontend from develop. I wanted to try git bisecting it, but ran into monorepo migration shenanigans, and decided to punt.

Copy link
Member

@arthyn arthyn left a comment

Choose a reason for hiding this comment

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

lgtm, let's see if we can use @urbit/aura-js. This PR does something similar to what you've done but they are different: urbit/aura-js#6

@arthyn arthyn merged commit ddcada5 into develop Feb 26, 2024
1 check passed
@arthyn arthyn deleted the m/search-encoding branch February 26, 2024 21:12
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