feat: extend optional HTML feedback to graduate imports in 0.7.8
This commit is contained in:
@@ -110,7 +110,7 @@ class ApiError(Exception):
|
||||
class SchoolHtmlValidator(HTMLParser):
|
||||
"""Accept only the inert diagnostic schema emitted by the app, not web pages."""
|
||||
tags = set(('html head meta title body input table thead tbody tfoot tr td th caption colgroup col '
|
||||
'span div p b i strong em u small br hr a font center nobr label s sub sup pre code').split())
|
||||
'span div p b i strong em u small br hr a font center nobr label s sub sup pre code select option').split())
|
||||
void = {'meta', 'input', 'br', 'hr', 'col'}
|
||||
csp = "default-src 'none'; base-uri 'none'; form-action 'none'"
|
||||
|
||||
@@ -145,9 +145,21 @@ class SchoolHtmlValidator(HTMLParser):
|
||||
elif tag == 'script':
|
||||
if values != {'type': 'application/x-tpschedule-course-data'}:
|
||||
raise ValueError('script')
|
||||
elif tag == 'select':
|
||||
if (self.stack[-1:] != ['body'] or set(values) != {'id'}
|
||||
or values['id'] not in {'drpxq', 'xqbh'}):
|
||||
raise ValueError('semester selector')
|
||||
elif tag == 'option':
|
||||
if (self.stack[-1:] != ['select'] or set(values) - {'value', 'selected'}
|
||||
or 'value' in values and not re.fullmatch(r'\d{1,6}', values['value'] or '')
|
||||
or 'selected' in values and values['selected'] not in {'', 'selected'}):
|
||||
raise ValueError('semester option')
|
||||
else:
|
||||
for key, value in attrs:
|
||||
if key == 'id' and tag == 'table' and value == 'manualArrangeCourseTable':
|
||||
if (key == 'id' and tag == 'table'
|
||||
and value in {'manualArrangeCourseTable', 'tbl', 'sample-table-1'}):
|
||||
continue
|
||||
if key == 'id' and tag in {'td', 'th'} and re.fullmatch(r't[0-7][13579]', value or ''):
|
||||
continue
|
||||
if key in {'rowspan', 'colspan'} and re.fullmatch(r'\d{1,2}', value or ''):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user