mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-15 00:45:57 +08:00
Remove use of eval() from ocr.py (#4481)
`eval(op_name)` -> `getattr(operators, op_name)` ### What problem does this PR solve? Using `eval()` can lead to code injections and is entirely unnecessary here. ### Type of change - [x] Other (please describe): Best practice code improvement, preventing the possibility of code injection.
This commit is contained in:
parent
938492cbae
commit
4f9f9405b8
@ -19,6 +19,7 @@ from huggingface_hub import snapshot_download
|
|||||||
|
|
||||||
from api.utils.file_utils import get_project_base_directory
|
from api.utils.file_utils import get_project_base_directory
|
||||||
from .operators import * # noqa: F403
|
from .operators import * # noqa: F403
|
||||||
|
from . import operators
|
||||||
import math
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
@ -55,7 +56,7 @@ def create_operators(op_param_list, global_config=None):
|
|||||||
param = {} if operator[op_name] is None else operator[op_name]
|
param = {} if operator[op_name] is None else operator[op_name]
|
||||||
if global_config is not None:
|
if global_config is not None:
|
||||||
param.update(global_config)
|
param.update(global_config)
|
||||||
op = eval(op_name)(**param)
|
op = getattr(operators, op_name)(**param)
|
||||||
ops.append(op)
|
ops.append(op)
|
||||||
return ops
|
return ops
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user