Skip to content

compiler: fix escape sequences in paths - #12802

Open
ogoffart wants to merge 2 commits into
masterfrom
olivier/fix-#12798
Open

compiler: fix escape sequences in paths#12802
ogoffart wants to merge 2 commits into
masterfrom
olivier/fix-#12798

Conversation

@ogoffart

@ogoffart ogoffart commented Aug 6, 2026

Copy link
Copy Markdown
Member

Fixes: #12798

@ogoffart
ogoffart requested a review from tronical August 6, 2026 11:00
The path in an import is a string literal, so decode its escape sequences
instead of only stripping the quotes. `import { X } from "b\u{61}r.slint"`
now loads bar.slint, and Unicode or emoji file names work whether written
literally or as a `\u{...}` escape. The path must stay a plain literal, so
`\{...}` interpolation is still rejected.
pathutils::join() documents that it returns a clean_path() result, but the
early returns handed absolute paths back verbatim. A path with a backslash
was then registered under the raw string yet looked up under the cleaned
one, so get_document() missed and the type loader panicked.

Fixes: #12798
@ogoffart
ogoffart force-pushed the olivier/fix-#12798 branch from b213938 to 25e1f37 Compare August 6, 2026 11:11

Because the path is a string literal, the [escape sequences](../../property-types/strings/#string) `\"`, `\\`, `\n`, and `\u{...}` are decoded in the file name.
For example, `"caf\u{e9}.slint"` and `"café.slint"` name the same file.
String interpolation (`\{...}`) isn't available: the path must be a constant.

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.

Doesn't this paragraph need spec ids?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it is not in Slint SC. Should it? I guess it could.

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.

Seems like it should be :)

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.

panic when importing file with quote

2 participants