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

interpolateName: Hash regex incorrectly mingles other values into the hash value #136

Closed
techjoshua opened this issue Dec 26, 2018 · 2 comments · Fixed by #137
Closed

interpolateName: Hash regex incorrectly mingles other values into the hash value #136

techjoshua opened this issue Dec 26, 2018 · 2 comments · Fixed by #137

Comments

@techjoshua
Copy link

/\[(?:([^:]+):)?(?:hash||contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,

Regex fails for values like: [name].[md5:hash:base64:20].[ext]...
getHashDigest() is called with a hashType = 'name].[md5'

I suggest changing the regex to exclude closing brackets, like:

/\[(?:([^:\]]+):)?(?:hash||contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi
          ^^ added
@webschik
Copy link
Contributor

Another test case with CSS Module names:

v1.1.x version:

/\[(?:(\w+):)?hash(?::([a-z]+\d*))?(?::(\d+))?\]/ig.exec('[name]__modalTitle___[sha1:hash:hex:4]')
...
[
0: "[sha1:hash:hex:4]"
1: "sha1"
2: "hex"
3: "4"
]

v1.2.x version:

/\[(?:([^:]+):)?(?:hash||contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi.exec('[name]__modalTitle___[sha1:hash:hex:4]')
...
[
0: "[name]__modalTitle___[sha1:hash:hex:4]"
1: "name]__modalTitle___[sha1"
2: "hex"
3: "4"
]

@alexander-akait
Copy link
Member

Fixed in https://github.com/webpack/loader-utils/releases/tag/v1.2.2

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

Successfully merging a pull request may close this issue.

3 participants