tokenshift / obsidian-page-gallery

Generates a gallery based on selected page contents.
MIT License
64 stars 2 forks source link

Images with single quotes in their paths don't load. #57

Closed tokenshift closed 8 months ago

tokenshift commented 8 months ago

Create a page with an image that has a path like /John Smith's Images/some_image.jpg. That results in an image path like app://some-app-specific-gobbledegook/John%20Smith%20's%20Images/some_image.jpg. Spaces (and many other special characters) are escaped already in what App.vault.getResourcePath returns; but single quotes aren't.

This is then used to generate the style:background-image for the page gallery tile:

style:background-image={`url('${imageSrc.replace('\'', '%27')}')`}

This is breaking due to the single quote in the path. The HTML that Svelte generates doesn't have the style element added at all, and the gallery tile shows up blank/empty as a result:

image

Fix: escape single quotes (or find a way to pass this URL to Svelte and let it handle escaping it properly).