Skip to content

fix(Authoring): import assets whose file names contain parentheses - #367

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

When steps are imported from another unit, getAssetFileNames searched the serialized steps with a single regex whose name class has no parentheses and no CJK characters. A name such as diagram (1).png was not found, so the asset was not copied into the target unit and the imported step showed a broken image. Because the regex ran over the whole JSON text, a match could also start at the closing quote of one string and run into the next, producing names like ,"b.png.

Each string value of the steps JSON is now handled on its own. A value that is itself a relative file name is taken whole; any other value, such as HTML, is searched with the same pattern the client's replaceAssetPaths uses, case-insensitively. Text that is not JSON is still searched as a whole.

Renaming an imported asset used replaceAll, which treats the file name as a regex: a name with parentheses silently matched nothing and an unbalanced parenthesis threw PatternSyntaxException. The rename is now a literal replace and also covers the %20-encoded form, since names are found after decoding %20.

The client side of the same problem is WISE-Community/WISE-Client#2365.

Testing: six new tests in AuthorAPIControllerTest. On develop four fail and one errors; the sixth, which checks that parentheses in HTML text do not swallow the next image, passes on both and guards against widening the embedded pattern. The existing %20 test still passes.

When steps are imported from another unit, getAssetFileNames searched the
serialized steps with one regex whose name class has no parentheses and no
CJK characters. A name such as "diagram (1).png" was not found, so the
asset was not copied, and a match could start at the closing quote of one
JSON string and run into the next, yielding names like ',"b.png'.

Each string value of the steps JSON is now handled on its own: a value
that is itself a relative file name is taken whole, and any other value is
searched with the same pattern the client uses, case-insensitively.

Renaming an imported asset used replaceAll, which treats the file name as
a regex: a name with parentheses silently matched nothing and an
unbalanced parenthesis threw PatternSyntaxException. The rename is now a
literal replace and also covers the %20-encoded form of the name.
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