#361: Fix for quoted data URIs getting prepended with path#432
Merged
cloudhead merged 1 commit intoless:masterfrom Oct 23, 2011
Merged
#361: Fix for quoted data URIs getting prepended with path#432cloudhead merged 1 commit intoless:masterfrom
cloudhead merged 1 commit intoless:masterfrom
Conversation
cloudhead
pushed a commit
that referenced
this pull request
Oct 23, 2011
#361: Fix for quoted data URIs getting prepended with path
Contributor
Author
|
This actually created a much larger browser-only bug, where all strings are treated as absolute URLs. This happened because I removed the slash after the optional group, so the regex now always matches all strings: /^(?:https?:\/\/|file:\/\/|data:)?/ // matches a string starting with anythingThe question is what to do in the case where the URL starts with a slash. If urls starting with a slash are treated as absolute, we can simply change the regex to: /^(?:https?:\/\/|file:\/\/|data:|\/)/ // matches a string with http(s), file, data, or a slashBut the line inside the conditional, which only runs if the regex doesn't match, (and therefore the url is being treated as relative) seems to expect that urls starting with slash might come to it: val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);In which case the regex should be changed to non-optional but not include the slash option: /^(?:https?:\/\/|file:\/\/|data:)/ // matches a string with http(s), file, or data only. |
stefanklug
pushed a commit
to stefanklug/carto
that referenced
this pull request
Jan 27, 2019
update docs
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.
In the browser environment, quoted data URIs are prepended with the import path.
The issue superficially appeared to be fixed because the tests pass, but that was because the codepath with the bug is only run in the browser environment.
This ticket fixes the problem by correctly pattern-matching for valid data URIs, which do not require a slash.