mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Fixes #10274: old.reddit pages are not saved correctly as HTML by the Web Clipper
This commit is contained in:
parent
a5f118bc26
commit
b1a669de01
1
packages/app-cli/tests/md_to_html/sanitize_19.html
Normal file
1
packages/app-cli/tests/md_to_html/sanitize_19.html
Normal file
@ -0,0 +1 @@
|
||||
<div><span class="jop-noMdConv">This is a comment we would like to keep</div></form>
|
1
packages/app-cli/tests/md_to_html/sanitize_19.md
Normal file
1
packages/app-cli/tests/md_to_html/sanitize_19.md
Normal file
@ -0,0 +1 @@
|
||||
<form><span>This is a comment we would like to keep</span></form>
|
@ -223,7 +223,7 @@ class HtmlUtils {
|
||||
// to disable them. SVG graphics are still supported via the IMG tag.
|
||||
const disallowedTags = [
|
||||
'script', 'iframe', 'frameset', 'frame', 'object', 'base',
|
||||
'embed', 'link', 'meta', 'noscript', 'button', 'form',
|
||||
'embed', 'link', 'meta', 'noscript', 'button',
|
||||
'input', 'select', 'textarea', 'option', 'optgroup',
|
||||
'svg',
|
||||
|
||||
@ -233,6 +233,14 @@ class HtmlUtils {
|
||||
'map', 'area',
|
||||
];
|
||||
|
||||
// Certain tags should not be rendered, however unlike for the disallowed tags, we want to
|
||||
// keep their content. For example the FORM tag may sometimes wrap relevant content so we
|
||||
// want to keep that content, but we don't want to keep the FORM tag itself. In that case we
|
||||
// simply replace it with a DIV tag.
|
||||
const replaceWithDivTags = [
|
||||
'form',
|
||||
];
|
||||
|
||||
const parser = new htmlparser2.Parser({
|
||||
|
||||
onopentag: (name: string, attrs: Record<string, string>) => {
|
||||
@ -249,6 +257,11 @@ class HtmlUtils {
|
||||
|
||||
if (disallowedTagDepth) return;
|
||||
|
||||
if (replaceWithDivTags.includes(currentTag())) {
|
||||
output.push('<div>');
|
||||
return;
|
||||
}
|
||||
|
||||
attrs = { ...attrs };
|
||||
|
||||
// Remove all the attributes that start with "on", which
|
||||
@ -342,6 +355,11 @@ class HtmlUtils {
|
||||
|
||||
if (disallowedTagDepth) return;
|
||||
|
||||
if (replaceWithDivTags.includes(currentTag())) {
|
||||
output.push('</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSelfClosingTag(name)) return;
|
||||
output.push(`</${name}>`);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user