Skip to content

fix(mdx-loader): replace image-size with measureImage hook - #12388

Open
kennym wants to merge 1 commit into
facebook:mainfrom
kennym:fix/mdx-loader-measure-image-hook
Open

fix(mdx-loader): replace image-size with measureImage hook#12388
kennym wants to merge 1 commit into
facebook:mainfrom
kennym:fix/mdx-loader-measure-image-hook

Conversation

@kennym

@kennym kennym commented Aug 25, 2026

Copy link
Copy Markdown

Pre-flight checklist

Motivation

@docusaurus/mdx-loader depends on archived image-size@^2.0.2 (CVE-2025-71329 / CVE-2025-71330). There is no published patched release.

#12235 replaced it with image-dimensions only. That drops SVG (unsupported by that library) and has no escape hatch for long-tail formats.

This draft follows the markdown.hooks pattern from #11283:

  • Add optional siteConfig.markdown.hooks.measureImage({ imagePath }).
  • Default: SVG via a small local width/height/viewBox parser; raster via image-dimensions; on failure log and return null (no throw/catch).
  • Remove image-size completely.
  • Document that BMP/ICO/TIFF/PSD/JXL/ICNS are no longer auto-measured unless the site provides a custom hook.

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)
  • New coverage: SVG attributes, viewBox fallback, measureImage override, config validation
  • Existing transformImage snapshots still emit width/height for PNG fixtures
  • Showcase user.test.ts and admin/scripts/resizeImage.js no longer import image-size

Test 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

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.
@meta-cla

meta-cla Bot commented Aug 25, 2026

Copy link
Copy Markdown

Hi @kennym!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedimage-dimensions@​2.5.110010010084100

View full report

@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 6f97dc4
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a8d9963acc50100086baaa6
😎 Deploy Preview https://deploy-preview-12388--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla

meta-cla Bot commented Aug 25, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Aug 25, 2026
@kennym
kennym marked this pull request as ready for review August 25, 2026 13:56
@kennym

kennym commented Aug 26, 2026

Copy link
Copy Markdown
Author

@slorber @Josh-Cena any feedback here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace unmaintained dependency image-size with active CVEs (CVSS 7.5)

1 participant