bugger.
All challenges/Pythonmediumthe-path-that-starts-at-a-share-v1
THE INVESTIGATION

The path that starts at a share

A supposedly relative upload path becomes an absolute network-share path on another platform.

FilesystemSecurityCompatibility

What’s going wrong

A cross-platform upload path guard simulates a legacy Windows absolute-path check. It rejects ordinary absolute paths but misses the two-slash network-share form.

Input is an array of path strings. Normalize each with posixpath.normpath. Reject normalized paths containing a backslash, beginning with /, having a colon at index 1, equal to .., or beginning with ../. Otherwise return posixpath.join("uploads", normalized). Print the resulting array of strings or null. Dot and empty paths normalize to `.` and return `uploads/.`. This is a pure string operation; no file is opened. Preserve accepted relative paths.

Expected behavior

Only normalized relative paths can be joined under the upload prefix, independent of the legacy platform check.

Reproduction

01 UNC share bypass
["//server/share/file"]
[null]
02 Ordinary relative paths
["photo.png","images/a.png"]
["uploads/photo.png","uploads/images/a.png"]
03 Normalize relative path
["a/../b","./a"]
["uploads/b","uploads/a"]

Before you begin

  • Path normalization
  • Platform differences
  • Validation

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.