Repository navigation
Conversation
When steps are imported from another unit, getAssetFileNames searched the serialized steps with one regex whose name class has no parentheses and no CJK characters. A name such as "diagram (1).png" was not found, so the asset was not copied, and a match could start at the closing quote of one JSON string and run into the next, yielding names like ',"b.png'. Each string value of the steps JSON is now handled on its own: a value that is itself a relative file name is taken whole, and any other value is searched with the same pattern the client uses, case-insensitively. Renaming an imported asset used replaceAll, which treats the file name as a regex: a name with parentheses silently matched nothing and an unbalanced parenthesis threw PatternSyntaxException. The rename is now a literal replace and also covers the %20-encoded form of the name.
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.
When steps are imported from another unit,
getAssetFileNamessearched the serialized steps with a single regex whose name class has no parentheses and no CJK characters. A name such asdiagram (1).pngwas not found, so the asset was not copied into the target unit and the imported step showed a broken image. Because the regex ran over the whole JSON text, a match could also start at the closing quote of one string and run into the next, producing names like,"b.png.Each string value of the steps JSON is now handled on its own. A value that is itself a relative file name is taken whole; any other value, such as HTML, is searched with the same pattern the client's
replaceAssetPathsuses, case-insensitively. Text that is not JSON is still searched as a whole.Renaming an imported asset used
replaceAll, which treats the file name as a regex: a name with parentheses silently matched nothing and an unbalanced parenthesis threwPatternSyntaxException. The rename is now a literal replace and also covers the%20-encoded form, since names are found after decoding%20.The client side of the same problem is WISE-Community/WISE-Client#2365.
Testing: six new tests in
AuthorAPIControllerTest. On develop four fail and one errors; the sixth, which checks that parentheses in HTML text do not swallow the next image, passes on both and guards against widening the embedded pattern. The existing%20test still passes.