diff --git a/src/services/html_sanitizer.ts b/src/services/html_sanitizer.ts index c0ebaf152..11bf9e42d 100644 --- a/src/services/html_sanitizer.ts +++ b/src/services/html_sanitizer.ts @@ -175,8 +175,12 @@ function sanitize(dirtyHtml: string) { border: [ /^\s*\d+(?:px|em|%)\s*(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)\s*(#(0x)?[0-9a-fA-F]+|rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\))\s*$/ ] + }, + col: { + width: sizeRegex } }, + selfClosing: [ "img", "br", "hr", "area", "base", "basefont", "input", "link", "meta", "col" ], allowedSchemes: ALLOWED_PROTOCOLS, nonTextTags: ["head"], transformTags diff --git a/src/services/import/markdown.spec.ts b/src/services/import/markdown.spec.ts index f6b541163..fd2de9912 100644 --- a/src/services/import/markdown.spec.ts +++ b/src/services/import/markdown.spec.ts @@ -197,4 +197,9 @@ second line 2
  1. Hello
  2. { + const html = /*html*/`
       
    1Go to any location on openstreetmap.org and right click to bring up the context menu. Select the “Show address” item.
    2The address will be visible in the top-left of the screen, in the place of the search bar.    

    Select the coordinates and copy them into the clipboard.
    3Simply paste the value inside the text box into the #geolocation attribute of a child note of the map and then it should be displayed on the map.
    `; + expect(markdownService.renderToHtml(html, "Title")).toStrictEqual(html); + }); + }); diff --git a/src/services/import/markdown.ts b/src/services/import/markdown.ts index a4b541979..e9554c2f5 100644 --- a/src/services/import/markdown.ts +++ b/src/services/import/markdown.ts @@ -100,7 +100,7 @@ function renderToHtml(content: string, title: string) { html = htmlSanitizer.sanitize(html); // Add a trailing semicolon to CSS styles. - html = html.replaceAll(/(<(img|figure).*?style=".*?)"/g, "$1;\""); + html = html.replaceAll(/(<(img|figure|col).*?style=".*?)"/g, "$1;\""); // Remove slash for self-closing tags to match CKEditor's approach. html = html.replace(/<(\w+)([^>]*)\s+\/>/g, "<$1$2>");