fix(mdx-loader): replace image-size with measureImage hook - #12388
Conversation
image-size is archived and carries unpatched DoS CVEs. Measure SVG locally and raster formats via image-dimensions, with an optional markdown.hooks.measureImage escape hatch.
|
Hi @kennym! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@slorber @Josh-Cena any feedback here? |
Pre-flight checklist
Motivation
@docusaurus/mdx-loaderdepends on archivedimage-size@^2.0.2(CVE-2025-71329 / CVE-2025-71330). There is no published patched release.#12235 replaced it with
image-dimensionsonly. That drops SVG (unsupported by that library) and has no escape hatch for long-tail formats.This draft follows the
markdown.hookspattern from #11283:siteConfig.markdown.hooks.measureImage({ imagePath }).width/height/viewBoxparser; raster viaimage-dimensions; on failure log and returnnull(no throw/catch).image-sizecompletely.Question for maintainers: is preserving SVG enough for a 3.x
fix, or is dropping the long-tail formats v4-only?Test Plan
pnpm exec vitest run packages/docusaurus-mdx-loader/src/remark/transformImage packages/docusaurus/src/server/__tests__/configValidation.test.ts(Node 24)measureImageoverride, config validationuser.test.tsandadmin/scripts/resizeImage.jsno longer importimage-sizeTest links
Deploy preview: https://deploy-preview-12388--docusaurus-2.netlify.app/
Docs:
website/docs/api/docusaurus.config.js.mdx(markdown.hooks.measureImage)Related issues/PRs
siteConfig.markdown.hooks, deprecatesiteConfig.onBrokenMarkdownLinks#11283