RTFDB-4842: Improve user input handling in "mapbox-gl-geocoder" - #558
Open
pahuta wants to merge 2 commits into
Open
RTFDB-4842: Improve user input handling in "mapbox-gl-geocoder"#558pahuta wants to merge 2 commits into
pahuta wants to merge 2 commits into
Conversation
- Remove numeric-range bound on coordinate detection regex so it matches how the Geocoding v5 API itself detects coordinate-shaped queries, fixing forward/reverse misclassification (422 errors) for out-of-range coordinate-like input - Require a comma (with optional surrounding whitespace) as the coordinate separator so whitespace-only separated numbers are still treated as a forward query - Deduplicate the coordinate regex in the forward-request branch, reusing the shared utils.REVERSE_GEOCODE_COORD_RGX - Add corresponding test cases and changelog entry https://mapbox.atlassian.net/browse/RTFDB-4842
Add input length validation and fix suggestions list race conditions https://mapbox.atlassian.net/browse/RTFDB-4842
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
utils.REVERSE_GEOCODE_COORD_RGXSince code-scanning found an issue https://github.com/mapbox/mapbox-gl-geocoder/security/code-scanning/7, I also:
_renderMessage()so it's consistently hidden for every error/no-results message.suggestionslibrary's own nativekeyup/pastelisteners on the input element that could redraw the list from stale/empty data and wipe out a just-rendered message — most visibly, pasting an over-limit value directly (via keyboard shortcut) silently failed to show the "too long" error.https://mapbox.atlassian.net/browse/RTFDB-4842
npm run docsand commit changes to API.mdmainheading before mergingPrevious behavior vs new behavior:
reverse.mp4
Add checking search input length before sending requests to Geocoding v5 API.
Previous behavior
old.mp4
New behavior
new.mp4