Skip to content

fix(forms): render crispy fragments from named templates - #23222

Open
nijel wants to merge 1 commit into
mainfrom
crispy-html
Open

nijel wants to merge 1 commit into
mainfrom
crispy-html

Conversation

@nijel

@nijel nijel commented Nov 29, 2026

Copy link
Copy Markdown
Member

Pass runtime values as template context so form fragments cannot interpret project or component names as Django template source. Ban crispy HTML layout objects with Ruff to prevent reintroduction.

@nijel nijel added this to the 2026.12 milestone Nov 29, 2026
@nijel nijel self-assigned this Nov 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T18:57:42.539580Z 4f52685 New commits
🔒 Security Review ✅ Completed 2026-11-29T18:51:41.141431Z 0d0f7ab PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread docs/contributing/frontend.rst Resolved
Comment thread docs/changes.rst Resolved
Pass runtime values as template context so form fragments cannot interpret project or component names as Django template source. Ban crispy HTML layout objects with Ruff to prevent reintroduction.
@nijel
nijel enabled auto-merge (rebase) November 29, 2026 20:44
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
15725 3 15722 1053
View the top 3 failed test(s) by shortest run time
weblate.utils.tests.test_files.FilesTestCase::test_resolve_path_walks_missing_suffix_once
Stack Traces | 0.002s run time
self = <weblate.utils.tests.test_files.FilesTestCase testMethod=test_resolve_path_walks_missing_suffix_once>

    def test_resolve_path_walks_missing_suffix_once(self) -> None:
        with tempfile.TemporaryDirectory() as tempdir:
            path = os.path.join(tempdir, "missing", *("nested" for _ in range(200)))
            with patch("weblate.utils.files.os.lstat", wraps=os.lstat) as lstat:
>               self.assertEqual(resolve_path(path), Path(path))
E               AssertionError: PosixPath('.../folders/q2/p1t6rgxj5fj32g1dc7[1431 chars]ted') != PosixPath('.../folders/q2/p1t6rgxj5fj32g1dc7dmd49r00[1423 chars]ted')

.../utils/tests/test_files.py:453: AssertionError
weblate.utils.tests.test_files.FilesTestCase::test_is_path_within_directory_rejects_unresolvable_symlink
Stack Traces | 0.003s run time
self = <weblate.utils.tests.test_files.FilesTestCase testMethod=test_is_path_within_directory_rejects_unresolvable_symlink>

    def test_is_path_within_directory_rejects_unresolvable_symlink(self) -> None:
        with tempfile.TemporaryDirectory() as tempdir:
>           repo_path, filename = self.create_unresolvable_symlink(tempdir)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.../utils/tests/test_files.py:415: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

tempdir = '.../p1t6rgxj5fj32g1dc7dmd49r0000gn/T/tmp4avc_s6c'

    @staticmethod
    def create_unresolvable_symlink(tempdir: str) -> tuple[str, str]:
        """Create a symlink escaping the repository stored beyond PATH_MAX."""
        repo_path = os.path.join(tempdir, "repo")
        outside_path = os.path.join(tempdir, "outside")
        os.makedirs(repo_path)
        os.makedirs(outside_path)
        Path(outside_path, "secrets.po").write_text("test", encoding="utf-8")
        # Deep enough to exceed PATH_MAX regardless of the temporary directory
        parts = ["d" * 238] * 17
        fd = os.open(repo_path, os.O_RDONLY)
        try:
            for index, part in enumerate(parts):
                os.mkdir(part, dir_fd=fd)
                child = os.open(part, os.O_RDONLY, dir_fd=fd)
                os.close(fd)
                fd = child
                if index == 7:
                    # Keep each symlink target below filesystem length limits.
>                   os.symlink("/".join(parts[8:]), "next", dir_fd=fd)
E                   OSError: [Errno 63] File name too long: '.../dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' -> 'next'

.../utils/tests/test_files.py:403: OSError
weblate.utils.tests.test_files.FilesTestCase::test_resolve_path
Stack Traces | 0.022s run time
self = <weblate.utils.tests.test_files.FilesTestCase testMethod=test_resolve_path>

    def test_resolve_path(self) -> None:
        for resolve in (resolve_path, _realpath_allow_missing):
            with (
                self.subTest(resolve=resolve.__name__),
                tempfile.TemporaryDirectory() as tempdir,
            ):
>               repo_path, filename = self.create_unresolvable_symlink(tempdir)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.../utils/tests/test_files.py:426: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

tempdir = '.../p1t6rgxj5fj32g1dc7dmd49r0000gn/T/tmpvo9rizv_'

    @staticmethod
    def create_unresolvable_symlink(tempdir: str) -> tuple[str, str]:
        """Create a symlink escaping the repository stored beyond PATH_MAX."""
        repo_path = os.path.join(tempdir, "repo")
        outside_path = os.path.join(tempdir, "outside")
        os.makedirs(repo_path)
        os.makedirs(outside_path)
        Path(outside_path, "secrets.po").write_text("test", encoding="utf-8")
        # Deep enough to exceed PATH_MAX regardless of the temporary directory
        parts = ["d" * 238] * 17
        fd = os.open(repo_path, os.O_RDONLY)
        try:
            for index, part in enumerate(parts):
                os.mkdir(part, dir_fd=fd)
                child = os.open(part, os.O_RDONLY, dir_fd=fd)
                os.close(fd)
                fd = child
                if index == 7:
                    # Keep each symlink target below filesystem length limits.
>                   os.symlink("/".join(parts[8:]), "next", dir_fd=fd)
E                   OSError: [Errno 63] File name too long: '.../dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' -> 'next'

.../utils/tests/test_files.py:403: OSError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

This branch has not been deployed

No deployments
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.

1 participant