2024-03-21 14:09:55 +00:00
|
|
|
// (c) Copyright Ascensio System SIA 2009-2024
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// This program is a free software product.
|
|
|
|
// You can redistribute it and/or modify it under the terms
|
|
|
|
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
|
|
|
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
|
|
|
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
|
|
|
// any third-party rights.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
|
|
|
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// The interactive user interfaces in modified source and object code versions of the Program must
|
|
|
|
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
|
|
|
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
|
|
|
// trademark law for use of our trademarks.
|
2024-03-18 09:54:09 +00:00
|
|
|
//
|
2024-03-17 23:13:02 +00:00
|
|
|
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
|
|
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
|
|
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
|
2024-01-12 07:33:24 +00:00
|
|
|
/* eslint-disable no-useless-escape */
|
2021-11-09 16:32:15 +00:00
|
|
|
/**
|
|
|
|
* Encoder
|
|
|
|
*/
|
|
|
|
export const Encoder = {
|
|
|
|
EncodeType: "entity",
|
2024-01-12 07:33:24 +00:00
|
|
|
isEmpty(val: null | string) {
|
2021-11-09 16:32:15 +00:00
|
|
|
if (val) {
|
2024-01-12 07:33:24 +00:00
|
|
|
return val === null || val.length === 0 || /^\s+$/.test(val);
|
2021-11-09 16:32:15 +00:00
|
|
|
}
|
2024-01-12 07:33:24 +00:00
|
|
|
return true;
|
2021-11-09 16:32:15 +00:00
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
HTML2Numerical(s: string) {
|
|
|
|
const arr1 = [
|
2021-11-09 16:32:15 +00:00
|
|
|
" ",
|
|
|
|
"¡",
|
|
|
|
"¢",
|
|
|
|
"£",
|
|
|
|
"¤",
|
|
|
|
"¥",
|
|
|
|
"¦",
|
|
|
|
"§",
|
|
|
|
"¨",
|
|
|
|
"©",
|
|
|
|
"ª",
|
|
|
|
"«",
|
|
|
|
"¬",
|
|
|
|
"­",
|
|
|
|
"®",
|
|
|
|
"¯",
|
|
|
|
"°",
|
|
|
|
"±",
|
|
|
|
"²",
|
|
|
|
"³",
|
|
|
|
"´",
|
|
|
|
"µ",
|
|
|
|
"¶",
|
|
|
|
"·",
|
|
|
|
"¸",
|
|
|
|
"¹",
|
|
|
|
"º",
|
|
|
|
"»",
|
|
|
|
"¼",
|
|
|
|
"½",
|
|
|
|
"¾",
|
|
|
|
"¿",
|
|
|
|
"à",
|
|
|
|
"á",
|
|
|
|
"â",
|
|
|
|
"ã",
|
|
|
|
"Ä",
|
|
|
|
"å",
|
|
|
|
"æ",
|
|
|
|
"ç",
|
|
|
|
"è",
|
|
|
|
"é",
|
|
|
|
"ê",
|
|
|
|
"ë",
|
|
|
|
"ì",
|
|
|
|
"í",
|
|
|
|
"î",
|
|
|
|
"ï",
|
|
|
|
"ð",
|
|
|
|
"ñ",
|
|
|
|
"ò",
|
|
|
|
"ó",
|
|
|
|
"ô",
|
|
|
|
"õ",
|
|
|
|
"Ö",
|
|
|
|
"×",
|
|
|
|
"ø",
|
|
|
|
"ù",
|
|
|
|
"ú",
|
|
|
|
"û",
|
|
|
|
"Ü",
|
|
|
|
"ý",
|
|
|
|
"þ",
|
|
|
|
"ß",
|
|
|
|
"à",
|
|
|
|
"á",
|
|
|
|
"â",
|
|
|
|
"ã",
|
|
|
|
"ä",
|
|
|
|
"å",
|
|
|
|
"æ",
|
|
|
|
"ç",
|
|
|
|
"è",
|
|
|
|
"é",
|
|
|
|
"ê",
|
|
|
|
"ë",
|
|
|
|
"ì",
|
|
|
|
"í",
|
|
|
|
"î",
|
|
|
|
"ï",
|
|
|
|
"ð",
|
|
|
|
"ñ",
|
|
|
|
"ò",
|
|
|
|
"ó",
|
|
|
|
"ô",
|
|
|
|
"õ",
|
|
|
|
"ö",
|
|
|
|
"÷",
|
|
|
|
"Ø",
|
|
|
|
"ù",
|
|
|
|
"ú",
|
|
|
|
"û",
|
|
|
|
"ü",
|
|
|
|
"ý",
|
|
|
|
"þ",
|
|
|
|
"ÿ",
|
|
|
|
""",
|
|
|
|
"&",
|
|
|
|
"<",
|
|
|
|
">",
|
|
|
|
"œ",
|
|
|
|
"œ",
|
|
|
|
"š",
|
|
|
|
"š",
|
|
|
|
"ÿ",
|
|
|
|
"ˆ",
|
|
|
|
"˜",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
"‌",
|
|
|
|
"‍",
|
|
|
|
"‎",
|
|
|
|
"‏",
|
|
|
|
"–",
|
|
|
|
"—",
|
|
|
|
"‘",
|
|
|
|
"’",
|
|
|
|
"‚",
|
|
|
|
"“",
|
|
|
|
"”",
|
|
|
|
"„",
|
|
|
|
"†",
|
|
|
|
"†",
|
|
|
|
"‰",
|
|
|
|
"‹",
|
|
|
|
"›",
|
|
|
|
"€",
|
|
|
|
"ƒ",
|
|
|
|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|
|
|
|
"∈",
|
|
|
|
"∉",
|
|
|
|
"∋",
|
|
|
|
"∏",
|
|
|
|
"∑",
|
|
|
|
"−",
|
|
|
|
"∗",
|
|
|
|
"√",
|
|
|
|
"∝",
|
|
|
|
"∞",
|
|
|
|
"∠",
|
|
|
|
"∧",
|
|
|
|
"∨",
|
|
|
|
"∩",
|
|
|
|
"∪",
|
|
|
|
"∫",
|
|
|
|
"∴",
|
|
|
|
"∼",
|
|
|
|
"≅",
|
|
|
|
"≈",
|
|
|
|
"≠",
|
|
|
|
"≡",
|
|
|
|
"≤",
|
|
|
|
"≥",
|
|
|
|
"⊂",
|
|
|
|
"⊃",
|
|
|
|
"⊄",
|
|
|
|
"⊆",
|
|
|
|
"⊇",
|
|
|
|
"⊕",
|
|
|
|
"⊗",
|
|
|
|
"⊥",
|
|
|
|
"⋅",
|
|
|
|
"⌈",
|
|
|
|
"⌉",
|
|
|
|
"⌊",
|
|
|
|
"⌋",
|
|
|
|
"⟨",
|
|
|
|
"⟩",
|
|
|
|
"◊",
|
|
|
|
"♠",
|
|
|
|
"♣",
|
|
|
|
"♥",
|
2024-01-11 13:38:53 +00:00
|
|
|
"♦",
|
2024-01-12 07:33:24 +00:00
|
|
|
];
|
|
|
|
const arr2 = [
|
2021-11-09 16:32:15 +00:00
|
|
|
" ",
|
|
|
|
"¡",
|
|
|
|
"¢",
|
|
|
|
"£",
|
|
|
|
"¤",
|
|
|
|
"¥",
|
|
|
|
"¦",
|
|
|
|
"§",
|
|
|
|
"¨",
|
|
|
|
"©",
|
|
|
|
"ª",
|
|
|
|
"«",
|
|
|
|
"¬",
|
|
|
|
"­",
|
|
|
|
"®",
|
|
|
|
"¯",
|
|
|
|
"°",
|
|
|
|
"±",
|
|
|
|
"²",
|
|
|
|
"³",
|
|
|
|
"´",
|
|
|
|
"µ",
|
|
|
|
"¶",
|
|
|
|
"·",
|
|
|
|
"¸",
|
|
|
|
"¹",
|
|
|
|
"º",
|
|
|
|
"»",
|
|
|
|
"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
|
|
"″",
|
|
|
|
"‾",
|
|
|
|
"⁄",
|
|
|
|
"℘",
|
|
|
|
"ℑ",
|
|
|
|
"ℜ",
|
|
|
|
"™",
|
|
|
|
"ℵ",
|
|
|
|
"←",
|
|
|
|
"↑",
|
|
|
|
"→",
|
|
|
|
"↓",
|
|
|
|
"↔",
|
|
|
|
"↵",
|
|
|
|
"⇐",
|
|
|
|
"⇑",
|
|
|
|
"⇒",
|
|
|
|
"⇓",
|
|
|
|
"⇔",
|
|
|
|
"∀",
|
|
|
|
"∂",
|
|
|
|
"∃",
|
|
|
|
"∅",
|
|
|
|
"∇",
|
|
|
|
"∈",
|
|
|
|
"∉",
|
|
|
|
"∋",
|
|
|
|
"∏",
|
|
|
|
"∑",
|
|
|
|
"−",
|
|
|
|
"∗",
|
|
|
|
"√",
|
|
|
|
"∝",
|
|
|
|
"∞",
|
|
|
|
"∠",
|
|
|
|
"∧",
|
|
|
|
"∨",
|
|
|
|
"∩",
|
|
|
|
"∪",
|
|
|
|
"∫",
|
|
|
|
"∴",
|
|
|
|
"∼",
|
|
|
|
"≅",
|
|
|
|
"≈",
|
|
|
|
"≠",
|
|
|
|
"≡",
|
|
|
|
"≤",
|
|
|
|
"≥",
|
|
|
|
"⊂",
|
|
|
|
"⊃",
|
|
|
|
"⊄",
|
|
|
|
"⊆",
|
|
|
|
"⊇",
|
|
|
|
"⊕",
|
|
|
|
"⊗",
|
|
|
|
"⊥",
|
|
|
|
"⋅",
|
|
|
|
"⌈",
|
|
|
|
"⌉",
|
|
|
|
"⌊",
|
|
|
|
"⌋",
|
|
|
|
"〈",
|
|
|
|
"〉",
|
|
|
|
"◊",
|
|
|
|
"♠",
|
|
|
|
"♣",
|
|
|
|
"♥",
|
2024-01-11 13:38:53 +00:00
|
|
|
"♦",
|
2024-01-12 07:33:24 +00:00
|
|
|
];
|
2021-11-09 16:32:15 +00:00
|
|
|
return this.swapArrayVals(s, arr1, arr2);
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
NumericalToHTML(s: string) {
|
|
|
|
const arr1 = [
|
2021-11-09 16:32:15 +00:00
|
|
|
" ",
|
|
|
|
"¡",
|
|
|
|
"¢",
|
|
|
|
"£",
|
|
|
|
"¤",
|
|
|
|
"¥",
|
|
|
|
"¦",
|
|
|
|
"§",
|
|
|
|
"¨",
|
|
|
|
"©",
|
|
|
|
"ª",
|
|
|
|
"«",
|
|
|
|
"¬",
|
|
|
|
"­",
|
|
|
|
"®",
|
|
|
|
"¯",
|
|
|
|
"°",
|
|
|
|
"±",
|
|
|
|
"²",
|
|
|
|
"³",
|
|
|
|
"´",
|
|
|
|
"µ",
|
|
|
|
"¶",
|
|
|
|
"·",
|
|
|
|
"¸",
|
|
|
|
"¹",
|
|
|
|
"º",
|
|
|
|
"»",
|
|
|
|
"¼",
|
|
|
|
"½",
|
|
|
|
"¾",
|
|
|
|
"¿",
|
|
|
|
"À",
|
|
|
|
"Á",
|
|
|
|
"Â",
|
|
|
|
"Ã",
|
|
|
|
"Ä",
|
|
|
|
"Å",
|
|
|
|
"Æ",
|
|
|
|
"Ç",
|
|
|
|
"È",
|
|
|
|
"É",
|
|
|
|
"Ê",
|
|
|
|
"Ë",
|
|
|
|
"Ì",
|
|
|
|
"Í",
|
|
|
|
"Î",
|
|
|
|
"Ï",
|
|
|
|
"Ð",
|
|
|
|
"Ñ",
|
|
|
|
"Ò",
|
|
|
|
"Ó",
|
|
|
|
"Ô",
|
|
|
|
"Õ",
|
|
|
|
"Ö",
|
|
|
|
"×",
|
|
|
|
"Ø",
|
|
|
|
"Ù",
|
|
|
|
"Ú",
|
|
|
|
"Û",
|
|
|
|
"Ü",
|
|
|
|
"Ý",
|
|
|
|
"Þ",
|
|
|
|
"ß",
|
|
|
|
"à",
|
|
|
|
"á",
|
|
|
|
"â",
|
|
|
|
"ã",
|
|
|
|
"ä",
|
|
|
|
"å",
|
|
|
|
"æ",
|
|
|
|
"ç",
|
|
|
|
"è",
|
|
|
|
"é",
|
|
|
|
"ê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Ω",
|
|
|
|
"α",
|
|
|
|
"β",
|
|
|
|
"γ",
|
|
|
|
"δ",
|
|
|
|
"ε",
|
|
|
|
"ζ",
|
|
|
|
"η",
|
|
|
|
"θ",
|
|
|
|
"ι",
|
|
|
|
"κ",
|
|
|
|
"λ",
|
|
|
|
"μ",
|
|
|
|
"ν",
|
|
|
|
"ξ",
|
|
|
|
"ο",
|
|
|
|
"π",
|
|
|
|
"ρ",
|
|
|
|
"ς",
|
|
|
|
"σ",
|
|
|
|
"τ",
|
|
|
|
"υ",
|
|
|
|
"φ",
|
|
|
|
"χ",
|
|
|
|
"ψ",
|
|
|
|
"ω",
|
|
|
|
"ϑ",
|
|
|
|
"ϒ",
|
|
|
|
"ϖ",
|
|
|
|
"•",
|
|
|
|
"…",
|
|
|
|
"′",
|
|
|
|
"″",
|
|
|
|
"‾",
|
|
|
|
"⁄",
|
|
|
|
"℘",
|
|
|
|
"ℑ",
|
|
|
|
"ℜ",
|
|
|
|
"™",
|
|
|
|
"ℵ",
|
|
|
|
"←",
|
|
|
|
"↑",
|
|
|
|
"→",
|
|
|
|
"↓",
|
|
|
|
"↔",
|
|
|
|
"↵",
|
|
|
|
"⇐",
|
|
|
|
"⇑",
|
|
|
|
"⇒",
|
|
|
|
"⇓",
|
|
|
|
"⇔",
|
|
|
|
"∀",
|
|
|
|
"∂",
|
|
|
|
"∃",
|
|
|
|
"∅",
|
|
|
|
"∇",
|
|
|
|
"∈",
|
|
|
|
"∉",
|
|
|
|
"∋",
|
|
|
|
"∏",
|
|
|
|
"∑",
|
|
|
|
"−",
|
|
|
|
"∗",
|
|
|
|
"√",
|
|
|
|
"∝",
|
|
|
|
"∞",
|
|
|
|
"∠",
|
|
|
|
"∧",
|
|
|
|
"∨",
|
|
|
|
"∩",
|
|
|
|
"∪",
|
|
|
|
"∫",
|
|
|
|
"∴",
|
|
|
|
"∼",
|
|
|
|
"≅",
|
|
|
|
"≈",
|
|
|
|
"≠",
|
|
|
|
"≡",
|
|
|
|
"≤",
|
|
|
|
"≥",
|
|
|
|
"⊂",
|
|
|
|
"⊃",
|
|
|
|
"⊄",
|
|
|
|
"⊆",
|
|
|
|
"⊇",
|
|
|
|
"⊕",
|
|
|
|
"⊗",
|
|
|
|
"⊥",
|
|
|
|
"⋅",
|
|
|
|
"⌈",
|
|
|
|
"⌉",
|
|
|
|
"⌊",
|
|
|
|
"⌋",
|
|
|
|
"〈",
|
|
|
|
"〉",
|
|
|
|
"◊",
|
|
|
|
"♠",
|
|
|
|
"♣",
|
|
|
|
"♥",
|
2024-01-11 13:38:53 +00:00
|
|
|
"♦",
|
2024-01-12 07:33:24 +00:00
|
|
|
];
|
|
|
|
const arr2 = [
|
2021-11-09 16:32:15 +00:00
|
|
|
" ",
|
|
|
|
"¡",
|
|
|
|
"¢",
|
|
|
|
"£",
|
|
|
|
"¤",
|
|
|
|
"¥",
|
|
|
|
"¦",
|
|
|
|
"§",
|
|
|
|
"¨",
|
|
|
|
"©",
|
|
|
|
"ª",
|
|
|
|
"«",
|
|
|
|
"¬",
|
|
|
|
"­",
|
|
|
|
"®",
|
|
|
|
"¯",
|
|
|
|
"°",
|
|
|
|
"±",
|
|
|
|
"²",
|
|
|
|
"³",
|
|
|
|
"´",
|
|
|
|
"µ",
|
|
|
|
"¶",
|
|
|
|
"·",
|
|
|
|
"¸",
|
|
|
|
"¹",
|
|
|
|
"º",
|
|
|
|
"»",
|
|
|
|
"¼",
|
|
|
|
"½",
|
|
|
|
"¾",
|
|
|
|
"¿",
|
|
|
|
"à",
|
|
|
|
"á",
|
|
|
|
"â",
|
|
|
|
"ã",
|
|
|
|
"Ä",
|
|
|
|
"å",
|
|
|
|
"æ",
|
|
|
|
"ç",
|
|
|
|
"è",
|
|
|
|
"é",
|
|
|
|
"ê",
|
|
|
|
"ë",
|
|
|
|
"ì",
|
|
|
|
"í",
|
|
|
|
"î",
|
|
|
|
"ï",
|
|
|
|
"ð",
|
|
|
|
"ñ",
|
|
|
|
"ò",
|
|
|
|
"ó",
|
|
|
|
"ô",
|
|
|
|
"õ",
|
|
|
|
"Ö",
|
|
|
|
"×",
|
|
|
|
"ø",
|
|
|
|
"ù",
|
|
|
|
"ú",
|
|
|
|
"û",
|
|
|
|
"Ü",
|
|
|
|
"ý",
|
|
|
|
"þ",
|
|
|
|
"ß",
|
|
|
|
"à",
|
|
|
|
"á",
|
|
|
|
"â",
|
|
|
|
"ã",
|
|
|
|
"ä",
|
|
|
|
"å",
|
|
|
|
"æ",
|
|
|
|
"ç",
|
|
|
|
"è",
|
|
|
|
"é",
|
|
|
|
"ê",
|
|
|
|
"ë",
|
|
|
|
"ì",
|
|
|
|
"í",
|
|
|
|
"î",
|
|
|
|
"ï",
|
|
|
|
"ð",
|
|
|
|
"ñ",
|
|
|
|
"ò",
|
|
|
|
"ó",
|
|
|
|
"ô",
|
|
|
|
"õ",
|
|
|
|
"ö",
|
|
|
|
"÷",
|
|
|
|
"Ø",
|
|
|
|
"ù",
|
|
|
|
"ú",
|
|
|
|
"û",
|
|
|
|
"ü",
|
|
|
|
"ý",
|
|
|
|
"þ",
|
|
|
|
"ÿ",
|
|
|
|
""",
|
|
|
|
"&",
|
|
|
|
"<",
|
|
|
|
">",
|
|
|
|
"œ",
|
|
|
|
"œ",
|
|
|
|
"š",
|
|
|
|
"š",
|
|
|
|
"ÿ",
|
|
|
|
"ˆ",
|
|
|
|
"˜",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
"‌",
|
|
|
|
"‍",
|
|
|
|
"‎",
|
|
|
|
"‏",
|
|
|
|
"–",
|
|
|
|
"—",
|
|
|
|
"‘",
|
|
|
|
"’",
|
|
|
|
"‚",
|
|
|
|
"“",
|
|
|
|
"”",
|
|
|
|
"„",
|
|
|
|
"†",
|
|
|
|
"†",
|
|
|
|
"‰",
|
|
|
|
"‹",
|
|
|
|
"›",
|
|
|
|
"€",
|
|
|
|
"ƒ",
|
|
|
|
"α",
|
|
|
|
"β",
|
|
|
|
"γ",
|
|
|
|
"δ",
|
|
|
|
"ε",
|
|
|
|
"ζ",
|
|
|
|
"η",
|
|
|
|
"θ",
|
|
|
|
"ι",
|
|
|
|
"κ",
|
|
|
|
"λ",
|
|
|
|
"μ",
|
|
|
|
"ν",
|
|
|
|
"ξ",
|
|
|
|
"ο",
|
|
|
|
"π",
|
|
|
|
"ρ",
|
|
|
|
"σ",
|
|
|
|
"τ",
|
|
|
|
"υ",
|
|
|
|
"φ",
|
|
|
|
"χ",
|
|
|
|
"ψ",
|
|
|
|
"ω",
|
|
|
|
"α",
|
|
|
|
"β",
|
|
|
|
"γ",
|
|
|
|
"δ",
|
|
|
|
"ε",
|
|
|
|
"ζ",
|
|
|
|
"η",
|
|
|
|
"θ",
|
|
|
|
"ι",
|
|
|
|
"κ",
|
|
|
|
"λ",
|
|
|
|
"μ",
|
|
|
|
"ν",
|
|
|
|
"ξ",
|
|
|
|
"ο",
|
|
|
|
"π",
|
|
|
|
"ρ",
|
|
|
|
"ς",
|
|
|
|
"σ",
|
|
|
|
"τ",
|
|
|
|
"υ",
|
|
|
|
"φ",
|
|
|
|
"χ",
|
|
|
|
"ψ",
|
|
|
|
"ω",
|
|
|
|
"ϑ",
|
|
|
|
"ϒ",
|
|
|
|
"ϖ",
|
|
|
|
"•",
|
|
|
|
"…",
|
|
|
|
"′",
|
|
|
|
"′",
|
|
|
|
"‾",
|
|
|
|
"⁄",
|
|
|
|
"℘",
|
|
|
|
"ℑ",
|
|
|
|
"ℜ",
|
|
|
|
"™",
|
|
|
|
"ℵ",
|
|
|
|
"←",
|
|
|
|
"↑",
|
|
|
|
"→",
|
|
|
|
"↓",
|
|
|
|
"↔",
|
|
|
|
"↵",
|
|
|
|
"←",
|
|
|
|
"↑",
|
|
|
|
"→",
|
|
|
|
"↓",
|
|
|
|
"↔",
|
|
|
|
"∀",
|
|
|
|
"∂",
|
|
|
|
"∃",
|
|
|
|
"∅",
|
|
|
|
"∇",
|
|
|
|
"∈",
|
|
|
|
"∉",
|
|
|
|
"∋",
|
|
|
|
"∏",
|
|
|
|
"∑",
|
|
|
|
"−",
|
|
|
|
"∗",
|
|
|
|
"√",
|
|
|
|
"∝",
|
|
|
|
"∞",
|
|
|
|
"∠",
|
|
|
|
"∧",
|
|
|
|
"∨",
|
|
|
|
"∩",
|
|
|
|
"∪",
|
|
|
|
"∫",
|
|
|
|
"∴",
|
|
|
|
"∼",
|
|
|
|
"≅",
|
|
|
|
"≈",
|
|
|
|
"≠",
|
|
|
|
"≡",
|
|
|
|
"≤",
|
|
|
|
"≥",
|
|
|
|
"⊂",
|
|
|
|
"⊃",
|
|
|
|
"⊄",
|
|
|
|
"⊆",
|
|
|
|
"⊇",
|
|
|
|
"⊕",
|
|
|
|
"⊗",
|
|
|
|
"⊥",
|
|
|
|
"⋅",
|
|
|
|
"⌈",
|
|
|
|
"⌉",
|
|
|
|
"⌊",
|
|
|
|
"⌋",
|
|
|
|
"⟨",
|
|
|
|
"⟩",
|
|
|
|
"◊",
|
|
|
|
"♠",
|
|
|
|
"♣",
|
|
|
|
"♥",
|
2024-01-11 13:38:53 +00:00
|
|
|
"♦",
|
2024-01-12 07:33:24 +00:00
|
|
|
];
|
2021-11-09 16:32:15 +00:00
|
|
|
return this.swapArrayVals(s, arr1, arr2);
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
numEncode(s: string) {
|
2021-11-09 16:32:15 +00:00
|
|
|
if (this.isEmpty(s)) return "";
|
2024-01-12 07:33:24 +00:00
|
|
|
let e = "";
|
|
|
|
for (let i = 0; i < s.length; i = +1) {
|
|
|
|
let c = s.charAt(i);
|
2021-11-09 16:32:15 +00:00
|
|
|
if (c < " " || c > "~") {
|
2024-01-12 07:33:24 +00:00
|
|
|
c = `&#${c.charCodeAt(0)};`;
|
2021-11-09 16:32:15 +00:00
|
|
|
}
|
|
|
|
e += c;
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
htmlDecode(s: string) {
|
|
|
|
let c;
|
|
|
|
let m;
|
|
|
|
let d = s;
|
2021-11-09 16:32:15 +00:00
|
|
|
if (this.isEmpty(d)) return "";
|
|
|
|
d = this.HTML2Numerical(d);
|
|
|
|
const arr = d.match(/&#[0-9]{1,5};/g);
|
|
|
|
if (arr != null) {
|
2024-01-12 07:33:24 +00:00
|
|
|
for (let x = 0; x < arr.length; x += 1) {
|
2021-11-09 16:32:15 +00:00
|
|
|
m = arr[x];
|
2024-01-12 07:33:24 +00:00
|
|
|
c = +m.substring(2, m.length - 1);
|
2021-11-09 16:32:15 +00:00
|
|
|
if (c >= -32768 && c <= 65535) {
|
|
|
|
d = d.replace(m, String.fromCharCode(c));
|
|
|
|
} else {
|
|
|
|
d = d.replace(m, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return d;
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
htmlEncode(s: string, dbl: boolean) {
|
2021-11-09 16:32:15 +00:00
|
|
|
if (this.isEmpty(s)) return "";
|
2024-01-12 07:33:24 +00:00
|
|
|
dbl = dbl || false;
|
2021-11-09 16:32:15 +00:00
|
|
|
if (dbl) {
|
2024-01-12 07:33:24 +00:00
|
|
|
if (this.EncodeType === "numerical") {
|
2021-11-09 16:32:15 +00:00
|
|
|
s = s.replace(/&/g, "&");
|
|
|
|
} else {
|
|
|
|
s = s.replace(/&/g, "&");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s = this.XSSEncode(s, false);
|
2024-01-12 07:33:24 +00:00
|
|
|
if (this.EncodeType === "numerical" || !dbl) {
|
2021-11-09 16:32:15 +00:00
|
|
|
s = this.HTML2Numerical(s);
|
|
|
|
}
|
|
|
|
s = this.numEncode(s);
|
|
|
|
if (!dbl) {
|
|
|
|
s = s.replace(/&#/g, "##AMPHASH##");
|
2024-01-12 07:33:24 +00:00
|
|
|
if (this.EncodeType === "numerical") {
|
2021-11-09 16:32:15 +00:00
|
|
|
s = s.replace(/&/g, "&");
|
|
|
|
} else {
|
|
|
|
s = s.replace(/&/g, "&");
|
|
|
|
}
|
|
|
|
s = s.replace(/##AMPHASH##/g, "&#");
|
|
|
|
}
|
|
|
|
s = s.replace(/&#\d*([^\d;]|$)/g, "$1");
|
|
|
|
if (!dbl) {
|
|
|
|
s = this.correctEncoding(s);
|
|
|
|
}
|
2024-01-12 07:33:24 +00:00
|
|
|
if (this.EncodeType === "entity") {
|
2021-11-09 16:32:15 +00:00
|
|
|
s = this.NumericalToHTML(s);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
XSSEncode(s: string, en: boolean) {
|
2021-11-09 16:32:15 +00:00
|
|
|
if (!this.isEmpty(s)) {
|
|
|
|
en = en || true;
|
|
|
|
if (en) {
|
|
|
|
s = s.replace(/\'/g, "'");
|
|
|
|
s = s.replace(/\"/g, """);
|
|
|
|
s = s.replace(/</g, "<");
|
|
|
|
s = s.replace(/>/g, ">");
|
|
|
|
} else {
|
|
|
|
s = s.replace(/\'/g, "'");
|
|
|
|
s = s.replace(/\"/g, """);
|
|
|
|
s = s.replace(/</g, "<");
|
|
|
|
s = s.replace(/>/g, ">");
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
2024-01-12 07:33:24 +00:00
|
|
|
|
|
|
|
return "";
|
2021-11-09 16:32:15 +00:00
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
hasEncoded(s: string) {
|
2021-11-09 16:32:15 +00:00
|
|
|
if (/&#[0-9]{1,5};/g.test(s)) {
|
|
|
|
return true;
|
2024-01-12 07:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (/&[A-Z]{2,6};/gi.test(s)) {
|
2021-11-09 16:32:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2024-01-12 07:33:24 +00:00
|
|
|
|
|
|
|
return false;
|
2021-11-09 16:32:15 +00:00
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
stripUnicode(s: string) {
|
2021-11-09 16:32:15 +00:00
|
|
|
return s.replace(/[^\x20-\x7E]/g, "");
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
correctEncoding(s: string) {
|
2021-11-09 16:32:15 +00:00
|
|
|
return s.replace(/(&)(amp;)+/, "$1");
|
|
|
|
},
|
2024-01-12 07:33:24 +00:00
|
|
|
swapArrayVals(s: string, arr1: string[], arr2: string[]) {
|
2021-11-09 16:32:15 +00:00
|
|
|
if (this.isEmpty(s)) return "";
|
2024-01-12 07:33:24 +00:00
|
|
|
let re;
|
2021-11-09 16:32:15 +00:00
|
|
|
if (arr1 && arr2) {
|
2024-01-12 07:33:24 +00:00
|
|
|
if (arr1.length === arr2.length) {
|
|
|
|
for (let x = 0, i = arr1.length; x < i; x += 1) {
|
2021-11-09 16:32:15 +00:00
|
|
|
re = new RegExp(arr1[x], "g");
|
|
|
|
s = s.replace(re, arr2[x]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
},
|
|
|
|
};
|