WordPress.org

Make WordPress Core

Changeset 31537


Ignore:
Timestamp:
02/25/2015 03:57:43 AM (5 years ago)
Author:
azaozz
Message:

Press This: JSON encode the URL before appending it to the bookmarklet. See #31373.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r31535 r31537  
    26092609         */
    26102610        $ua = $_SERVER['HTTP_USER_AGENT'];
    2611        
     2611
    26122612        if ( ! empty( $ua ) && preg_match( '/\bMSIE (\d)/', $ua, $matches ) && (int) $matches[1] <= 8 ) {
    2613             $link = "javascript:
    2614                 var d=document,
    2615                 w=window,
    2616                 e=w.getSelection,
    2617                 k=d.getSelection,
    2618                 x=d.selection,
    2619                 s=(e?e():(k)?k():(x?x.createRange().text:0)),
    2620                 f='" . admin_url('press-this.php') . "',
    2621                 l=d.location,
    2622                 e=encodeURIComponent,
    2623                 u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=" . $bookmarklet_version . "';
    2624                 a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700'))l.href=u;};
    2625                 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();
    2626                 void(0)";
     2613            $url = wp_json_encode( admin_url( 'press-this.php' ) );
     2614
     2615            $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' .
     2616                's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' .
     2617                'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' .
     2618                'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' .
     2619                'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
    26272620        }
    26282621    }
    26292622
    26302623    if ( empty( $link ) ) {
     2624        $url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . $bookmarklet_version );
     2625
    26312626        /**
    26322627         * A non-minified version if this script is in /wp-admin/js/bookmarklet.js
     
    26572652            'f=a.outerWidth||b.documentElement.clientWidth||600,g=a.outerHeight||b.documentElement.clientHeight||700,f=800>f||f>5e3?600:.7*f,' .
    26582653            'g=800>g||g>3e3?700:.9*g,a.open("about:blank",s,"width="+f+",height="+g),b.body.appendChild(p),p.submit()}}' .
    2659             '(window,document,top.location.href,"' . admin_url( 'press-this.php' ) . '?v=' . $bookmarklet_version . '");';
     2654            '(window,document,top.location.href,' . $url . ');';
    26602655    }
    26612656
Note: See TracChangeset for help on using the changeset viewer.