-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix content clickable when having HTML attributes with "<" in the value #39931
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense and it works as described. 👍
Think this restriction was (mostly) a security hardening. In theory both If I remember right this code is more restrictive to "err on the side of safety", and to keep that functionality simple. If the |
@azaozz, thank you for checking! I agree that a refactor to use the WP HTML API would probably be better here. But since it would impact all WPCOM sites, I think it would need to be a cautious work, checking possible issues, performance, and so on. Since we don't have a critical issue related to the brackets, I would go ahead with this current solution, and I could also create an issue for a refactor to use the WP HTML API. Does it make sense to you? |
@renatho Sure, sounds good. I cannot remember if there was a specific (security hardening) reason to exclude HTML tags that may have extra Would also be pretty good if some unit tests are added for this, would definitely help in similar situations in the future. |
8f2d703
to
a68558a
Compare
31ccde5
to
2624695
Compare
2624695
to
753bbe0
Compare
It seems the issue with the test coverage is something also happening in other PRs, so considering it was already reviewed and I just wrote a test, I'm going ahead and merging this. The test was added here: 753bbe0 Thank you for your approval @m1r0! And thank you for checking and for your suggestions @azaozz!
Issue to refactor the whole approach created here: #40134 |
Related to https://github.com/Automattic/sensei-pro/issues/2574
Proposed changes:
This regex was introduced years ago: https://github.com/Automattic/wpcomsh/pull/375/files#diff-617829ac2bd62b94e204d12538c81a709caa5671cc2471c1051b2b8e272e6b50R982. Notice that it tries to split the pieces starting with "<" and ending with ">" to handle them in chunks.
But with the previous regex, if we have "<" inside the tag (an attribute), it doesn't get the chunks properly. If I'm not missing anything, we don't need to skip the "<" from inside the tags because "<" wouldn't never be there.
<this<isnotexpected>
.So removing that char from the excluding portion of the regex, fixes the issue.
To be more clear, see the following examples:
The current regex:
The new regex:
Notice that we could also have issues with the
>
inside the attributes, but this doesn't happen because of this: WordPress/gutenberg#9963.Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Known issue: https://github.com/Automattic/sensei-pro/issues/2609