Split a path into segments and perform a sanity check. If it detects '..' in the path it will raise a `TemplateNotFound` error.
(template: str)
| 23 | |
| 24 | |
| 25 | def split_template_path(template: str) -> t.List[str]: |
| 26 | """Split a path into segments and perform a sanity check. If it detects |
| 27 | '..' in the path it will raise a `TemplateNotFound` error. |
| 28 | """ |
| 29 | pieces = [] |
| 30 | for piece in template.split("/"): |
| 31 | if ( |
| 32 | os.path.sep in piece |
| 33 | or (os.path.altsep and os.path.altsep in piece) |
| 34 | or piece == os.path.pardir |
| 35 | ): |
| 36 | raise TemplateNotFound(template) |
| 37 | elif piece and piece != ".": |
| 38 | pieces.append(piece) |
| 39 | return pieces |
| 40 | |
| 41 | |
| 42 | class BaseLoader: |
no test coverage detected