jq79 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jq79.cjs +8 -8
- package/dist/jq79.cjs.map +1 -1
- package/dist/jq79.global.js +8 -8
- package/dist/jq79.global.js.map +1 -1
- package/dist/jq79.js +12 -12
- package/dist/jq79.js.map +1 -1
- package/package.json +1 -1
- package/src/dom.ts +8 -2
package/package.json
CHANGED
package/src/dom.ts
CHANGED
|
@@ -173,10 +173,16 @@ function sanitizeNode(node: HTMLElement, depth: number, allowUrl?: AllowUrl): HT
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export function sanitizeHTML(html: string, options?: SanitizeOptions): string {
|
|
176
|
-
|
|
176
|
+
// parsear con <template> en vez de con DOMParser: el contenido de un template
|
|
177
|
+
// es un documento inerte igual (ni scripts ni imágenes se ejecutan al asignar
|
|
178
|
+
// innerHTML), pero el parseo de fragmento conserva el espacio en blanco inicial
|
|
179
|
+
// que el modo "before body" de un documento completo descartaría - así una
|
|
180
|
+
// primera línea indentada (un diff, un <pre>) llega con su sangría intacta
|
|
181
|
+
const template = document.createElement('template');
|
|
182
|
+
template.innerHTML = html;
|
|
177
183
|
const container = document.createElement('div');
|
|
178
184
|
|
|
179
|
-
appendSanitizedChildren(
|
|
185
|
+
appendSanitizedChildren(template.content, container, 0, options?.allowUrl);
|
|
180
186
|
|
|
181
187
|
return container.innerHTML;
|
|
182
188
|
}
|