mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
fix: codeql alerts
This commit is contained in:
1 parent
f7286a08a6
commit
ff4fd6c65c
3 files changed
+1787
-1027
No files matched your search
@@ -203,6 +203,7 @@
|
||||
"pythonstack.js": "^1.0.2",
|
||||
"qpdf-wasm-esm-embedded": "^1.1.1",
|
||||
"qrcode": "^1.5.1",
|
||||
"sanitize-html": "^2.13.1",
|
||||
"qrcode-parser": "^2.1.3",
|
||||
"qrcode-terminal-nooctal": "^0.12.1",
|
||||
"randexp": "^0.5.3",
|
||||
@@ -283,6 +284,7 @@
|
||||
"@types/potrace": "^2.1.5",
|
||||
"@types/punycode": "^2.1.4",
|
||||
"@types/qrcode": "^1.5.0",
|
||||
"@types/sanitize-html": "^2.13.0",
|
||||
"@types/stringify-object": "^4.0.5",
|
||||
"@types/spdx-satisfies": "^0.1.2",
|
||||
"@types/sshpk": "^1.17.4",
|
||||
|
||||
Generated
+1775
-1022
File diff suppressed because it is too large.
Load diff
@@ -1,3 +1,5 @@
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
|
||||
function stripNonLatinCharacters(text: string) {
|
||||
return text.replace(/[^A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u02BB\u02EE\uA78C\d\s_-]/g, '');
|
||||
};
|
||||
@@ -13,8 +15,11 @@ function spacesToDash(text: string) {
|
||||
};
|
||||
|
||||
function stripHtmlTags(text: string) {
|
||||
return text.replace(/<.*?>/g, '');
|
||||
};
|
||||
return sanitizeHtml(text, {
|
||||
allowedTags: [],
|
||||
allowedAttributes: {},
|
||||
});
|
||||
}
|
||||
|
||||
function stripMarkdownLinks(text: string, replacement: string = '$1') {
|
||||
return text.replace(/\[([^\]]*)\]\([^\)]*\)/g, replacement);
|
||||
@@ -124,7 +129,7 @@ export function getTocMarkdown({
|
||||
const titles = getTitles(markdown, titleContent => getFinalId(genericAnchorGenerator(titleContent, concatSpaces)));
|
||||
|
||||
const createLink = (linkText: string, url: string) => {
|
||||
return `[${linkText.replace('[', '\\[').replace(']', '\\]')}](${url.replace('(', '%28').replace(')', '%29')})`;
|
||||
return `[${linkText.replace(/\[/g, '\\[').replace(/\]/g, '\\]')}](${url.replace(/\(/g, '%28').replace(/\(/g, '%29')})`;
|
||||
};
|
||||
|
||||
let markdownTOC = '';
|
||||
@@ -133,11 +138,11 @@ export function getTocMarkdown({
|
||||
const commentClose = commentStyle === 'html' ? '-->' : '-%}';
|
||||
|
||||
resultMarkdown = resultMarkdown.replace(
|
||||
new RegExp(`\n${commentOpen} TOC START.*?TOC END ${commentClose}\n`, 'smg'),
|
||||
new RegExp(`\n${escapeRegExp(commentOpen)} TOC START.*?TOC END ${escapeRegExp(commentClose)}\n`, 'smg'),
|
||||
'\n[TOC]\n',
|
||||
);
|
||||
resultMarkdown = resultMarkdown.replace(
|
||||
new RegExp(`^${commentOpen} TOC ANCHOR.*?\n`, 'mg'),
|
||||
new RegExp(`^${escapeRegExp(commentOpen)} TOC ANCHOR.*?\n`, 'mg'),
|
||||
'',
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user