Skip to content

Commit 30f6d86

Browse files
committed
🔥 Remove old escapeHTML function
1 parent eea55d7 commit 30f6d86

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

src/script/lib/helper.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ export function dynamicList(list: string[], select: HTMLSelectElement, title?: s
1111
});
1212
}
1313

14-
export function escapeHTML(str: string): string {
15-
return str.replace(/([<>&"'])/g, (match, p1) => (
16-
{
17-
'<': '&lt;',
18-
'>': '&gt;',
19-
'&': '&amp;',
20-
'"': '&quot;',
21-
"'": '&apos;'
22-
}[p1])
23-
);
24-
}
25-
2614
export function exportToFile(dataStr, fileName = 'data.txt') {
2715
const dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
2816
const linkElement = document.createElement('a');

src/script/optionPage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Constants from './lib/constants';
2-
import { dynamicList, escapeHTML, exportToFile, readFile, removeChildren, removeFromArray } from './lib/helper';
2+
import { dynamicList, exportToFile, readFile, removeChildren, removeFromArray } from './lib/helper';
33
import WebConfig from './webConfig';
44
import Filter from './lib/filter';
55
import Domain from './domain';
@@ -743,7 +743,7 @@ export default class OptionPage {
743743
const optionElement = document.createElement('option');
744744
optionElement.value = item === list[0] ? '' : item.replace(regExp, '');
745745
optionElement.dataset.sensitive = regExp.test(item).toString();
746-
optionElement.textContent = escapeHTML(item);
746+
optionElement.textContent = item;
747747
whitelist.appendChild(optionElement);
748748
});
749749
this.populateWhitelistWord();
@@ -887,7 +887,7 @@ export default class OptionPage {
887887
const optionElement = document.createElement('option');
888888
optionElement.value = word === words[0] ? '' : word;
889889
optionElement.dataset.filtered = filteredWord;
890-
optionElement.textContent = escapeHTML(filteredWord);
890+
optionElement.textContent = filteredWord;
891891
wordsSelect.appendChild(optionElement);
892892
});
893893

src/script/popup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Constants from './lib/constants';
2-
import { dynamicList, escapeHTML } from './lib/helper';
2+
import { dynamicList } from './lib/helper';
33
import WebAudioSites from './webAudioSites';
44
import WebConfig from './webConfig';
55
import Domain from './domain';
@@ -167,9 +167,9 @@ class Popup {
167167
tooltipSpan.classList.add('summaryTooltip');
168168
tooltipSpan.classList.add('w3-tag');
169169
tooltipSpan.classList.add('w3-text');
170-
tooltipSpan.textContent = escapeHTML(key);
170+
tooltipSpan.textContent = key;
171171
const wordSpan = document.createElement('span');
172-
wordSpan.textContent = escapeHTML(summary[key].filtered);
172+
wordSpan.textContent = summary[key].filtered;
173173
wordCell.appendChild(tooltipSpan);
174174
wordCell.appendChild(wordSpan);
175175

test/lib/helper.spec.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { expect } from 'chai';
2-
import { escapeHTML, formatNumber, getVersion, hmsToSeconds, isVersionOlder, removeFromArray, secondsToHMS } from '../built/lib/helper';
2+
import { formatNumber, getVersion, hmsToSeconds, isVersionOlder, removeFromArray, secondsToHMS } from '../built/lib/helper';
33

44
const array = ['a', 'needle', 'in', 'a', 'large', 'haystack'];
55

66
describe('Helper', function() {
7-
describe('escapeHTML()', function() {
8-
it('should return HTML safe string', function() {
9-
expect(escapeHTML('a>b')).to.eql('a&gt;b');
10-
expect(escapeHTML('(?<!un)censored')).to.eql('(?&lt;!un)censored');
11-
expect(escapeHTML('already safe')).to.eql('already safe');
12-
});
13-
});
14-
157
describe('formatNumber()', function() {
168
it('Format numbers for counter display', function() {
179
expect(formatNumber(999)).to.eql('999');

0 commit comments

Comments
 (0)