- Issue created by @Grevil
- 🇩🇪Germany Anybody Porta Westfalica
I agree. But we should first discuss how to solve this best, before starting any implementation, please.
- Assigned to Anybody
- 🇮🇳India sj_baradia
Hi @anybody, we can use
\Drupal::service ('extension.list.module')->getPath('my_markdown_module)
to get the relative path of the module.We can define it at the top of the php file or globally to use it according to our need.
- 🇩🇪Germany Grevil
ChatGPT thinks this is the right regex to match the image url inside a markdown image decleration, feel free to test it out!
/!\[.*?\]\((.*?)\)/
- 🇩🇪Germany Anybody Porta Westfalica
Ok I think I first need to have a look here and eventually discuss this finally. Let's do it, when it's needed.
- 🇩🇪Germany lrwebks Porta Westfalica
If this is a relative URL NOT starting with / […] leave untouched
I think this case should also be prefixed with the module path, as this would still give access to more folders than it should (security).
/img.png
could easily be something like/my-secret-module/secrets.png
, which the markdown should not have access to.In my opinion the best approach to this would be to only allow relative URLs in one of these forms as these can all safely be redirected to the path within the module:
image.png
orfolder/image.webp
/image.jpg
or/folder/image.svg
./path.jpeg
or./folder/image.jfif