Skip to content

fix(ProjectService): Inject asset paths per string so file names with parentheses resolve - #2365

Open
Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/asset-file-names-with-parentheses
Open

Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/asset-file-names-with-parentheses

Conversation

@Isaries

@Isaries Isaries commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

injectAssetPaths ran the replaceAssetPaths regex over the whole content serialized as JSON. The regex's name class has no parentheses, and its leading [^:][^/]?[^/]? lets a match start at the closing quote of one string and run into the next. Content such as ["image (1).png","heart.png"] got the prefix inserted outside any string, JSON.parse threw, and the component failed to render.

Each string value is now handled on its own. A value that is nothing but a relative file name gets the prefix directly; this accepts parentheses, full-width brackets, kana and hangul, but not sentence punctuation, so prose that ends in a file name is not mistaken for one. Other strings, such as HTML, go through the original regex, except that a match closing on a different quote than it opened with is left alone instead of having a quote rewritten. For matches whose quotes agree the output is unchanged. Object keys are no longer rewritten.

The server side of the same problem, importing such assets between units, is WISE-Community/WISE-API#367.

Testing: seven new injectAssetPaths() tests in projectService.spec.ts, covering parentheses, CJK punctuation, a name the pattern cannot match followed by one it can, mismatched quotes, HTML text with parentheses, prose and absolute paths. Four fail on develop; the other three guard behaviour that develop already gets right. The existing replaceAssetPaths tests pass unchanged.

… parentheses resolve

injectAssetPaths ran the replaceAssetPaths regex over the whole content
serialized as JSON. The regex's name class has no parentheses, and its
leading [^:][^/]?[^/]? lets a match start at the closing quote of one
string and run into the next, so content such as
["image (1).png","heart.png"] had the prefix inserted outside any string
and JSON.parse threw.

Each string value is now handled on its own. A value that is nothing but
a relative file name gets the prefix directly, which accepts parentheses,
full-width brackets, kana and hangul but not sentence punctuation. Other
strings go through the original regex, except that a match closing on a
different quote than it opened with is left alone instead of having a
quote rewritten.
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 this pull request may close these issues.

1 participant