Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: prevent numeric-only content hashes in filename templates#19897

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mduclehcm wants to merge2 commits intowebpack:main
base:main
Choose a base branch
Loading
frommduclehcm:patch-01

Conversation

@mduclehcm
Copy link

Problem

When using webpack filename templates with length-limited content hashes (e.g.,[contenthash:12]), the hash truncation was performed using simple string slicing (hash.slice(0, length)). This could result in truncated hashes that contain only numeric characters, which can cause issues when RealContentHashPlugin try to replace the content hash with real content hash.#14058

Root Cause

ThehashLength function inTemplatedPathPlugin.js used simple string slicing:

// Before: Could produce numeric-only hashesresult=length ?hash.slice(0,length) :hash;

When a hash like"123456789101acbdefgh" was truncated to 12 characters, it could produce"123456789101" - a purely numeric string. This creates problems forRealContentHashPlugin which expects to find and replace these hash patterns.

Fix

Use existingnonNumericOnlyHash utility function that webpack already uses internally:

@linux-foundation-easycla
Copy link

linux-foundation-easyclabot commentedSep 10, 2025
edited
Loading

CLA Signed

The committers listed above are authorized under a signed CLA.

@alexander-akait
Copy link
Member

Please add a test case

@mduclehcm
Copy link
Author

Please add a test case

Sorry, but I really don't know how to test this case. It's hard to create a mock module that has a numeric-only content hash. Could you please give me some advice?

@alexander-akait
Copy link
Member

@mduclehcm You can mock some webpack function or create a plugin which generate only numbers

mduclehcm reacted with thumbs up emoji

@mduclehcm
Copy link
Author

mduclehcm commentedSep 19, 2025
edited
Loading

@mduclehcm You can mock some webpack function or create a plugin which generate only numbers

I've added the unit test! Could you take another look at the PR when you get a chance?

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@mduclehcm@alexander-akait

[8]ページ先頭

©2009-2025 Movatter.jp