(text: string)
| 158 | } |
| 159 | |
| 160 | function escapeHtml(text: string): string { |
| 161 | const escaped = (text || "").replace(/[&<>"']/g, (ch) => { |
| 162 | switch (ch) { |
| 163 | case "&": |
| 164 | return "&"; |
| 165 | case "<": |
| 166 | return "<"; |
| 167 | case ">": |
| 168 | return ">"; |
| 169 | case '"': |
| 170 | return """; |
| 171 | case "'": |
| 172 | return "'"; |
| 173 | default: |
| 174 | return ch; |
| 175 | } |
| 176 | }); |
| 177 | return escaped.replace(/\n/g, "<br>"); |
| 178 | } |
| 179 | |
| 180 | function escapeAttribute(text: string): string { |
| 181 | return (text || "").replace(/[&<>"]/g, (ch) => { |
no outgoing calls
no test coverage detected