Skip to content

Commit

Permalink
Return to title fetch helper of 1.2
Browse files Browse the repository at this point in the history
The fetch helper does not obey rules and returns an array of bytes.
Naturally, the templace expansion tracebacks. The proper solution is
to get rid of SGMLhelper and find a parser that returns unicode.
But for now, just back Christian's code out.
  • Loading branch information
zaitcev committed Aug 6, 2012
1 parent bf56b71 commit c4fccc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README
Expand Up @@ -11,10 +11,11 @@ TODO:
- macro variables list - document starting with underscore
- parse and beautify devel notes (again)
- make .substitute to return a list-of-strings; million useless .join now
- replace sgmllib.SGMLParser with something better. Fails at HTML:
http://www.reallifecomics.com/
<title>Real Life Comics - The Online Comic &copy;1999-2010 Greg Dean</title>

fixup TODO for templates:
- Hitting "Preload" ends with same, in fetch_get()
Maybe just drop templating for the helper.
- remove flooding print from template.py - 'str found:' etc. Kill all print.
- rename "jsondict" into something sensible
- http://elanor.zaitcev.lan/slasti/zaitcev/login?savedref=new?
Expand Down
10 changes: 5 additions & 5 deletions slasti/main.py
Expand Up @@ -209,7 +209,8 @@ def fetch_body(url):
#
# The server-side indirection requires extreme care to prevent abuse.
# User may hit us with URLs that point to generated pages, slow servers, etc.
# As the last resort, we never work as a generic proxy.
# Also, security. As the first defense, we require user to be logged in.
# As the last resort, we never work as a generic proxy: only return the title.
#
def fetch_get(start_response, ctx):
url = ctx.get_query_arg("url")
Expand All @@ -218,10 +219,9 @@ def fetch_get(start_response, ctx):
body = fetch_body(url)
title = fetch_parse(body)

start_response("200 OK", [('Content-type', 'text/plain; charset=utf-8')])
# XXX Ewww, why substitute here? Just safe it out. Compare with 1.2.
jsondict = { "output": '%s\r\n' % title }
return [template_simple_output.substitute(jsondict)]
output = ['%s\r\n' % title]
start_response("200 OK", [('Content-type', 'text/plain')])
return output

def mark_post(start_response, ctx, mark):
argd = find_post_args(ctx)
Expand Down

0 comments on commit c4fccc6

Please sign in to comment.