File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change
1
+ import base64
2
+ import json
3
+
4
+
5
+ class DebugToolbarJSONDecoder (json .JSONDecoder ):
6
+ """Custom JSON decoder that reconstructs binary data during parsing."""
7
+
8
+ def decode (self , s ):
9
+ """Override decode to apply reconstruction after parsing."""
10
+ obj = super ().decode (s )
11
+ return self ._reconstruct_params (obj )
12
+
13
+ def _reconstruct_params (self , params ):
14
+ """Reconstruct parameters, handling lists and dicts recursively."""
15
+ if isinstance (params , list ):
16
+ return [self ._reconstruct_params (param ) for param in params ]
17
+ elif isinstance (params , dict ):
18
+ if "__djdt_binary__" in params :
19
+ return base64 .b64decode (params ["__djdt_binary__" ])
20
+ else :
21
+ return {
22
+ key : self ._reconstruct_params (value )
23
+ for key , value in params .items ()
24
+ }
25
+ else :
26
+ return params
Original file line number Diff line number Diff line change 7
7
from django .utils .functional import cached_property
8
8
from django .utils .translation import gettext_lazy as _
9
9
10
+ from debug_toolbar .panels .sql .decoders import DebugToolbarJSONDecoder
10
11
from debug_toolbar .panels .sql .utils import is_select_query , reformat_sql
11
12
from debug_toolbar .toolbar import DebugToolbar
12
13
@@ -90,7 +91,7 @@ def clean(self):
90
91
def _get_query_params (self ):
91
92
"""Get reconstructed parameters for the current query"""
92
93
query = self .cleaned_data ["query" ]
93
- return _reconstruct_params ( json .loads (query ["params" ]) )
94
+ return json .loads (query ["params" ], cls = DebugToolbarJSONDecoder )
94
95
95
96
def select (self ):
96
97
query = self .cleaned_data ["query" ]
You can’t perform that action at this time.
0 commit comments