Skip to content

Fix Windows extrn_files cache failure on embedded-URL paths (#68273)#69423

Open
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68273
Open

Fix Windows extrn_files cache failure on embedded-URL paths (#68273)#69423
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68273

Conversation

@dwoz

@dwoz dwoz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Sanitises the URL-path-derived portion of the extrn_files cache target on
Windows so that a remote URL whose path embeds another URL (e.g. an
archive.org snapshot of an https://... resource) no longer produces a
cache path containing characters illegal in a Windows file name.

What issues does this PR fix or reference?

Fixes #68273

Previous Behavior

file.managed of a remote source like
https://web.archive.org/web/20190720195601/https://download.microsoft.com/.../VCForPython27.msi
failed on Windows with:

Failed to cache https://web.archive.org/...: [WinError 123] The filename,
directory name, or volume label syntax is incorrect:
'C:\ProgramData\Salt Project\Salt\var\cache\salt\minion\extrn_files\base\web.archive.org\web\20190720195601\https:'

Client._extrn_path already ran the netloc through
salt.utils.path.sanitize_win_path on Windows, but the URL-path portion
(which becomes the rest of the cache path) was used unmodified. Any URL
whose path contained < > : | ? * therefore produced an invalid Windows
path and the cache write failed before the file could be downloaded.

New Behavior

On Windows, Client._extrn_path now runs the file_name portion through
sanitize_win_path the same way the netloc already is, so the embedded-URL
URL above caches to a syntactically valid path and file.managed succeeds.
Behaviour on non-Windows platforms is unchanged.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

Yes

@dwoz dwoz requested a review from a team as a code owner June 12, 2026 00:10
@dwoz dwoz added this to the Sulphur v3006.26 milestone Jun 12, 2026
@dwoz dwoz added the test:full Run the full test suite label Jun 12, 2026
@dwoz dwoz force-pushed the fix/issue-68273 branch from 424775c to 60e0d91 Compare June 12, 2026 00:11
`fileclient.Client._extrn_path` sanitised the URL's netloc on Windows so
that characters illegal in a Windows file name (`< > : | ? *`) could not
break the cache path, but applied no equivalent sanitisation to the
URL-path-derived portion. A remote URL whose path embeds another URL
(e.g. an archive.org snapshot of an `https://download.microsoft.com/...`
resource) therefore produced a path containing `https:` and
`file.managed` failed with `WinError 123` before the file could be
written.

Run `sanitize_win_path` on the file_name component too on Windows so the
extrn_files write target is always a syntactically valid Windows path.

Fixes saltstack#68273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant