-
Notifications
You must be signed in to change notification settings - Fork 6
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
IBX-5054: HTML code gets removed from the Custom tag's string attribute #71
IBX-5054: HTML code gets removed from the Custom tag's string attribute #71
Conversation
Failing SOLR test is not related to changes in this PR... |
const attributeValue = value !== null ? value : ''; | ||
// Escaping | ||
// <script>alert("Hello! I am a script!");</script> --> <script>alert("Hello! I am a script!");</script> | ||
const stringTempNode = domDocument.createElement('div'); |
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.
What do you think about escaping without creating div?
const valueString = value ?? '';
const attributeValue = valueString
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
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.
Escaping like I currently do seems to be quite common in JS. But if you prefer, I can change it as suggested. However, others have already approved it so not sure what others think of it.
I am not sure either if your suggestion covers all characters that needs to be escaped ?
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.
After talking with the frontend team, I approved for your solution :)
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.
Retest of original issue OK.
Sanities on rich-text field OK.
QA Approved on Ibexa Experience 4.3.4.
2165f6a
to
d51b59b
Compare
Rebased to see if we can get CI green. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Missing escaping of input
TODO:
Implement tests.( Assume this is not needed for this one ?)$ composer fix-cs
).