summaryrefslogtreecommitdiffstats
path: root/fb.in
diff options
context:
space:
mode:
Diffstat (limited to 'fb.in')
-rw-r--r--fb.in24
1 files changed, 21 insertions, 3 deletions
diff --git a/fb.in b/fb.in
index ce85695..b63ac28 100644
--- a/fb.in
+++ b/fb.in
@@ -63,9 +63,27 @@ do_upload() {
return 1
fi
fi
- if ! $LIBDIR/fb-upload "$PASTEBIN/file/do_upload" "$file" > $TMPFILE; then
- EXITCODE=1
- return 1
+
+ # fb-upload handles corner cases (comma in the filename) better
+ if [ -x "$LIBDIR/fb-upload" ]; then
+ if ! $LIBDIR/fb-upload "$PASTEBIN/file/do_upload" "$file" > $TMPFILE; then
+ EXITCODE=1
+ return 1
+ fi
+ else
+ CURLOPTS="-# -n -L -A $USERAGENT $EXTRA"
+ if [ `stat -c %s -- "$file"` -eq "0" ] || echo "$file" | grep -F -q ","; then
+ basefilename=`echo "$basefilename" | tr -d ,`
+ if ! curl $CURLOPTS -F "file=@-;filename=$basefilename" "$PASTEBIN/file/do_upload" < "$file" > $TMPFILE; then
+ EXITCODE=1
+ return 1
+ fi
+ else
+ if ! curl $CURLOPTS -F "file=@$file" "$PASTEBIN/file/do_upload" > $TMPFILE; then
+ EXITCODE=1
+ return 1
+ fi
+ fi
fi
sed '$d' $TMPFILE >&2
URL=`tail -1 $TMPFILE`"$EXTENSION"