mirror of
https://github.com/tenrok/BBob.git
synced 2026-05-15 11:59:37 +03:00
fix(plugin-helper): escape case insensitive javascript: attrs
This commit is contained in:
@@ -34,7 +34,7 @@ const escapeHTML = (value) => value
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
// eslint-disable-next-line no-script-url
|
||||
.replace('javascript:', 'javascript%3A');
|
||||
.replace(/(javascript):/gi, '$1%3A');
|
||||
|
||||
/**
|
||||
* Acept name and value and return valid html5 attribute string
|
||||
|
||||
@@ -92,6 +92,12 @@ describe('@bbob/plugin-helper', () => {
|
||||
href: `javascript:alert('hello')`,
|
||||
})).toBe(` onclick="javascript%3Aalert('hello')" href="javascript%3Aalert('hello')"`)
|
||||
});
|
||||
test(`JAVASCRIPT:alert("hello")`, () => {
|
||||
expect(attrsToString({
|
||||
onclick: `JAVASCRIPT:alert('hello')`,
|
||||
href: `JAVASCRIPT:alert('hello')`,
|
||||
})).toBe(` onclick="JAVASCRIPT%3Aalert('hello')" href="JAVASCRIPT%3Aalert('hello')"`)
|
||||
});
|
||||
test(`<tag>`, () => {
|
||||
expect(attrsToString({
|
||||
onclick: `<tag>`,
|
||||
|
||||
Reference in New Issue
Block a user