Skip to content

Fix folder path escaping for names containing slashes - #1084

Merged
ako merged 1 commit into
mainfrom
claude/modest-mayer-7s1w4m
Oct 9, 2026
Merged

ako merged 1 commit into
mainfrom
claude/modest-mayer-7s1w4m

Conversation

@ako

@ako ako commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes issue mendixlabs#1367 where marketplace update --save-edits followed by exec corrupted folder paths containing literal / characters in folder names. The issue occurred because folder names were joined with bare / separators, making it impossible to distinguish between a single folder named "Private - String en/de-cryption" and two nested folders "Private - String en" and "de-cryption".

Changes

  • New package mdl/folderpath: Implements escaping and unescaping of folder path segments

    • Join(): Renders folder names as a path, escaping / as \/ and \ as \\ within names
    • Escape(): Escapes a single folder name
    • Split(): Parses a path back into folder names, treating \/ and \\ as escaped characters
    • Lenient reading: backslash before any character other than / or \ is kept literal, preserving backward compatibility with hand-written paths
  • Updated folder path handling across executor:

    • hierarchy.go: BuildFolderPath() now uses folderpath.Join() to escape names
    • cmd_folders.go, cmd_microflows_build.go, cmd_pages_builder.go, helpers.go: Updated to use folderpath.Split() instead of naive strings.Split()
    • cmd_constants.go: Refactored to use new describeFolderClause() helper
    • document_placement.go: describeFolderClause() now uses mdlQuote() for proper string literal quoting
  • CLI integration (cmd/mxcli/project_tree.go):

    • getOrCreateFolder() now escapes folder names when building paths
    • splitFolderPath() delegates to folderpath.Split()
  • Documentation (docs-site/src/reference/organization/create-folder.md):

    • Added section explaining escaping syntax with example
  • Test coverage:

    • mdl/folderpath/folderpath_test.go: Round-trip tests, backward compatibility, and edge cases
    • mdl/executor/folder_path_slash_test.go: Integration test verifying describe→exec round-trip with slashes in folder names
    • mdl-examples/bug-tests/1367-folder-name-containing-slash.mdl: Reproducible test case

Implementation Details

The escape mechanism uses backslash (\) as the escape character:

  • \/ inside a segment represents a literal /
  • \\ inside a segment represents a literal \
  • A backslash before any other character is treated as a literal backslash (backward compatible)

This approach works across both MDL string literal quoting rules because \/ is unambiguous under both language versions. The escaping is at the path level, not the string literal level, so DESCRIBE output is properly round-trippable.

https://claude.ai/code/session_01Cj4DQ8PRitHdtF3q8pVVBQ

Studio Pro allows '/' in a folder name, but BuildFolderPath joined names
with a bare '/' and every folder-path walker split on it. A constant in
`Private - String en/de-cryption` > `Apis` was described as
folder 'Private - String en/de-cryption/Apis', and replaying the
--save-edits output with exec filed it three folders deep, exit 0.

New package mdl/folderpath: a '/' in a segment is written `\/`, a '\'
`\\`; Split is lenient (a backslash before anything else stays literal),
so existing paths keep their meaning. BuildFolderPath joins with it,
resolveFolder / findFolderByPath / lookupFolder / the page builder and
the project tree split with it. Describers that wrote `folder '%s'`
unquoted now use mdlQuote, so the escape (and apostrophes) survive both
string rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cj4DQ8PRitHdtF3q8pVVBQ
@ako
ako merged commit d2c5f44 into main Oct 9, 2026
33 checks passed
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.

2 participants