You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop: Security: Fixes #6004: Prevent XSS in Goto Anything
This commit is contained in:
@@ -97,8 +97,7 @@ class HtmlUtils {
|
||||
return selfClosingElements.includes(tagName.toLowerCase());
|
||||
}
|
||||
|
||||
// TODO: copied from @joplin/lib
|
||||
stripHtml(html: string) {
|
||||
public stripHtml(html: string) {
|
||||
const output: string[] = [];
|
||||
|
||||
const tagStack: string[] = [];
|
||||
@@ -130,7 +129,14 @@ class HtmlUtils {
|
||||
parser.write(html);
|
||||
parser.end();
|
||||
|
||||
return output.join('').replace(/\s+/g, ' ');
|
||||
// In general, we want to get back plain text from this function, so all
|
||||
// HTML entities are decoded. Howver, to prevent XSS attacks, we
|
||||
// re-encode all the "<" characters, which should break any attempt to
|
||||
// inject HTML tags.
|
||||
|
||||
return output.join('')
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(/</g, '<');
|
||||
}
|
||||
|
||||
public sanitizeHtml(html: string, options: any = null) {
|
||||
|
||||
Reference in New Issue
Block a user