From decb3365ac63c2df28743819af655568cac26dc9 Mon Sep 17 00:00:00 2001 From: ozh Date: Sat, 28 Dec 2013 17:32:57 +0100 Subject: [PATCH] urldecode() before processing. Also, Tumblr share. Not sure why, but urldecode() is required on some host (tested on tso.io), otherwise the URL shortened ends up like http://http%3A%2F%2Fblah.cmo%2F --- admin/index.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/admin/index.php b/admin/index.php index 68f1e7b..3ad4090 100644 --- a/admin/index.php +++ b/admin/index.php @@ -137,10 +137,10 @@ // No sanitization needed here: everything happens in yourls_add_new_link() if( isset( $_GET['u'] ) ) { // Old school bookmarklet: ?u= - $url = $_GET['u']; + $url = rawurldecode( $_GET['u'] ); } else { // New style bookmarklet: ?up=&us=&ur= - $url = $_GET['up'] . $_GET['us'] . $_GET['ur']; + $url = rawurldecode( $_GET['up'] . $_GET['us'] . $_GET['ur'] ); } $keyword = ( isset( $_GET['k'] ) ? ( $_GET['k'] ) : '' ); $title = ( isset( $_GET['t'] ) ? ( $_GET['t'] ) : '' ); @@ -178,7 +178,7 @@ switch ( $_GET['share'] ) { case 'twitter': // share with Twitter - $destination = sprintf( "https://twitter.com/intent/tweet?url=%s&text=%s", urlencode( $return['shorturl'] ), urlencode( $_GET['t'] ) ); + $destination = sprintf( "https://twitter.com/intent/tweet?url=%s&text=%s", urlencode( $return['shorturl'] ), urlencode( $title ) ); yourls_redirect( $destination, 303 ); // Deal with the case when redirection failed: @@ -189,7 +189,7 @@ case 'facebook': // share with Facebook - $destination = sprintf( "https://www.facebook.com/sharer/sharer.php?u=%s&t=%s", urlencode( $return['shorturl'] ), urlencode( $_GET['t'] ) ); + $destination = sprintf( "https://www.facebook.com/sharer/sharer.php?u=%s&t=%s", urlencode( $return['shorturl'] ), urlencode( $title ) ); yourls_redirect( $destination, 303 ); // Deal with the case when redirection failed: @@ -198,6 +198,17 @@ $return['message'] = yourls_s( 'Short URL created, but could not redirect to %s !', 'Facebook' ); break; + case 'tumblr': + // share with Tumblr + $destination = sprintf( "http://www.tumblr.com/share?v=3&u=%s&t=%s&s=%s", urlencode( $return['shorturl'] ), urlencode( $title ), urlencode( $text ) ); + yourls_redirect( $destination, 303 ); + + // Deal with the case when redirection failed: + $return['status'] = 'error'; + $return['errorCode'] = 400; + $return['message'] = yourls_s( 'Short URL created, but could not redirect to %s !', 'Tumblr' ); + break; + default: // Is there a custom registered social bookmark? yourls_do_action( 'share_redirect_' . $_GET['share'], $return ); -- 2.45.0