浏览代码

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.
tags/v0.16.0
Mathias Panzenböck 9 个月前
父节点
当前提交
4f9f9405b8
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2
    1
      deepdoc/vision/ocr.py

+ 2
- 1
deepdoc/vision/ocr.py 查看文件



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
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



正在加载...
取消
保存