| 2480 | } |
| 2481 | |
| 2482 | const escapeAttribute = (s: string): string => { |
| 2483 | const first = s.search(attributeSpecials) |
| 2484 | if (first === -1) return s |
| 2485 | let out = "" |
| 2486 | let last = 0 |
| 2487 | for (let i = first; i < s.length; i++) { |
| 2488 | const c = s.charCodeAt(i) |
| 2489 | const escaped = c === AMPERSAND ? |
| 2490 | "&" : |
| 2491 | c === LT ? |
| 2492 | "<" : |
| 2493 | c === DQUOTE ? |
| 2494 | """ : |
| 2495 | c === TAB ? |
| 2496 | "	" : |
| 2497 | c === LF ? |
| 2498 | " " : |
| 2499 | c === CR ? |
| 2500 | " " : |
| 2501 | undefined |
| 2502 | if (escaped !== undefined) { |
| 2503 | out += s.slice(last, i) + escaped |
| 2504 | last = i + 1 |
| 2505 | } |
| 2506 | } |
| 2507 | return out + s.slice(last) |
| 2508 | } |
| 2509 | |
| 2510 | const checkChars = (what: string, s: string): void => { |
| 2511 | const invalid = searchInvalid(s) |