1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Mobile: Rich Text Editor: Avoid rendering links with unknown protocols (#12943)

Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
Henry Heino
2025-08-26 00:49:26 -07:00
committed by GitHub
parent ac05b7d389
commit c99780db1b
3 changed files with 71 additions and 5 deletions

View File

@@ -10,6 +10,24 @@ import convertHtmlToMarkdown from './convertHtmlToMarkdown';
import { ExportedWebViewGlobals as MarkdownEditorWebViewGlobals } from '../../markdownEditorBundle/types';
import { EditorEventType } from '@joplin/editor/events';
const postprocessHtml = (html: HTMLElement) => {
// Fix resource URLs
const resources = html.querySelectorAll<HTMLImageElement>('img[data-resource-id]');
for (const resource of resources) {
const resourceId = resource.getAttribute('data-resource-id');
resource.src = `:/${resourceId}`;
}
// Restore HREFs
const links = html.querySelectorAll<HTMLAnchorElement>('a[href="#"][data-original-href]');
for (const link of links) {
link.href = link.getAttribute('data-original-href');
link.removeAttribute('data-original-href');
}
return html;
};
const wrapHtmlForMarkdownConversion = (html: HTMLElement) => {
// Add a container element -- when converting to HTML, Turndown
// sometimes doesn't process the toplevel element in the same way