Fixed search abandon anything after #
character - #3779
#3826
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As described in #3779. If you search for a song title that contains
#
character, everything from that character will be dropped. As the result, the query only look for string before the#
What I found
The problem seems to be a string sanitization happens before the string is passed to param for query. As observed, line 383 of AppNavigation.kt yields both string with and without
#
.Solution
This can be prevent by converting query string to URL-safe string (with special characters converted into their corresponding percent-encoded format) with the implementation of
URLEncoder#encode()
. For example, stringCC#2 OST Arknights
will be converted intoCC%232+OST+Arknights
However, this creates another problem. The query string is now
CC%232+OST+Arknights
instead of what user input. When present this to user in SearchResultScreen.kt, the result is undesired.To counter this effect,
URLDecoder#decode()
is implemented to convert URL-safe string to readable string.Conclusion
The problem seems to go away when the implementation is introduced. But I think this is just a temporary solution until the root cause is found.
Songs with
#
or most special characters is showing up in search result