From ec42aa12bf5ac9f9926003ead78f54d1ed35ba52 Mon Sep 17 00:00:00 2001 From: VG Date: Sat, 29 Nov 2014 23:35:06 +0100 Subject: add consistency in encoding for file i/o --- pasteme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pasteme.py b/pasteme.py index fae3922..68a93f3 100755 --- a/pasteme.py +++ b/pasteme.py @@ -39,8 +39,8 @@ def route_paste_get(pid, pformat='colored'): return bottle.template('bad_format') path = pathbase / pid try: - with path.open() as fd: - content = fd.read() + with path.open(mode='rb') as fd: + content = fd.read().decode('utf8') except IOError: # use this template for all file based exception bottle.abort(404) -- cgit v1.2.3 From 7c6c10f8e5bae9f112dcde5f8cc3bf7bf178db41 Mon Sep 17 00:00:00 2001 From: VG Date: Sat, 29 Nov 2014 23:57:08 +0100 Subject: fix pasteme script when no ascii data is used --- scripts/pasteme | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/pasteme b/scripts/pasteme index db4b641..fe1f720 100755 --- a/scripts/pasteme +++ b/scripts/pasteme @@ -6,5 +6,7 @@ if [ "$file" == "" ]; then file=- fi -cat "$file" \ - | curl -w '%{redirect_url}\n' --form 'content=<-' http://paste.devys.org/ +sed '1s/^/content=/' "$file" \ + | curl -w '%{redirect_url}\n' \ + -X POST -H "Content-Type: text/plain; charset=UTF-8" \ + --data-binary @- http://paste.devys.org/ -- cgit v1.2.3