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
link_url = post_header[ln].lstrip() # URL
if link_url.startswith(tyto.headers): link_url = '' try:
link_url = post_header[ln].lstrip()
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
link_alt = post_header[ln + 1].lstrip() # ALT
if link_alt.startswith(tyto.headers): link_alt = '' try:
link_alt = post_header[ln + 1].lstrip()
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
image_uri = post_header[ln].lstrip() try:
if image_uri.startswith(tyto.headers): image_uri = '' image_uri = post_header[ln].lstrip()
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
image_alt = post_header[ln + 1].lstrip() try:
if image_alt.startswith(tyto.headers): image_alt = '' image_alt = post_header[ln + 1].lstrip()
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
raw_uri = post_header[ln].lstrip() try:
if raw_uri.startswith(tyto.headers): raw_uri = '' raw_uri = post_header[ln].lstrip()
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
raw_alt = post_header[ln + 1].lstrip() try:
if raw_alt.startswith(tyto.headers): raw_alt = '' raw_alt = post_header[ln + 1].lstrip()
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
file_uri = post_header[ln].lstrip() try:
if file_uri.startswith(tyto.headers): file_uri = '' file_uri = post_header[ln].lstrip()
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
file_alt = post_header[ln + 1].lstrip() try:
if file_alt.startswith(tyto.headers): file_alt = '' file_alt = post_header[ln + 1].lstrip()
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