Skip to content

drive designator handling issue in template URI normalization on Windows #441

Closed

Description

@zzzeek

Summary

There is an inconsistency in how drive designators are handled during URI normalization in template lookup on Windows, which can lead to incorrect path resolution.

Details will be updated when fix is provided.

Activity

  1. sqla-tester commented on Sep 22, 2026

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the main branch:

    Fix path traversal via drive designator URI on Windows in TemplateLookup https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/6989

  2. zzzeek commented on Sep 22, 2026

    @zzzeek
    MemberAuthor

    Reopening: the test matrix added with this fix cannot run on Windows.

    TemplateLookup.get_template() converts the configured directory with dir_.replace(os.path.sep, posixpath.sep). The new parametrized test forces os.path = posixpath in order to exercise both platforms' semantics, but on a real Windows host that makes os.path.sep equal to /, so the genuine backslashes in the temporary directory path are never converted and the template is not found at all. The eleven -posix rows therefore fail with TopLevelLookupException instead of reaching the traversal check.

    The library itself is not affected; the -windows rows pass on Windows and the whole matrix passes on Linux and macOS. This is a test-only regression in 1.4.2.

  3. reopened this on Sep 22, 2026
  4. sqla-tester commented on Sep 22, 2026

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the main branch:

    Skip posix path traversal test rows on a Windows filesystem https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/6990

  5. added 2 commits that reference this issue on Sep 23, 2026
    000ed85
    0d9f2d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglookup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions