Skip to content

Commit

Permalink
mark cityssm.escapeHTML as a sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Apr 30, 2024
1 parent 689ce4a commit 2fd1b74
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
16 changes: 16 additions & 0 deletions eslint-config-cityssm.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ module.exports = {
'n/no-missing-import': 'off',
'no-extra-semi': 'off',
'no-secrets/no-secrets': 'error',
'no-unsanitized/method': [
'error',
{
escape: {
methods: ['cityssm.escapeHTML']
}
}
],
'no-unsanitized/property': [
'error',
{
escape: {
methods: ['cityssm.escapeHTML']
}
}
],
'sonarjs/cognitive-complexity': ['warn', 20],
'sonarjs/no-duplicate-string': 'warn',
'sort-imports': [
Expand Down
18 changes: 18 additions & 0 deletions eslint-config-cityssm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ module.exports = {
'no-extra-semi': 'off',
'no-secrets/no-secrets': 'error',

'no-unsanitized/method': [
'error',
{
escape: {
methods: ['cityssm.escapeHTML']
}
}
],

'no-unsanitized/property': [
'error',
{
escape: {
methods: ['cityssm.escapeHTML']
}
}
],

'sonarjs/cognitive-complexity': ['warn', 20],
'sonarjs/no-duplicate-string': 'warn',

Expand Down
6 changes: 6 additions & 0 deletions samples/browserTest.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
document.getElementById('#test').innerHTML = document.getElementsByClassName('input')[0].value;
document.getElementById('#test').innerHTML = cityssm.escapeHTML(document.getElementsByClassName('input')[0].value);
document.getElementById('#test').innerHTML = `<p>
${cityssm.escapeHTML(document.getElementsByClassName('input')[0].value)}
</p>`;
var text = document.getElementsByTagName('p')[2].textContent;
document.getElementById('#test').insertAdjacentHTML('beforeend', text);
13 changes: 12 additions & 1 deletion samples/browserTest.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
document.getElementById('#test')!.innerHTML = document.getElementsByClassName('input')[0].value
document.getElementById('#test')!.innerHTML = document.getElementsByClassName('input')[0].value

document.getElementById('#test')!.innerHTML = cityssm.escapeHTML(document.getElementsByClassName('input')[0].value)


document.getElementById('#test')!.innerHTML = `<p>
${cityssm.escapeHTML(document.getElementsByClassName('input')[0].value})}
</p>`

var text = document.getElementsByTagName('p')[2].textContent

document.getElementById('#test')!.insertAdjacentHTML('beforeend', text)

0 comments on commit 2fd1b74

Please sign in to comment.