check. fix out of range for image, link, raw, file

This commit is contained in:
Cyrille L 2023-03-26 17:45:58 +02:00
parent 7982d6030b
commit 42996f5039
1 changed files with 66 additions and 22 deletions

View File

@ -459,24 +459,44 @@ def check_headers(post_header):
stat_links += 1 stat_links += 1
var_tag = 'link_%s'%stat_links var_tag = 'link_%s'%stat_links
# NAME
link_name = post_header[ln - 1].rsplit(tag)[1].lstrip() link_name = post_header[ln - 1].rsplit(tag)[1].lstrip()
if not link_name: if not link_name:
logs.out("2", "Line %s (Name, %s)"%(ln, tag), False) logs.out("2", 'L=%s. "%s %s" > %s'%(
ln, tag, tr.name, db.uri_file
), False)
post_err = True post_err = True
if not isin(r'\b_%s\b'%link_name, post_bottom): if not post_err and \
logs.out("6", "_%s"%link_name, False) not isin(r'\b_%s\b'%link_name, post_bottom):
logs.out("12", '"_%s%s" > %s'%(
tag, image_name, db.uri_file
), False)
post_err = True post_err = True
# URL
try:
link_url = post_header[ln].lstrip() link_url = post_header[ln].lstrip()
if link_url.startswith(tyto.headers): link_url = '' if link_url.startswith(tyto.headers): link_url = ''
except:
link_url = ''
if not link_url: if not link_url:
logs.out("2", "Line %s (URL, %s)"%(ln + 1, tag), False) logs.out("2", 'L=%s. "%s URL" > %s)'%(
ln + 1, tag, db.uri_file
), False)
post_err = True post_err = True
# ALT
try:
link_alt = post_header[ln + 1].lstrip() link_alt = post_header[ln + 1].lstrip()
if link_alt.startswith(tyto.headers): link_alt = '' if link_alt.startswith(tyto.headers): link_alt = ''
except:
link_alt = ''
if not link_alt: if not link_alt:
logs.out("2", "Line %s (Alt-Text, %s)"%(ln + 2, tag), False) logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file
), False)
post_err = True post_err = True
if not post_err: if not post_err:
@ -511,8 +531,12 @@ def check_headers(post_header):
post_err = True post_err = True
# URI # URI
try:
image_uri = post_header[ln].lstrip() image_uri = post_header[ln].lstrip()
if image_uri.startswith(tyto.headers): image_uri = '' if image_uri.startswith(tyto.headers): image_uri = ''
except:
image_uri = ''
if not image_uri: if not image_uri:
logs.out("2", 'L=%s. "%s URI" > %s)'%( logs.out("2", 'L=%s. "%s URI" > %s)'%(
ln + 1, tag, db.uri_file ln + 1, tag, db.uri_file
@ -525,8 +549,12 @@ def check_headers(post_header):
files_post = (files_post + "'%s', "%f_uri) files_post = (files_post + "'%s', "%f_uri)
# ALT # ALT
try:
image_alt = post_header[ln + 1].lstrip() image_alt = post_header[ln + 1].lstrip()
if image_alt.startswith(tyto.headers): image_alt = '' if image_alt.startswith(tyto.headers): image_alt = ''
except:
image_alt = ''
if not image_alt: if not image_alt:
logs.out("2", 'L=%s. "%s Alt-Text" > %s'%( logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file ln + 2, tag, db.uri_file
@ -563,8 +591,12 @@ def check_headers(post_header):
post_err = True post_err = True
# URI # URI
try:
raw_uri = post_header[ln].lstrip() raw_uri = post_header[ln].lstrip()
if raw_uri.startswith(tyto.headers): raw_uri = '' if raw_uri.startswith(tyto.headers): raw_uri = ''
except:
raw_uri = ''
if not raw_uri: if not raw_uri:
logs.out("2", 'L=%s. "%s URI" > %s)'%( logs.out("2", 'L=%s. "%s URI" > %s)'%(
ln + 1, tag, db.uri_file ln + 1, tag, db.uri_file
@ -577,8 +609,12 @@ def check_headers(post_header):
files_post = (files_post + "'%s', "%f_uri) files_post = (files_post + "'%s', "%f_uri)
# ALT # ALT
try:
raw_alt = post_header[ln + 1].lstrip() raw_alt = post_header[ln + 1].lstrip()
if raw_alt.startswith(tyto.headers): raw_alt = '' if raw_alt.startswith(tyto.headers): raw_alt = ''
except:
raw_alt = ''
if not raw_alt: if not raw_alt:
logs.out("2", 'L=%s. "%s Alt-Text" > %s'%( logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file ln + 2, tag, db.uri_file
@ -610,8 +646,12 @@ def check_headers(post_header):
post_err = True post_err = True
# URI # URI
try:
file_uri = post_header[ln].lstrip() file_uri = post_header[ln].lstrip()
if file_uri.startswith(tyto.headers): file_uri = '' if file_uri.startswith(tyto.headers): file_uri = ''
except:
file_uri = ''
if not file_uri: if not file_uri:
logs.out("2", 'L=%s. "%s URI" > %s)'%( logs.out("2", 'L=%s. "%s URI" > %s)'%(
ln + 1, tag, db.uri_file ln + 1, tag, db.uri_file
@ -624,8 +664,12 @@ def check_headers(post_header):
files_post = (files_post + "'%s', "%f_uri) files_post = (files_post + "'%s', "%f_uri)
# ALT # ALT
try:
file_alt = post_header[ln + 1].lstrip() file_alt = post_header[ln + 1].lstrip()
if file_alt.startswith(tyto.headers): file_alt = '' if file_alt.startswith(tyto.headers): file_alt = ''
except:
file_alt = ''
if not file_alt: if not file_alt:
logs.out("2", 'L=%s. "%s Alt-Text" > %s'%( logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file ln + 2, tag, db.uri_file