mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-21 19:30:48 +00:00
Added code to prevent crashing when URLs contain non-ASCII characters.
Does not guarantee handling of non-UTF-8 URLs (like ISO 8859-15, Shift-JIS, etc)
This commit is contained in:
parent
9914700ae9
commit
b4333ca2fd
9
wrp.py
9
wrp.py
@ -262,11 +262,11 @@ if sys.platform == "linux" or sys.platform == "linux2":
|
||||
turl = QUrl(web_url).resolved(QUrl(x.attribute('href'))).toString()
|
||||
xmin, ymin, xmax, ymax = x.geometry().getCoords()
|
||||
if ISMAP == "true":
|
||||
mapfile.write("rect %s %i,%i %i,%i\n" % (turl, xmin, ymin, xmax, ymax))
|
||||
mapfile.write("rect %s %i,%i %i,%i\n".decode('utf-8', errors='ignore') % (turl, xmin, ymin, xmax, ymax))
|
||||
else:
|
||||
httpout.write("<AREA SHAPE=\"RECT\""
|
||||
" COORDS=\"%i,%i,%i,%i\""
|
||||
" ALT=\"%s\" HREF=\"%s\">\n"
|
||||
" ALT=\"%s\" HREF=\"%s\">\n".decode('utf-8', errors='ignore')
|
||||
% (xmin, ymin, xmax, ymax, turl, turl))
|
||||
|
||||
if ISMAP != "true":
|
||||
@ -547,6 +547,7 @@ elif sys.platform == "darwin":
|
||||
% ttl.toPlainText()).encode('utf-8', errors='ignore'))
|
||||
break # Don't repeat bad HTML coding with several title marks
|
||||
httpout.write("</HEAD>\n<BODY>\n")
|
||||
|
||||
if ISMAP == "true":
|
||||
httpout.write("<A HREF=\"http://%s\">"
|
||||
"<IMG SRC=\"http://%s\" ALT=\"wrp-render\" ISMAP>\n"
|
||||
@ -571,11 +572,11 @@ elif sys.platform == "darwin":
|
||||
ymax = Foundation.NSMaxY(myrect)
|
||||
|
||||
if ISMAP == "true":
|
||||
mapfile.write("rect %s %i,%i %i,%i\n" % (turl, xmin, ymin, xmax, ymax))
|
||||
mapfile.write("rect %s %i,%i %i,%i\n".decode('utf-8', errors='ignore') % (turl, xmin, ymin, xmax, ymax))
|
||||
else:
|
||||
httpout.write("<AREA SHAPE=\"RECT\""
|
||||
" COORDS=\"%i,%i,%i,%i\""
|
||||
" ALT=\"%s\" HREF=\"%s\">\n"
|
||||
" ALT=\"%s\" HREF=\"%s\">\n".decode('utf-8', errors='ignore')
|
||||
% (xmin, ymin, xmax, ymax, turl, turl))
|
||||
|
||||
i += 1
|
||||
|
Loading…
Reference in New Issue
Block a user