diff options
author | Photon89 | 2017-01-28 16:19:19 +0100 |
---|---|---|
committer | Photon89 | 2017-01-28 16:19:19 +0100 |
commit | a1ac132bdfa6613d558ffe84495fe12610707f7d (patch) | |
tree | dce1806251e38a8224e402d924806eeef6427572 | |
parent | d1ed17573bdc71218d98664247a022d85c964ed0 (diff) | |
download | aur-a1ac132bdfa6613d558ffe84495fe12610707f7d.tar.gz |
Added patch fixing imgur upload
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 11 | ||||
-rw-r--r-- | fix-imgur.patch | 342 |
3 files changed, 353 insertions, 6 deletions
@@ -1,7 +1,7 @@ pkgbase = shutter pkgdesc = a featureful screenshot tool (formerly gscrot) pkgver = 0.93.1 - pkgrel = 4 + pkgrel = 5 url = http://shutter-project.org/ arch = any license = GPL3 @@ -9,7 +9,7 @@ pkgbase = shutter depends = imagemagick depends = procps depends = librsvg - depends = gnome-perl + depends = gtk2-perl depends = desktop-file-utils depends = perl-gnome2-wnck depends = perl-gtk2-imageview @@ -43,11 +43,13 @@ pkgbase = shutter source = fix-dropbox.patch source = fix-unicode.patch source = fix-second-instance-crash.patch + source = fix-imgur.patch sha512sums = 50a635fdf73454b15351a7e2c4507bf0f9fd816273affbed412f42b1032087304ecf1fb4a4b655bc056820f267b98214ff5104f4fcd9e843f78e70ac4a7a4a04 sha512sums = 4307cdfe9409e3ff66c74730caa99932e1b8a2698012e948b974157219f4fc572117dd1968b29f6ea08736c0fa44a62cdb11855456cff8c280f4cd60edbc1ed6 sha512sums = 88fe92c33ba2e580328589d0f1f5639aa40580f96fbc92d05903167f87053d02f472d6afcc839ca18029df6fac065c108c440da551d86494c70b1219b0b032dc sha512sums = 52ac381b5b1bd1ac5ba40cb3f6f425fbfcb5f491855af8c19494b64ba5311e6fdc3579e334a38167e1391cd57aae8d4312e389529d594aade53c6f8a49bc66c8 sha512sums = cb6fee947f62d0fdf1f4810136782df8097e764760d6e66fc80945c88af137e4524ab8ec1abd44f9439c1b6c408fe1de779a1c0ff930be0521bedc117c39d4ac + sha512sums = 7c7ff590237bb2bd5b54aeec7ad013542d6f64624fa16c0f129875cca908f6d8666328edd2ebf1fa80bdedc683785ba75516d8fdee9ca25b48aca117fb89baf6 pkgname = shutter @@ -8,12 +8,12 @@ pkgname=shutter pkgver=0.93.1 -pkgrel=4 +pkgrel=5 pkgdesc="a featureful screenshot tool (formerly gscrot)" arch=('any') url="http://shutter-project.org/" license=('GPL3') -depends=(xdg-utils imagemagick procps librsvg gnome-perl desktop-file-utils +depends=(xdg-utils imagemagick procps librsvg gtk2-perl desktop-file-utils perl-{gnome2-wnck,gtk2-{imageview,unique},x11-protocol} perl-{proc-{simple,processtable},net-dbus} perl-{sort-naturally,json,json-xs,xml-simple,www-mechanize,locale-gettext} @@ -31,12 +31,14 @@ source=("http://shutter-project.org/wp-content/uploads/releases/tars/$pkgname-$p CVE-2015-0854.patch fix-dropbox.patch fix-unicode.patch - fix-second-instance-crash.patch) + fix-second-instance-crash.patch + fix-imgur.patch) sha512sums=('50a635fdf73454b15351a7e2c4507bf0f9fd816273affbed412f42b1032087304ecf1fb4a4b655bc056820f267b98214ff5104f4fcd9e843f78e70ac4a7a4a04' '4307cdfe9409e3ff66c74730caa99932e1b8a2698012e948b974157219f4fc572117dd1968b29f6ea08736c0fa44a62cdb11855456cff8c280f4cd60edbc1ed6' '88fe92c33ba2e580328589d0f1f5639aa40580f96fbc92d05903167f87053d02f472d6afcc839ca18029df6fac065c108c440da551d86494c70b1219b0b032dc' '52ac381b5b1bd1ac5ba40cb3f6f425fbfcb5f491855af8c19494b64ba5311e6fdc3579e334a38167e1391cd57aae8d4312e389529d594aade53c6f8a49bc66c8' - 'cb6fee947f62d0fdf1f4810136782df8097e764760d6e66fc80945c88af137e4524ab8ec1abd44f9439c1b6c408fe1de779a1c0ff930be0521bedc117c39d4ac') + 'cb6fee947f62d0fdf1f4810136782df8097e764760d6e66fc80945c88af137e4524ab8ec1abd44f9439c1b6c408fe1de779a1c0ff930be0521bedc117c39d4ac' + '7c7ff590237bb2bd5b54aeec7ad013542d6f64624fa16c0f129875cca908f6d8666328edd2ebf1fa80bdedc683785ba75516d8fdee9ca25b48aca117fb89baf6') prepare() { cd "$srcdir/$pkgname-$pkgver" @@ -49,6 +51,7 @@ prepare() { patch -p0 < "${srcdir}/fix-dropbox.patch" patch -p0 < "${srcdir}/fix-unicode.patch" patch -p0 < "${srcdir}/fix-second-instance-crash.patch" + patch -p0 < "${srcdir}/fix-imgur.patch" } package() { diff --git a/fix-imgur.patch b/fix-imgur.patch new file mode 100644 index 000000000000..30777f688a29 --- /dev/null +++ b/fix-imgur.patch @@ -0,0 +1,342 @@ +=== modified file 'bin/shutter' +--- bin/shutter 2014-12-23 23:02:02 +0000 ++++ bin/shutter 2017-01-28 09:57:21 +0000 +@@ -8353,7 +8353,10 @@ + #~ print $name, $folder, $type, "\n"; + + if ( !exists $accounts{$name} +- || !exists $accounts{$name}->{module} ) ++ || !exists $accounts{$name}->{module} ++ || $accounts{$name}->{supports_anonymous_upload} ne &fct_upload_plugin_get_info( $ukey, 'supports_anonymous_upload' ) || ++ $accounts{$name}->{supports_authorized_upload} ne &fct_upload_plugin_get_info( $ukey, 'supports_authorized_upload' ) || ++ $accounts{$name}->{supports_oauth_upload} ne &fct_upload_plugin_get_info( $ukey, 'supports_oauth_upload' ) ) + { + + #show dialog and progress bar +@@ -10632,7 +10635,7 @@ + my $uploader = $hosting_module->new( $hosting_host, $sc->get_debug, $shutter_root, $d, $window, SHUTTER_VERSION ); + + #init module +- if ( $uploader->init ) { ++ if ( $uploader->init($hosting_username) ) { + + my $counter = 1; + $hosting_progress->set_fraction(0); + +=== modified file 'share/shutter/resources/modules/Shutter/App/Common.pm' +--- share/shutter/resources/modules/Shutter/App/Common.pm 2013-08-25 18:40:51 +0000 ++++ share/shutter/resources/modules/Shutter/App/Common.pm 2017-01-28 09:57:21 +0000 +@@ -48,7 +48,7 @@ + my $self = { _shutter_root => shift, _mainwindow => shift, _appname => shift, _version => shift, _rev => shift, _pid => shift }; + + #vars +- $self->{_debug_cparam} = FALSE; ++ $self->{_debug_cparam} = TRUE; + $self->{_clear_cache} = FALSE; + $self->{_min_cparam} = FALSE; + $self->{_disable_systray_cparam} = FALSE; + +=== modified file 'share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm' +--- share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm 2013-08-25 18:40:51 +0000 ++++ share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm 2017-01-28 09:57:21 +0000 +@@ -59,6 +59,7 @@ + my $detail_message = shift; + my $detail_checkbox = shift; + my $content_widget = shift; ++ my $content_widget2 = shift; + + my $info_dialog = Gtk2::MessageDialog->new( $self->{_window}, [qw/modal destroy-with-parent/], 'info', 'none', undef ); + +@@ -71,6 +72,9 @@ + if($content_widget){ + $info_dialog->get_content_area()->add($content_widget); + } ++ if($content_widget2){ ++ $info_dialog->get_content_area()->add($content_widget2); ++ } + + $info_dialog->add_button( $button_text_extra1, 10 ) if $button_text_extra1; + $info_dialog->add_button( $button_text_extra2, 20 ) if $button_text_extra2; + +=== modified file 'share/shutter/resources/system/upload_plugins/upload/Imgur.pm' +--- share/shutter/resources/system/upload_plugins/upload/Imgur.pm 2013-08-25 18:40:51 +0000 ++++ share/shutter/resources/system/upload_plugins/upload/Imgur.pm 2017-01-28 09:57:21 +0000 +@@ -29,7 +29,8 @@ + use strict; + use POSIX qw/setlocale/; + use Locale::gettext; +-use Glib qw/TRUE FALSE/; ++use Glib qw/TRUE FALSE/; ++use MIME::Base64; + + use Shutter::Upload::Shared; + our @ISA = qw(Shutter::Upload::Shared); +@@ -38,12 +39,13 @@ + $d->dir( $ENV{'SHUTTER_INTL'} ); + + my %upload_plugin_info = ( +- 'module' => "Imgur", ++ 'module' => "Imgur", + 'url' => "http://imgur.com/", + 'registration' => "https://imgur.com/register", + 'description' => $d->get( "Imgur is used to share photos with social networks and online communities, and has the funniest pictures from all over the Internet" ), +- 'supports_anonymous_upload' => TRUE, ++ 'supports_anonymous_upload' => TRUE, + 'supports_authorized_upload' => FALSE, ++ 'supports_oauth_upload' => TRUE, + ); + + binmode( STDOUT, ":utf8" ); +@@ -66,13 +68,128 @@ + + sub init { + my $self = shift; ++ my $username = shift; + +- #do custom stuff here ++ #do custom stuff here + use JSON; + use LWP::UserAgent; + use HTTP::Request::Common; +- +- return TRUE; ++ use Path::Class; ++ ++ $self->{_config} = { }; ++ $self->{_config_file} = file( $ENV{'HOME'}, '.imgur-api-config' ); ++ ++ $self->load_config; ++ if ($username eq $d->get("OAuth")) ++ { ++ return $self->connect; ++ } ++ ++ return TRUE; ++} ++ ++sub load_config { ++ my $self = shift; ++ ++ if (-f $self->{_config_file}) { ++ eval { ++ $self->{_config} = decode_json($self->{_config_file}->slurp); ++ }; ++ if ($@) { ++ $self->{_config}->{client_id} = '9490811e0906b6e'; ++ $self->{_config}->{client_secret} = '158b57f13e9a51f064276bd9e31529fb065f741e'; ++ } ++ } ++ else { ++ $self->{_config}->{client_id} = '9490811e0906b6e'; ++ $self->{_config}->{client_secret} = '158b57f13e9a51f064276bd9e31529fb065f741e'; ++ } ++ ++ return TRUE; ++} ++ ++sub connect { ++ my $self = shift; ++ return $self->setup; ++} ++ ++sub setup { ++ my $self = shift; ++ ++ if ($self->{_debug_cparam}) { ++ print "Setting up Imgur...\n"; ++ } ++ ++ #some helpers ++ my $sd = Shutter::App::SimpleDialogs->new; ++ ++ #Authentication ++ my $login_link = 'https://api.imgur.com/oauth2/authorize?response_type=pin&client_id=' . $self->{_config}->{client_id}; ++ ++ my $pin_entry = Gtk2::Entry->new(); ++ my $pin = ''; ++ $pin_entry->signal_connect(changed => sub { ++ $pin = $pin_entry->get_text; ++ }); ++ ++ my $response = $sd->dlg_info_message( ++ $d->get("Please click on the button below to authorize with Imgur. Input the PIN you receive and press 'Apply' when you are done."), ++ $d->get("Authorize with Imgur"), ++ 'gtk-cancel','gtk-apply', undef, ++ undef, undef, undef, undef, undef, ++ Gtk2::LinkButton->new ($login_link, $d->get("Authorize")), ++ $pin_entry, ++ ); ++ if ($response == 20) { ++ ++ if ($self->{_debug_cparam}) { ++ print "Imgur: Authorizing...\n"; ++ } ++ ++ my %params = ( ++ 'client_id' => $self->{_config}->{client_id}, ++ 'client_secret' => $self->{_config}->{client_secret}, ++ 'grant_type' => 'pin', ++ 'pin' => $pin, ++ ); ++ ++ my @params = ( ++ "https://api.imgur.com/oauth2/token", ++ 'Content' => [%params] ++ ); ++ ++ my $req = HTTP::Request::Common::POST(@params, 'Authorization' => 'Client-ID ' . $self->{_config}->{client_id}); ++ ++ my $client = LWP::UserAgent->new( ++ 'timeout' => 20, ++ 'keep_alive' => 10, ++ 'env_proxy' => 1, ++ ); ++ my $rsp = $client->request($req); ++ ++ my $json = JSON->new(); ++ my $json_rsp = $json->decode($rsp->content); ++ ++ if ($self->{_debug_cparam}) { ++ print $pin . ' ' . $rsp->content; ++ } ++ if (exists $json_rsp->{status} && $json_rsp->{status} ne 200) { ++ return $self->setup; ++ } ++ ++ $self->{_config}->{access_token} = $json_rsp->{access_token}; ++ $self->{_config}->{refresh_token} = $json_rsp->{refresh_token}; ++ $self->{_config}->{account_id} = $json_rsp->{account_id}; ++ $self->{_config}->{account_username} = $json_rsp->{account_username}; ++ ++ $self->{_config_file}->openw->print(encode_json($self->{_config})); ++ chmod 0600, $self->{_config_file}; ++ ++ return TRUE; ++ } ++ else { ++ return FALSE; ++ } + } + + sub upload { +@@ -87,62 +204,66 @@ + utf8::encode $password; + utf8::encode $username; + +- #~ if ( $username ne "" && $password ne "" ) { +- +- my $client = LWP::UserAgent->new( +- 'timeout' => 20, +- 'keep_alive' => 10, +- 'env_proxy' => 1, +- ); +- +- eval{ +- +- my $json = JSON->new(); +- +- my %params = ( +- 'image' => [$upload_filename], +- 'key' => '12ea5e932124142c5ef3c8d5a02557de', +- ); +- +- my @params = ( +- "http://api.imgur.com/1/upload.json", +- 'Content_Type' => 'multipart/form-data', +- 'Content' => [%params] +- ); +- +- my $req = HTTP::Request::Common::POST(@params); +- my $rsp = $client->request($req); +- +- #~ print Dumper $json->decode( $rsp->content ); +- +- $self->{_links} = $json->decode( $rsp->content ); +- $self->{_links} = $self->{_links}->{'rsp'}; +- if(defined $self->{_links}->{'stat'} && $self->{_links}->{'stat'} eq 'ok'){ +- $self->{_links} = $self->{_links}->{'image'}; +- #clean hash +- foreach (keys %{$self->{_links}}){ +- if($_ eq 'delete_hash' || $_ eq 'image_hash'){ +- delete $self->{_links}->{$_}; +- next; +- } +- if( $self->{_debug_cparam}) { +- print $_.": ".$self->{_links}->{$_}, "\n"; +- } +- } +- #set status (success) +- $self->{_links}{'status'} = 200; +- }else{ +- $self->{_links}{'status'} = $self->{_links}->{'image'}->{'error_msg'}; ++ my $client = LWP::UserAgent->new( ++ 'timeout' => 20, ++ 'keep_alive' => 10, ++ 'env_proxy' => 1, ++ ); ++ ++ eval { ++ ++ my $json = JSON->new(); ++ ++ open( IMAGE, $upload_filename ) or die "$!"; ++ my $binary_data = do { local $/ = undef; <IMAGE>; }; ++ close IMAGE; ++ my $encoded_image = encode_base64($binary_data); ++ ++ my %params = ( ++ 'image' => $encoded_image, ++ ); ++ ++ my @params = ( ++ "https://api.imgur.com/3/image", ++ 'Content' => [%params] ++ ); ++ ++ my $req; ++ if ($username eq $d->get("OAuth") && $self->{_config}->{access_token}) { ++ $req = HTTP::Request::Common::POST(@params, 'Authorization' => 'Bearer ' . $self->{_config}->{access_token}); ++ } ++ else { ++ $req = HTTP::Request::Common::POST(@params, 'Authorization' => 'Client-ID ' . $self->{_config}->{client_id}); ++ } ++ my $rsp = $client->request($req); ++ ++ #~ print Dumper $json->decode( $rsp->content ); ++ ++ my $json_rsp = $json->decode( $rsp->content ); ++ ++ if ($json_rsp->{'status'} ne 200) { ++ unlink $self->{_config_file}; ++ $self->{_links}{'status'} = ''; ++ if (exists $json_rsp->{'data'}->{'error'}) { ++ $self->{_links}{'status'} .= $json_rsp->{'data'}->{'error'} . ': '; + } +- +- }; +- if($@){ +- $self->{_links}{'status'} = $@; +- #~ print "$@\n"; ++ $self->{_links}{'status'} .= $d->get("Maybe you or Imgur revoked or expired an access token. Please close this dialog and try again. Your account will be re-authenticated the next time you upload a file."); ++ return %{ $self->{_links} }; + } + +- #~ } +- ++ $self->{_links}{'status'} = $json_rsp->{'status'}; ++ $self->{_links}->{'direct_link'} = $json_rsp->{'data'}->{'link'}; ++ $self->{_links}->{'deletion_link'} = 'https://imgur.com/delete/' . $json_rsp->{'data'}->{'deletehash'}; ++ $self->{_links}->{'post_link'} = $json_rsp->{'data'}->{'link'}; ++ $self->{_links}->{'post_link'} =~ s/i\.imgur/imgur/; ++ $self->{_links}->{'post_link'} =~ s/\.[^.]+$//; ++ ++ }; ++ if ($@) { ++ $self->{_links}{'status'} = $@; ++ #~ print "$@\n"; ++ } ++ + #and return links + return %{ $self->{_links} }; + } + |