Skip to content

Commit

Permalink
Release v1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
markasoftware committed Mar 6, 2023
2 parents 8d4b95d + a7ff3c2 commit bf9319a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 45 deletions.
44 changes: 10 additions & 34 deletions anypaste
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# shellcheck disable=2064

export ap_version ap_mac ap_path ap_human_name ap_human_name_escaped ap_mime ap_size ap_plugin ap_last_stdout
ap_version_text='Anypaste 1.1.5'
ap_version_text='Anypaste 1.1.6'
[[ $OSTYPE == darwin* ]] && ap_mac='true' || ap_mac='false'
shopt -s extglob

Expand Down Expand Up @@ -50,8 +50,7 @@ function curl_get {
# string json, string key -> string value
# make sure shopt -s extglob is on before using
# not standards compliant in any way shape or form, is designed specifically to work around strange
# cases present in anypaste plugins, mainly if the whole json is wrapped in a string so all
# actual strings inside of the json are escaped, eg: "{\"hello\":\"world\"}", see test.sh for more
# cases present in anypaste plugins
function json_parse {
local infernal_agony
infernal_agony="$1"
Expand All @@ -63,6 +62,8 @@ function json_parse {
# remove initial quote
infernal_agony=${infernal_agony:1}
infernal_agony=${infernal_agony%%\"*}
# remove backslashes escaping things such as forward slashes. This breaks if there's a literal backslash because it gets completely removed, but I don't think that's a problem for us...
infernal_agony=${infernal_agony//\\/}
else
# it can only be a number or a boolean, so it can't contain special characters at this point
infernal_agony=${infernal_agony%%[ ,\}]*}
Expand Down Expand Up @@ -220,19 +221,19 @@ function hastebin {
[[ $ap_mime == text/* ]] && check_size 400000
;;
upload)
hastebin_json=$(curl_file_upload 'POST' "$ap_path" 'https://hastebin.com/documents') || return 1
hastebin_json=$(curl_file_upload 'POST' "$ap_path" 'https://hastebin.skyra.pw/documents') || return 1
hastebin_id=$(json_parse "$hastebin_json" 'key')
echo 'Reminder: hastebin.com uploads are deleted 30 days after their last view!' >&2
echo >&2
echo "Link: https://hastebin.com/$hastebin_id"
echo "Direct: https://hastebin.com/raw/$hastebin_id"
echo "Link: https://hastebin.skyra.pw/$hastebin_id"
echo "Direct: https://hastebin.skyra.pw/raw/$hastebin_id"
echo
;;
get_info)
echo '[name]'
echo 'Hastebin'
echo '[description]'
echo 'Plain-text host with syntax highlighting and forking.'
echo 'Plain-text host with syntax highlighting and forking. The original hastebin.com was changed, so we use hastebin.skyra.pw'
echo '[tags]'
echo 'private'
echo 'direct'
Expand Down Expand Up @@ -421,31 +422,6 @@ function pixhost {
esac
}

function tinyimg {
case $1 in
check_eligibility)
[[ $ap_mime == image/* ]] && check_size 10000000
;;
upload)
tinyimg_json=$(curl_form_upload 'qqfile' 'https://tinyimg.io/upload') || return 1
tinyimg_filename=$(json_parse "$tinyimg_json" 'uploadName')
echo >&2
echo "Direct: https://tinyimg.io/i/$tinyimg_filename"
echo
;;
get_info)
echo '[name]'
echo 'Tinyimg'
echo '[description]'
echo 'Image host, super simple, direct links only.'
echo '[tags]'
echo 'private'
echo 'direct'
echo 'permanent'
;;
esac
}

function imgur {
case $1 in
check_eligibility)
Expand Down Expand Up @@ -1263,7 +1239,7 @@ function ap_create_config {
# You'll need to uncomment (remove # at beginning of line) first
# ap_plugins=(
# 'sendvid' 'streamable' 'gfycat' # Videos/Gifs
# 'tinyimg' 'imgur' 'pixhost' # Images
# 'imgur' 'pixhost' # Images
# # Audio
# 'ixio' 'pdefault' 'hastebin' 'pastie' 'paste2' # Text
# 'docdroid' # Documents
Expand Down Expand Up @@ -1460,7 +1436,7 @@ function ap_main {
ap_help='false'
ap_version='false'
ap_plugins=(
'sendvid' 'streamable' 'gfycat' 'tinyimg' 'imgur' 'pixhost' 'ixio' 'pdefault' 'hastebin' 'pastie' 'paste2' 'docdroid' 'bayfiles' 'keepsh' 'gofile' 'transfersh' 'filemail' 'fileio'
'sendvid' 'streamable' 'gfycat' 'imgur' 'pixhost' 'ixio' 'pdefault' 'hastebin' 'pastie' 'paste2' 'docdroid' 'bayfiles' 'keepsh' 'gofile' 'transfersh' 'filemail' 'fileio'
)
ap_hooks=()
ap_hook_policy='lazy'
Expand Down
10 changes: 5 additions & 5 deletions test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ function test_version() {

function test_basic_upload() {
local out exit_code
out=$(ap_main ./anypaste 2>&1)
out=$(ap_main -p haste ./anypaste 2>&1)
exit_code="$?"
assertEquals 'exit code' 0 "$exit_code"
assertTrue 'uploads to Hastebin' '[[ $out == *https://hastebin.com/+([a-z])* ]]'
assertTrue 'uploads to Hastebin' '[[ $out == *https://hastebin.skyra.pw/+([a-z])* ]]'
assertURLIsAnypaste "$out"
}

function test_p_upload() {
local out exit_code
out=$(ap_main -p ixio ./anypaste 2>&1)
out=$(ap_main ./anypaste 2>&1)
exit_code="$?"
assertEquals 'exit code' 0 "$exit_code"
assertTrue 'uploads to ixio' '[[ $out == *http://ix.io/+([a-zA-Z0-9])* ]]'
Expand All @@ -76,10 +76,10 @@ function test_p_upload() {

function test_stdin_upload() {
local out exit_code
out=$(ap_main < ./anypaste 2>&1)
out=$(ap_main -p haste < ./anypaste 2>&1)
exit_code="$?"
assertEquals 'exit code' 0 "$exit_code"
assertTrue 'uploads to Hastebin' '[[ $out == *https://hastebin.com/+([a-z])* ]]'
assertTrue 'uploads to Hastebin' '[[ $out == *https://hastebin.skyra.pw/+([a-z])* ]]'
assertURLIsAnypaste "$out"
}

Expand Down
7 changes: 1 addition & 6 deletions test-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@ function test_pixhost() {
function test_hastebin() {
uploadAndAssert hastebin "$text_fixture"
assertDirectLinkWorks 'uploads text fixture' "$text_fixture"
assertLabelPatternEquals 'hastebin normal link' 'Link' 'https://hastebin.com/+([a-z])'
assertLabelPatternEquals 'hastebin normal link' 'Link' 'https://hastebin.skyra.pw/+([a-z])'
}

function test_ixio() {
uploadAndAssert ixio "$text_fixture"
assertDirectLinkWorks 'uploads text fixture' "$text_fixture"
}

function test_tinyimg() {
uploadAndAssert tinyimg "$jpeg_fixture"
assertDirectLinkWorks 'uploads jpeg fixture' "$jpeg_fixture"
}

function test_imgur() {
uploadAndAssert imgur "$png_fixture"
assertLabelPatternEquals 'imgur direct link' 'Direct' 'https://i.imgur.com/+([0-9a-zA-z]).png'
Expand Down
3 changes: 3 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ test_json_parse() {
"bye": "sonny"
}' 'bye')
assertEquals 'multi line' 'sonny' "$out"

out=$(json_parse '{"hello":"wor\/ld"}' 'hello')
assertEquals 'escaped slash' 'wor/ld' "$out"
}

test_url_encode() {
Expand Down

0 comments on commit bf9319a

Please sign in to comment.