close issue #1 by properly handling " and ' characters

master
Benjamin 'blindCoder' Schieder 2017-04-26 20:23:31 +02:00
parent a6feb5618d
commit ca894cd1ca
2 changed files with 9 additions and 10 deletions

View File

@ -77,9 +77,14 @@ FEED: foreach my $feed (@feeds){
$status =~ s/{Modified}/$entry{modified}/g;
$status =~ s/{Tags}/$entry{tags}/g;
$status =~ s/'/'\\''/g;
my %data;
if (length($status) > 500){
$status =~ s/^(.{497}).*$/\1.../g;
}
$data{status} = $status;
$ENV{status} = encode_json({%data});
open(DATA, "./post_status.bash '$user->{data}->{access_token}' '$user->{data}->{instance}' '$status'|");
open(DATA, "./post_status.bash '$user->{data}->{access_token}' '$user->{data}->{instance}' |");
my $reply = "";
{
local $/ = undef;

View File

@ -1,9 +1,3 @@
#!/bin/bash
#!/bin/bash -x
status="${3}"
if [[ -n "${status:500}" ]]; then
status="${status:0:496}..."
fi
curl -sS -X POST --header "Authorization: Bearer ${1}" "${2}/api/v1/statuses" -d "status=${status}" 2>/dev/null
#https://cloud.digitalocean.com/v1/oauth/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=authorization_code&code=AUTHORIZATION_CODE&redirect_uri=CALLBACK_URL
echo "${status}" | curl -sS -X POST --header "Authorization: Bearer ${1}" --header "Content-Type: application/json;charset=utf-8" "${2}/api/v1/statuses" -d@- 2>/dev/null