Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image elements getting their src attribute removed #338

Open
protozoo opened this issue Feb 6, 2025 · 9 comments
Open

Image elements getting their src attribute removed #338

protozoo opened this issue Feb 6, 2025 · 9 comments

Comments

@protozoo
Copy link

protozoo commented Feb 6, 2025

I just ran npm install in a Nuxtjs project that was working fine earlier today, and then npm run dev to discover a new warn in the command output:

WARN [@nuxtjs/mdc] removing unsafe attribute: src="/path/to/my/image.png" 7:17:40 PM

I am using @nuxt/content and mdc in my content's markdown file as usual like this:

![image](/path/to/my/image.png)

After some unsuccessful googling I search nuxt/content's repo and this one and noticed a new mdc release was published just hours ago with a change that seems related.

So, is my problem caused (unintendedly) by this change? I checked my code and could not find anything wrong, but maybe I'm missing something? @lirantal perhaps you can help?

Thank you

@lirantal
Copy link
Contributor

lirantal commented Feb 7, 2025

Possibly, let me look into it.

@lirantal
Copy link
Contributor

lirantal commented Feb 7, 2025

Found the issue. Unfortunately there was no test case for it so I didn't catch it before in my XSS fix. The change in #339 should fix the regression (sorry about that!) as well as keep the XSS guards intact.

@protozoo
Copy link
Author

protozoo commented Feb 7, 2025

Thanks for the quick response @lirantal. I'm a Nuxt newbie, so I was not sure if what I said made much sense... happy to see we caught it early, and thanks for fixing it so fast.

@myurDev
Copy link

myurDev commented Feb 7, 2025

When using internal anchor links (e.g., [meta] (#meta-object)), Nuxt’s MDC (@nuxtjs/mdc) incorrectly removes them as unsafe attributes. This happens because new URL("#meta-object") throws an error, causing the function to return false, marking the link as unsafe. @lirantal

@lirantal
Copy link
Contributor

lirantal commented Feb 7, 2025

Yes @myurDev, my fix in the open PR #340 will address that. I'm waiting for @farnabaz to merge and then release it.

@acidjazz
Copy link

I can confirm this issue on my end as well

@lirantal
Copy link
Contributor

@acidjazz we released version 0.13.5 which fixes prior cases. Are you on this latest version? and if so, which types of links are not working for you? please provide reproducible code so I can test.

@acidjazz
Copy link

@acidjazz we released version 0.13.5 which fixes prior cases. Are you on this latest version? and if so, which types of links are not working for you? please provide reproducible code so I can test.

anywhere we point to an image we have stored in public/ via markdown - ill make sure were at 0.13.5 and then if it continues ill whip up a reproducible setup

@lirantal
Copy link
Contributor

@acidjazz cool, please check your version and let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants