aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Murphy <alec@checksum.fail>2017-02-21 18:57:24 -0500
committerAlec Murphy <alec@checksum.fail>2017-02-21 18:57:24 -0500
commit5fe4ab849c9ab86beae46c0a20707025b8316231 (patch)
tree7c827e8e22a1102fd61dddff059f1436c1475795
parent30e0fd52d8167eb799fb27c1a3ccaf5a6138684f (diff)
Fix some queries and formatting
-rwxr-xr-xUriel.HC6
-rw-r--r--uriel.py20
2 files changed, 19 insertions, 7 deletions
diff --git a/Uriel.HC b/Uriel.HC
index a13e741..f6b7465 100755
--- a/Uriel.HC
+++ b/Uriel.HC
@@ -32,7 +32,7 @@ U0 U_InsertThumb(U8 *anchor, U8 *indent, U8 *outdent, U8 *url)
HGExec(URIEL_THUMB);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
- if (size==-1) {
+ if (size<1) {
PopUpOk("Error loading image.");
return;
};
@@ -66,7 +66,7 @@ U0 U_Browser(U8 *url)
HGExec(URIEL_GETPAGE);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
- if (size==-1) {
+ if (size<1) {
PopUpOk("Bad URL.");
return;
};
@@ -132,7 +132,7 @@ U0 U_HistNav(I64 index)
if (index==1) { HGExec(URIEL_NAVFWD); };
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
- if (size==-1) {
+ if (size<1) {
PopUpOk("Bad URL.");
return;
};
diff --git a/uriel.py b/uriel.py
index de0487a..6de9736 100644
--- a/uriel.py
+++ b/uriel.py
@@ -67,6 +67,8 @@ def UrielGetPage():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
+ if url_comp.query != '':
+ post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
pagedata = subprocess.Popen('wget -q -O - -U "' + Uriel.user_agent + '" "' + url + '" 2>/dev/null', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
filedata = UrielPreProcess(pagedata, url)
@@ -149,6 +151,8 @@ def UrielNavBack():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
+ if url_comp.query != '':
+ post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
filesize = len(filedata)
if filesize>0:
@@ -203,6 +207,8 @@ def UrielNavFwd():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
+ if url_comp.query != '':
+ post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
filesize = len(filedata)
if filesize>0:
@@ -260,6 +266,8 @@ def UrielThumb():
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
+ if url_comp.query != '':
+ post_scheme += '?'+url_comp.query
url = scheme + "://" + post_scheme
tmp_thumb = '/tmp/' + str(uuid.uuid4()) + '.bmp'
while os.path.exists(tmp_thumb):
@@ -290,9 +298,13 @@ def UrielPreProcess(htm1, l_url):
title_text = ''
hb_header = '$WW,1$$BLACK$$MA+LIS,"[Close]",LM="U_CloseBrowser;"$ $MA+LIS,"[Back]",LM="U_HistNav(0);"$ $MA+LIS,"[Fwd]",LM="U_HistNav(1);"$ $MA+LIS,"[Go]",LM="U_Browser(GetStr(\\"\nURL> \\"));"$ ' + title_text + '\n\n'
- if htm1.upper().find('<HTML') == -1:
- dl_link = '$AN,"",A="BINARY"$Click $MA+LIS,"[Here]",LM="U_Download(\\"' + l_url + '\\");"$ to download the file:\n\n' + l_url
- return hb_header + dl_link
+ doc_detect = False
+ if htm1.upper().find('<HTML') != -1:
+ doc_detect = True
+ if htm1.upper().find('<!DOCTYPE HTML') != -1:
+ doc_detect = True
+ if doc_detect == False:
+ return '$AN,"",A="BINARY"$'
htm1 = htm1[htm1.upper().find('<HTML'):]
htm1 = htm1.replace('$', '$$')
@@ -331,7 +343,7 @@ def UrielPreProcess(htm1, l_url):
if tag.name.upper() != 'IMG':
tag.decompose()
- remove_tags = [ 'svg', 'embed', 'head', 'noscript', 'object', 'param', 'script', 'option' ]
+ remove_tags = [ 'style', 'svg', 'embed', 'head', 'noscript', 'object', 'param', 'script', 'option' ]
for tag in remove_tags:
[s.extract() for s in soup1(tag)]