Make WordPress Core

Ticket #31645: 31645-make-fully-qualified.diff

File 31645-make-fully-qualified.diff, 819 bytes (added by stephdau, 10 years ago)

Suggestion to make canonical links fully qualified.

  • src/wp-admin/includes/class-wp-press-this.php

     
    928928                        $link = $data['_links']['shortlink'];
    929929                }
    930930
     931                if ( ! preg_match( '/^https?:/', $link ) ) {
     932                        if ( preg_match( '/^[\/]{1}[^\/]+/', $link ) ) {
     933                                // From root: /blah
     934                                $link = preg_replace( '/^(https?:\/\/[^\/]+)(\/.*)?$/', '\1', $data['u'] ) . $link;
     935                        } else if ( preg_match( '/^[\/]{2}[^\/]+/', $link ) ) {
     936                                // Protocol relative: //blah.com/blah
     937                                $link = preg_replace( '/^(https?:)\/\/.+$/', '\1', $data['u'] ) . $link;
     938                        } else {
     939                                // Relative, or diff protocol
     940                                return '';
     941                        }
     942                }
     943
    931944                return $link;
    932945        }
    933946