Skip to content

USDAParser: Keep comment markers inside strings and asset paths. - #35182

Merged
Mugen87 merged 4 commits into
mrdoob:devfrom
L4XB:usdaparser-comments-in-literals
Oct 23, 2026
Merged

Mugen87 merged 4 commits into
mrdoob:devfrom
L4XB:usdaparser-comments-in-literals

Conversation

@L4XB

@L4XB L4XB commented Oct 23, 2026

Copy link
Copy Markdown

Related issue: -

Description

USDAParser strips comments before it parses, but it does not know where strings and asset paths are:

  • _stripBlockComments() removes every /* ... */ span. If a string or asset path holds /* with no later */, everything from there to the end of the file is gone. string note = "matches /*.usd" leaves "matches and none of the prims that follow it.
  • _stripInlineComment() tracks " and ' strings but not asset paths, so asset texture = @./textures/wood#1.png@ becomes @./textures/wood.

In the OpenUSD text grammar (pxr/usd/sdf/textFileFormatParser.h), #, // and /* */ comments appear only between tokens. An asset reference @...@ may hold any character except @, and @@@...@@@ may hold @ too.

_stripBlockComments() now copies strings ('...', "...", '''...''', """..."""), asset paths (@...@, @@@...@@@) and # comments unchanged. It still uses the same indexOf-and-slice scan, without per-character string building. A small _literalEnd() helper finds the end of a literal. An unclosed single-line string or asset path ends at its line. _stripInlineComment() skips asset paths with the same helper.

USDLoader.tests.js gets three assertions in the block-comment test: a string, an asset path or triple-quoted string, and an apostrophe inside a # comment. A new test checks that the string and the asset path keep their full value and that the prim after them is still read. Both fail with the current code. ESLint passes on the changed files.

_stripBlockComments() removed every /* ... */ span, so a string or asset path holding /* without a later */ cut off the rest of the file. _stripInlineComment() did not know asset paths, so @./wood#1.png@ lost everything from the #. Both now skip strings and asset paths, as the USD text grammar reads comments only between tokens.
@Mugen87

Mugen87 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

@mrdoob Can you please block this user? It's another AI spammer.

Most of these PRs fix nits that are irrelevant for normal usage. I think it's better if we only apply such fixes if a real-world use case actually hits it.

@Mugen87 Mugen87 added this to the r187 milestone Oct 23, 2026
@Mugen87
Mugen87 merged commit ee6a50e into mrdoob:dev Oct 23, 2026
9 checks passed
@mrdoob

mrdoob commented Oct 23, 2026

Copy link
Copy Markdown
Owner

@mrdoob Can you please block this user? It's another AI spammer.

Most of these PRs fix nits that are irrelevant for normal usage. I think it's better if we only apply such fixes if a real-world use case actually hits it.

Done! πŸ‘Œ

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.

3 participants