Repository navigation
Conversation
… parentheses resolve injectAssetPaths ran the replaceAssetPaths regex over the whole content serialized as JSON. The regex's name class has no parentheses, and its leading [^:][^/]?[^/]? lets a match start at the closing quote of one string and run into the next, so content such as ["image (1).png","heart.png"] had the prefix inserted outside any string and JSON.parse threw. Each string value is now handled on its own. A value that is nothing but a relative file name gets the prefix directly, which accepts parentheses, full-width brackets, kana and hangul but not sentence punctuation. Other strings go through the original regex, except that a match closing on a different quote than it opened with is left alone instead of having a quote rewritten.
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.
injectAssetPathsran thereplaceAssetPathsregex over the whole content serialized as JSON. The regex's name class has no parentheses, and its leading[^:][^/]?[^/]?lets a match start at the closing quote of one string and run into the next. Content such as["image (1).png","heart.png"]got the prefix inserted outside any string,JSON.parsethrew, and the component failed to render.Each string value is now handled on its own. A value that is nothing but a relative file name gets the prefix directly; this accepts parentheses, full-width brackets, kana and hangul, but not sentence punctuation, so prose that ends in a file name is not mistaken for one. Other strings, such as HTML, go through the original regex, except that a match closing on a different quote than it opened with is left alone instead of having a quote rewritten. For matches whose quotes agree the output is unchanged. Object keys are no longer rewritten.
The server side of the same problem, importing such assets between units, is WISE-Community/WISE-API#367.
Testing: seven new
injectAssetPaths()tests inprojectService.spec.ts, covering parentheses, CJK punctuation, a name the pattern cannot match followed by one it can, mismatched quotes, HTML text with parentheses, prose and absolute paths. Four fail on develop; the other three guard behaviour that develop already gets right. The existingreplaceAssetPathstests pass unchanged.