Skip to content

Commit

Permalink
"fix: 插件上传文件超过特定大小导致内存段错误 #1010158081127907857"
Browse files Browse the repository at this point in the history
  • Loading branch information
unique0lai committed Jul 24, 2024
1 parent 4aea743 commit 15f2c4d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bkmonitor/patches/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
from json import load as json_load
from json import loads as json_loads

try:
from django.core.files import File
except ImportError:
File = None

try:
import ujson
except ImportError:
Expand Down Expand Up @@ -63,6 +68,10 @@ def loads(*args, **kwargs):


def dumps(*args, **kwargs):
# 当前文件为django的File对象时,不进行转换,避免segmentation fault错误
if args and File and isinstance(args[0], File):
return json_dumps(*args, **kwargs)

if SAFE_OPTIONS.issuperset(kwargs.keys()):
try:
kwargs.setdefault("escape_forward_slashes", False)
Expand Down

0 comments on commit 15f2c4d

Please sign in to comment.