storybook
storybook copied to clipboard
[Bug]: "Invalid regular expression" in process.env causes build-storybook to crash
Describe the bug
It is possible to have values in process.env
that cause the build-storybook
command to crash because template.ts
assumes that the value will be a valid regex.
This code in node_modules\@storybook\manager-webpack5\dist\cjs\presets\manager-preset.js
has this code:
case 9:
template = _context.sent;
_context.next = 12;
return presets.apply('managerHead', (0, _coreCommon.getManagerHeadTemplate)(configDir, process.env));
which directly passes process.env
to getManagerHeadTemplate
, which in turn passes those values directly to interpolate
.
To Reproduce
We had some markdown content similar to [link](https://github.com/?_a)
which was in an environment variable which somehow led to the error:
SyntaxError: InvalidRegularExpression: /%[here](https://github.com?_a%/: Unterminated group
I don't know how the trailing )
was lost but either way, even if we have something that appears to be an invalid regex in our environment variables, we don't expect build_storybook
to fail.
System
Windows
Additional context
No response