Skip to content

Commit c800f2b

Browse files
fix: DEV-3089: Disable DTDForbidden for label config validation (#2782)
* fix: DEV-3089: Disable DTDForbidden for label config validation
1 parent 682a115 commit c800f2b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

label_studio/core/label_config.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ def _fix_choices(config):
7373

7474

7575
def parse_config_to_json(config_string):
76-
parser = etree.XMLParser()
7776
try:
78-
xml = etree.fromstring(config_string, parser)
77+
xml = etree.fromstring(config_string, forbid_dtd=False)
7978
except TypeError as error:
8079
raise etree.ParseError('can only parse strings')
8180
if xml is None:
@@ -113,8 +112,7 @@ def validate_label_config(config_string):
113112

114113
def extract_data_types(label_config):
115114
# load config
116-
parser = etree.XMLParser()
117-
xml = etree.fromstring(label_config, parser)
115+
xml = etree.fromstring(label_config, forbid_dtd=False)
118116
if xml is None:
119117
raise etree.ParseError('Project config is empty or incorrect')
120118

@@ -163,7 +161,7 @@ def get_all_object_tag_names(label_config):
163161

164162

165163
def config_line_stipped(c):
166-
tree = etree.fromstring(c)
164+
tree = etree.fromstring(c, forbid_dtd=False)
167165
comments = tree.xpath('//comment()')
168166

169167
for c in comments:
@@ -223,8 +221,7 @@ def generate_sample_task_without_check(label_config, mode='upload', secure_mode=
223221
""" Generate sample task only
224222
"""
225223
# load config
226-
parser = etree.XMLParser()
227-
xml = etree.fromstring(label_config, parser)
224+
xml = etree.fromstring(label_config, forbid_dtd=False)
228225
if xml is None:
229226
raise etree.ParseError('Project config is empty or incorrect')
230227

0 commit comments

Comments
 (0)