Repository navigation
USDAParser: Keep comment markers inside strings and asset paths. - #35182
Merged
Merged
Conversation
_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.
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. |
Owner
Done! π |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: -
Description
USDAParserstrips 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"matchesand none of the prims that follow it._stripInlineComment()tracks"and'strings but not asset paths, soasset 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.jsgets 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.