Account for \n and <br> appearing in same string#27
Merged
jonw-cogapp merged 2 commits intomainfrom Feb 9, 2024
Merged
Conversation
b8581b9 to
d7eba8e
Compare
It created a false _negative_ if `\n` appeared in a HTML string The `m` flag shouldn't be necessary in json context. I don't _think_ this was contributing to the issue, but it feels correct to remove it.
d7eba8e to
dbb783b
Compare
|
@jonw-cogapp The change looks good, would it be possible to add a sample test fixture or some example string values that should / shouldn't be caught by the update? |
neilh-cogapp
approved these changes
Feb 9, 2024
Collaborator
Author
|
@neilh-cogapp Thanks. Looking at this again today I saw a way to test the behaviour using Cypress. We should expect that anything that is HTML according to that regex shouldn't have any |
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.
What does this Pull Request do?
The regular expression in
IIIFSaysThisIsHTMLreturned a false negative if\nappeared inside a HTML string owing to.not capturing whitespace characters.For reference:
.= any character\s= any whitespace character\S= any non-whitespace characterAs a result this issue only effects manifests which mix HTML and newline characters (which is technically incorrect. The newlines should be ignored in a HTML context, but should be included in the regex in order to match correctly).
We noticed this in manifests that came out of StoriiiesEditor, but that has been patched separately to replace
\nwith<br>(these were statically wrapped in a<p>tag, qualifying them as HTML).I also removed the
mflag a this shouldn't be needed.N.B.
I tried to see if this would be easy enough to add a new test fixture and assertion in Cypress, but it seems to have trouble comparing the fixture value when mixing HTML and plain text newline characters
Test coverage
Yes/No: Are changes in this pull-request covered by:
Interested parties
@tristanr-cogapp