mirror of https://gitee.com/openkylin/jinja2.git
changed debian/source/format to native
This commit is contained in:
parent
08be726ab3
commit
705b44318b
|
@ -1,22 +0,0 @@
|
|||
From: =?utf-8?q?Piotr_O=C5=BCarowski?= <piotr@debian.org>
|
||||
Date: Thu, 2 Apr 2020 13:41:14 +0200
|
||||
Subject: docs: disable sphinxcontrib.log_cabinet
|
||||
|
||||
it's not packaged in Debian yet
|
||||
---
|
||||
docs/conf.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/docs/conf.py b/docs/conf.py
|
||||
index f65d462..43bcfda 100644
|
||||
--- a/docs/conf.py
|
||||
+++ b/docs/conf.py
|
||||
@@ -15,7 +15,7 @@ extensions = [
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.intersphinx",
|
||||
"pallets_sphinx_themes",
|
||||
- "sphinxcontrib.log_cabinet",
|
||||
+ # "sphinxcontrib.log_cabinet",
|
||||
"sphinx_issues",
|
||||
]
|
||||
autodoc_typehints = "description"
|
|
@ -1,38 +0,0 @@
|
|||
From: =?utf-8?q?Piotr_O=C5=BCarowski?= <piotr@debian.org>
|
||||
Date: Fri, 24 Feb 2023 16:06:57 +0100
|
||||
Subject: fix nose leftovers
|
||||
|
||||
taken from upstream repo
|
||||
---
|
||||
tests/test_loader.py | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/tests/test_loader.py b/tests/test_loader.py
|
||||
index 04c921d..77d686e 100644
|
||||
--- a/tests/test_loader.py
|
||||
+++ b/tests/test_loader.py
|
||||
@@ -183,6 +183,7 @@ class TestFileSystemLoader:
|
||||
|
||||
class TestModuleLoader:
|
||||
archive = None
|
||||
+ mod_env = None
|
||||
|
||||
def compile_down(self, prefix_loader, zip="deflated"):
|
||||
log = []
|
||||
@@ -196,13 +197,14 @@ class TestModuleLoader:
|
||||
self.mod_env = Environment(loader=loaders.ModuleLoader(self.archive))
|
||||
return "".join(log)
|
||||
|
||||
- def teardown(self):
|
||||
- if hasattr(self, "mod_env"):
|
||||
+ def teardown_method(self):
|
||||
+ if self.archive is not None:
|
||||
if os.path.isfile(self.archive):
|
||||
os.remove(self.archive)
|
||||
else:
|
||||
shutil.rmtree(self.archive)
|
||||
self.archive = None
|
||||
+ self.mod_env = None
|
||||
|
||||
def test_log(self, prefix_loader):
|
||||
log = self.compile_down(prefix_loader)
|
|
@ -1,92 +0,0 @@
|
|||
From 7dd3680e6eea0d77fde024763657aa4d884ddb23 Mon Sep 17 00:00:00 2001
|
||||
From: Calum Hutton <calum.hutton@snyk.io>
|
||||
Date: Thu, 26 Oct 2023 12:08:53 +0100
|
||||
Subject: [PATCH] xmlattr filter disallows keys with spaces
|
||||
|
||||
---
|
||||
CHANGES.rst | 1 +
|
||||
src/jinja2/filters.py | 28 +++++++++++++++++++++-------
|
||||
tests/test_filters.py | 6 ++++++
|
||||
3 files changed, 28 insertions(+), 7 deletions(-)
|
||||
|
||||
#diff --git a/CHANGES.rst b/CHANGES.rst
|
||||
#index 36db0843a..d6688e762 100644
|
||||
#--- a/CHANGES.rst
|
||||
#+++ b/CHANGES.rst
|
||||
#@@ -7,6 +7,7 @@ Unreleased
|
||||
#
|
||||
# - Fix compiler error when checking if required blocks in parent templates are
|
||||
# empty. :pr:`1858`
|
||||
#+- ``xmlattr`` filter does not allow keys with spaces. GHSA-h5c8-rqwp-cp95
|
||||
#
|
||||
#
|
||||
# Version 3.1.2
|
||||
diff --git a/src/jinja2/filters.py b/src/jinja2/filters.py
|
||||
index ed07c4c0e..c7ecc9bb6 100644
|
||||
--- a/src/jinja2/filters.py
|
||||
+++ b/src/jinja2/filters.py
|
||||
@@ -248,13 +248,17 @@ def do_items(value: t.Union[t.Mapping[K, V], Undefined]) -> t.Iterator[t.Tuple[K
|
||||
yield from value.items()
|
||||
|
||||
|
||||
+_space_re = re.compile(r"\s", flags=re.ASCII)
|
||||
+
|
||||
+
|
||||
@pass_eval_context
|
||||
def do_xmlattr(
|
||||
eval_ctx: "EvalContext", d: t.Mapping[str, t.Any], autospace: bool = True
|
||||
) -> str:
|
||||
"""Create an SGML/XML attribute string based on the items in a dict.
|
||||
- All values that are neither `none` nor `undefined` are automatically
|
||||
- escaped:
|
||||
+
|
||||
+ If any key contains a space, this fails with a ``ValueError``. Values that
|
||||
+ are neither ``none`` nor ``undefined`` are automatically escaped.
|
||||
|
||||
.. sourcecode:: html+jinja
|
||||
|
||||
@@ -273,12 +277,22 @@ def do_xmlattr(
|
||||
|
||||
As you can see it automatically prepends a space in front of the item
|
||||
if the filter returned something unless the second parameter is false.
|
||||
+
|
||||
+ .. versionchanged:: 3.1.3
|
||||
+ Keys with spaces are not allowed.
|
||||
"""
|
||||
- rv = " ".join(
|
||||
- f'{escape(key)}="{escape(value)}"'
|
||||
- for key, value in d.items()
|
||||
- if value is not None and not isinstance(value, Undefined)
|
||||
- )
|
||||
+ items = []
|
||||
+
|
||||
+ for key, value in d.items():
|
||||
+ if value is None or isinstance(value, Undefined):
|
||||
+ continue
|
||||
+
|
||||
+ if _space_re.search(key) is not None:
|
||||
+ raise ValueError(f"Spaces are not allowed in attributes: '{key}'")
|
||||
+
|
||||
+ items.append(f'{escape(key)}="{escape(value)}"')
|
||||
+
|
||||
+ rv = " ".join(items)
|
||||
|
||||
if autospace and rv:
|
||||
rv = " " + rv
|
||||
diff --git a/tests/test_filters.py b/tests/test_filters.py
|
||||
index 32897c546..f50ed13ab 100644
|
||||
--- a/tests/test_filters.py
|
||||
+++ b/tests/test_filters.py
|
||||
@@ -474,6 +474,12 @@ def test_xmlattr(self, env):
|
||||
assert 'bar="23"' in out
|
||||
assert 'blub:blub="<?>"' in out
|
||||
|
||||
+ def test_xmlattr_key_with_spaces(self, env):
|
||||
+ with pytest.raises(ValueError, match="Spaces are not allowed"):
|
||||
+ env.from_string(
|
||||
+ "{{ {'src=1 onerror=alert(1)': 'my_class'}|xmlattr }}"
|
||||
+ ).render()
|
||||
+
|
||||
def test_sort1(self, env):
|
||||
tmpl = env.from_string("{{ [2, 3, 1]|sort }}|{{ [2, 3, 1]|sort(true) }}")
|
||||
assert tmpl.render() == "[1, 2, 3]|[3, 2, 1]"
|
|
@ -1,104 +0,0 @@
|
|||
From: Thomas Goirand <zigo@debian.org>
|
||||
Date: Wed, 1 Apr 2020 14:08:47 +0200
|
||||
Subject: Python 3.9: fix collections import
|
||||
|
||||
Bug-Debian: https://bugs.debian.org/949018
|
||||
Forwarded: no
|
||||
Last-Update: 2020-02-27
|
||||
|
||||
As collections has moved to collections.abc, this produces a warning which
|
||||
may lead to unit testing errors: this is the case when building Rally.
|
||||
|
||||
This patch attempts to import from collections.abc, and if it fails, falls
|
||||
back to collections. This should be harmless.
|
||||
|
||||
Note that this patch is probably useless with future version, as hopefully,
|
||||
upstream will fix it (I didn't check). However, I didn't dare upgrading the
|
||||
package to the major upstream release 3.x.
|
||||
---
|
||||
src/jinja2/lexer.py | 5 ++++-
|
||||
src/jinja2/nodes.py | 5 ++++-
|
||||
src/jinja2/sandbox.py | 5 ++++-
|
||||
src/jinja2/utils.py | 5 ++++-
|
||||
tests/test_utils.py | 5 ++++-
|
||||
5 files changed, 20 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/jinja2/lexer.py b/src/jinja2/lexer.py
|
||||
index aff7e9f..37ef342 100644
|
||||
--- a/src/jinja2/lexer.py
|
||||
+++ b/src/jinja2/lexer.py
|
||||
@@ -6,7 +6,10 @@ template code and python code in expressions.
|
||||
import re
|
||||
import typing as t
|
||||
from ast import literal_eval
|
||||
-from collections import deque
|
||||
+try:
|
||||
+ from collections.abc import deque
|
||||
+except ImportError:
|
||||
+ from collections import deque
|
||||
from sys import intern
|
||||
|
||||
from ._identifier import pattern as name_re
|
||||
diff --git a/src/jinja2/nodes.py b/src/jinja2/nodes.py
|
||||
index b2f88d9..53da1e9 100644
|
||||
--- a/src/jinja2/nodes.py
|
||||
+++ b/src/jinja2/nodes.py
|
||||
@@ -5,7 +5,10 @@ to normalize nodes.
|
||||
import inspect
|
||||
import operator
|
||||
import typing as t
|
||||
-from collections import deque
|
||||
+try:
|
||||
+ from collections.abc import deque
|
||||
+except ImportError:
|
||||
+ from collections import deque
|
||||
|
||||
from markupsafe import Markup
|
||||
|
||||
diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py
|
||||
index 06d7414..f443c18 100644
|
||||
--- a/src/jinja2/sandbox.py
|
||||
+++ b/src/jinja2/sandbox.py
|
||||
@@ -6,7 +6,10 @@ import types
|
||||
import typing as t
|
||||
from _string import formatter_field_name_split # type: ignore
|
||||
from collections import abc
|
||||
-from collections import deque
|
||||
+try:
|
||||
+ from collections.abc import deque
|
||||
+except ImportError:
|
||||
+ from collections import deque
|
||||
from string import Formatter
|
||||
|
||||
from markupsafe import EscapeFormatter
|
||||
diff --git a/src/jinja2/utils.py b/src/jinja2/utils.py
|
||||
index 9b5f5a5..205b2af 100644
|
||||
--- a/src/jinja2/utils.py
|
||||
+++ b/src/jinja2/utils.py
|
||||
@@ -4,7 +4,10 @@ import os
|
||||
import re
|
||||
import typing as t
|
||||
from collections import abc
|
||||
-from collections import deque
|
||||
+try:
|
||||
+ from collections.abc import deque
|
||||
+except ImportError:
|
||||
+ from collections import deque
|
||||
from random import choice
|
||||
from random import randrange
|
||||
from threading import Lock
|
||||
diff --git a/tests/test_utils.py b/tests/test_utils.py
|
||||
index 7b58af1..9013d7c 100644
|
||||
--- a/tests/test_utils.py
|
||||
+++ b/tests/test_utils.py
|
||||
@@ -1,6 +1,9 @@
|
||||
import pickle
|
||||
import random
|
||||
-from collections import deque
|
||||
+try:
|
||||
+ from collections.abc import deque
|
||||
+except ImportError:
|
||||
+ from collections import deque
|
||||
from copy import copy as shallow_copy
|
||||
|
||||
import pytest
|
|
@ -1,4 +0,0 @@
|
|||
py3.9-fix-collections-import.patch
|
||||
0002-docs-disable-sphinxcontrib.log_cabinet.patch
|
||||
0003-fix-nose-leftovers.patch
|
||||
CVE-2024-22195.patch
|
|
@ -1 +1 @@
|
|||
3.0 (quilt)
|
||||
3.0 (native)
|
||||
|
|
Loading…
Reference in New Issue