(
fn: Callable[..., Any], other: Any, escape: Optional[str], autoescape: bool
)
| 2345 | |
| 2346 | |
| 2347 | def _escaped_like_impl( |
| 2348 | fn: Callable[..., Any], other: Any, escape: Optional[str], autoescape: bool |
| 2349 | ) -> Any: |
| 2350 | if autoescape: |
| 2351 | if autoescape is not True: |
| 2352 | util.warn( |
| 2353 | "The autoescape parameter is now a simple boolean True/False" |
| 2354 | ) |
| 2355 | if escape is None: |
| 2356 | escape = "/" |
| 2357 | |
| 2358 | if not isinstance(other, str): |
| 2359 | raise TypeError("String value expected when autoescape=True") |
| 2360 | |
| 2361 | if escape not in ("%", "_"): |
| 2362 | other = other.replace(escape, escape + escape) |
| 2363 | |
| 2364 | other = other.replace("%", escape + "%").replace("_", escape + "_") |
| 2365 | |
| 2366 | return fn(other, escape=escape) |
| 2367 | |
| 2368 | |
| 2369 | @comparison_op |
no test coverage detected