Skip to content
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

[SER-1602] Security Vulnerabilities and bugs #5370

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
sanitize text and links
prevent xss
  • Loading branch information
John-Weak committed Jun 26, 2024
commit 34c7bcba3d0bf188e15def89ad3f22b9a95b2ec6
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,18 @@
links = JSON.parse(response.links);
}
if(consent && links && finalText){
links.forEach(function(link) {
var regex = new RegExp('\\b' + link.textValue + '\\b', 'g');
finalText = finalText.replace(regex, '<a href="' + link.linkValue + '" target="_blank">' + link.textValue + '</a>');
});

//sanitize the text and links
finalText = $("<p>").text(finalText).text();
links.forEach(function (link) {
link.linkValue = $("<p>").text(link.linkValue).text();
link.textValue = $("<p>").text(link.textValue).text();
var regex = new RegExp('\\b' + link.textValue + '\\b', 'g');
finalText = finalText.replace(regex, '<a href="' + link.linkValue + '" target="_blank">' + link.textValue + '</a>');
});
John-Weak marked this conversation as resolved.
Show resolved Hide resolved
}
if(consent){
contentEl.removeClass("hidden");
$(contentEl).find(".text").html(finalText);

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
var consentChecked = contentEl.find("input").is(":checked");
if(consentChecked){
$("#cf-submit-button").removeClass("disabled");
Expand Down
Loading