Skip to content

Commit f695134

Browse files
committed
Avoid stripping additional characters from GIS SQL params.
If the param lead or ended with characters identified in the strip calls, those characters would also be removed. Using split will retain all of the characters inbetween the given strings. When we drop support for < 3.9, we can switch to the removeprefix and removesuffix functions. Fixes #1543
1 parent 4adfcc1 commit f695134

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

debug_toolbar/panels/sql/tracking.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def _record(self, method, sql, params):
141141

142142
def strip_GeomFromEWKB(param):
143143
if isinstance(param, str):
144-
return param.lstrip("ST_GeomFromEWKB('\\x").rstrip("'::bytea)")
144+
return param.split("ST_GeomFromEWKB('\\x", maxsplit=1)[
145+
0
146+
].rsplit("'::bytea)", maxsplit=1)[0]
145147
return param
146148

147149
params = [strip_GeomFromEWKB(param) for param in params]

0 commit comments

Comments
 (0)