python-liquid 2.3.5__py3-none-any.whl → 2.3.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
liquid/__init__.py CHANGED
@@ -56,7 +56,7 @@ from .tag import Tag
56
56
 
57
57
  from . import future
58
58
 
59
- __version__ = "2.3.5"
59
+ __version__ = "2.3.6"
60
60
 
61
61
  __all__ = (
62
62
  "AwareBoundTemplate",
@@ -6,6 +6,7 @@ import asyncio
6
6
  import os
7
7
  from functools import partial
8
8
  from pathlib import Path
9
+ from pathlib import PurePath
9
10
  from typing import TYPE_CHECKING
10
11
  from typing import Iterable
11
12
  from typing import Optional
@@ -62,7 +63,9 @@ class FileSystemLoader(BaseLoader):
62
63
  _template_name_ exists. If none of the search paths contain _template_name_, a
63
64
  _TemplateNotFound_ exception is raised.
64
65
  """
65
- template_path = Path(template_name)
66
+ template_path = PurePath(template_name)
67
+ if template_path.anchor:
68
+ template_path = PurePath(*template_path.parts[1:])
66
69
 
67
70
  if not template_path.name:
68
71
  raise TemplateNotFoundError(template_name)
@@ -74,26 +77,24 @@ class FileSystemLoader(BaseLoader):
74
77
  raise TemplateNotFoundError(template_name)
75
78
 
76
79
  for base in self.search_path:
77
- source_path = base.joinpath(template_path)
80
+ base_resolved = base.resolve()
81
+ source_path = (base_resolved / template_path).resolve()
78
82
 
79
- try:
80
- if not source_path.exists() or not source_path.is_file():
81
- continue
82
- except OSError:
83
- # "File name too long", for example
83
+ if not source_path.is_relative_to(base_resolved):
84
84
  continue
85
85
 
86
86
  if self.reject_symlinks:
87
- try:
88
- resolved = source_path.resolve(strict=False)
89
- base_resolved = base.resolve(strict=False)
90
- except OSError:
91
- continue
87
+ current = base_resolved
88
+ for part in template_path.parts:
89
+ current /= part
90
+ if current.is_symlink():
91
+ continue
92
92
 
93
- if not resolved.is_relative_to(base_resolved):
94
- continue
93
+ if not source_path.is_file() or source_path.is_dir():
94
+ continue
95
95
 
96
- return source_path
96
+ # We don't want to expose a fully qualified path in error messages.
97
+ return base / template_path
97
98
 
98
99
  raise TemplateNotFoundError(template_name)
99
100
 
@@ -150,12 +150,12 @@ class CachingLoaderMixin(ABC, _CachingLoaderProtocol):
150
150
  cache_key = self.cache_key(name, context, kwargs)
151
151
  return await self._check_cache_async(
152
152
  env,
153
- name,
153
+ cache_key,
154
154
  globals,
155
155
  partial(
156
156
  super().load_async, # type: ignore
157
157
  env,
158
- cache_key,
158
+ name,
159
159
  globals=globals,
160
160
  context=context,
161
161
  **kwargs,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-liquid
3
- Version: 2.3.5
3
+ Version: 2.3.6
4
4
  Summary: A Python engine for the Liquid template language.
5
5
  Project-URL: Change Log, https://github.com/jg-rp/liquid/blob/main/CHANGES.md
6
6
  Project-URL: Documentation, https://jg-rp.github.io/liquid/
@@ -1,4 +1,4 @@
1
- liquid/__init__.py,sha256=r-szneydI9E0ImPstsYX7ai94McLEczbs6V0I51P4cQ,7696
1
+ liquid/__init__.py,sha256=bpF7HaxYagzD51WtLErxRvxMLSm0_XWUuoXkjg2xhMM,7696
2
2
  liquid/analyze_tags.py,sha256=Uc1nueKLRiIejs2JyQIC7u2pxp9l-5HJAMWlg-Qj1m8,7615
3
3
  liquid/ast.py,sha256=4ZqSbuW4mv9IvoIMPk3OICUaOI1vPh8P8uFCrXI_3XA,8140
4
4
  liquid/context.py,sha256=GYMG5-u3JI3w1jN_osEtyNsjziWgjBBMFZTilJEMap0,21931
@@ -46,8 +46,8 @@ liquid/builtin/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
46
46
  liquid/builtin/loaders/caching_file_system_loader.py,sha256=V4OLa6UGT-RELGiV4eu02TeLL4P_JIE2kMYMrO3qy8U,2158
47
47
  liquid/builtin/loaders/choice_loader.py,sha256=FE23RLMOiWmsRGZv9t6QmlG7bgMEUSblnucAv3j0SBM,2816
48
48
  liquid/builtin/loaders/dict_loader.py,sha256=8TdMJqaYPLwllmIiEmuZNXqH6UOOsi4HuJ2t5sztOOw,1785
49
- liquid/builtin/loaders/file_system_loader.py,sha256=kKPUmznPgNFq3fRDeoOTbWjNwxuLrYPAteZ_Do1-Mks,4924
50
- liquid/builtin/loaders/mixins.py,sha256=4Hj5wWGMOi3LqA9ZJYsUb4LFbG0a5DDb9H975G8nn58,5209
49
+ liquid/builtin/loaders/file_system_loader.py,sha256=RZBpQXfqR-esrNVsR5BRYszf9tRD3_LkGRkoYrwqbq8,5052
50
+ liquid/builtin/loaders/mixins.py,sha256=x83ir6zGZsLvDoJbeHvwGzTZDm150vvLjhpxKyO9H6k,5209
51
51
  liquid/builtin/loaders/package_loader.py,sha256=PNg-ygoRjfiALFu3bzEDRdps30rtsTIkt0voJKs9zCo,4061
52
52
  liquid/builtin/tags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  liquid/builtin/tags/assign_tag.py,sha256=VTfkPbF-i0KLqMmaacBItFQHaBTP7ECWR-RvVh9Q6lY,2374
@@ -90,7 +90,7 @@ liquid/utils/chain_map.py,sha256=nxkw3wwF6ddlGarIuL7Ii2elm4dU80LySgdQx1oift0,151
90
90
  liquid/utils/html.py,sha256=TmqOOpRMsy7fqZLj7X5ybd_XQnWW2YDAVDwTP1Gwf40,1706
91
91
  liquid/utils/lru_cache.py,sha256=sDum97lCXOIHnT1zFsI36rfLWM9nv2y6xSSzxDnq_E4,4021
92
92
  liquid/utils/text.py,sha256=1SwDECNMaqnnZ05je_AZZgxqzZd6U-mvq5jNU3W1-Qk,841
93
- python_liquid-2.3.5.dist-info/METADATA,sha256=3o5IwVk-A0OdLNsAgUUhXdEhaEBWUtMg-Sv7deVOyGo,6837
94
- python_liquid-2.3.5.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
95
- python_liquid-2.3.5.dist-info/licenses/LICENSE,sha256=yAFURzud5ERNHt1rZIPnTLJ92ep7q8y5yG9g5DUMR_E,1075
96
- python_liquid-2.3.5.dist-info/RECORD,,
93
+ python_liquid-2.3.6.dist-info/METADATA,sha256=KvEELu7O5fCkBqFk8mCFfWr_xYRAeHX5OU_D_L9xGBc,6837
94
+ python_liquid-2.3.6.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
95
+ python_liquid-2.3.6.dist-info/licenses/LICENSE,sha256=yAFURzud5ERNHt1rZIPnTLJ92ep7q8y5yG9g5DUMR_E,1075
96
+ python_liquid-2.3.6.dist-info/RECORD,,