feat: Add file type validation and sanitize markdown input in adventure components

This commit is contained in:
Sean Morley
2025-03-15 12:29:12 -04:00
parent 50a732b4d7
commit 7fbcf170d0
6 changed files with 84 additions and 8 deletions

View File

@@ -7,7 +7,7 @@
import { DefaultMarker, MapLibre, Popup, GeoJSON, LineLayer } from 'svelte-maplibre';
import { t } from 'svelte-i18n';
import { marked } from 'marked'; // Import the markdown parser
import DOMPurify from 'dompurify';
// @ts-ignore
import toGeoJSON from '@mapbox/togeojson';
@@ -16,7 +16,7 @@
let geojson: any;
const renderMarkdown = (markdown: string) => {
return marked(markdown);
return marked(markdown) as string;
};
async function getGpxFiles() {
@@ -369,7 +369,7 @@
<article
class="prose overflow-auto h-full max-w-full p-4 border border-base-300 rounded-lg"
>
{@html renderMarkdown(adventure.description)}
{@html DOMPurify.sanitize(renderMarkdown(adventure.description))}
</article>
{/if}
</div>