Skip to content

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

Merged
hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:fix/asset-file-names-with-parentheses
Nov 13, 2026
Merged

hirokiterashima merged 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.

@hirokiterashima hirokiterashima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This doesn't fix an existing issue with HTML strings containing parenthesis, like <img src="image (1).png">. We can handle this separately.

@hirokiterashima
hirokiterashima merged commit bed4365 into WISE-Community:develop Nov 13, 2026
3 of 4 checks passed
@hirokiterashima

Copy link
Copy Markdown
Member

🎉 This PR is included in version 5.251.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Isaries

Isaries commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The HTML case is handled in #2373.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants