Permalink
Browse files

Normalize newly-minted normalized guids to http, but match normalized…

… guids entirely regardless of http/https protocol prefix
  • Loading branch information...
Rad Geek
Rad Geek committed Sep 13, 2017
1 parent cb385a2 commit dc8adbbb89b6054033b0b1da3758b319c42ad02b
Showing with 18 additions and 0 deletions.
  1. +16 −0 syndicatedpost.class.php
  2. +2 −0 syndicationdataqueries.class.php
View
@@ -615,6 +615,22 @@ static function normalize_guid ($guid) {
return $guid;
} /* SyndicatedPost::normalize_guid() */
static function alternative_guid_prefix () {
$url = trailingslashit(home_url(/*path=*/ '', /*scheme=*/ 'https'));
return apply_filters('syndicated_item_guid_normalized_prefix', $url . '?guid=');
}
static function alternative_guid ($guid) {
$guid = trim($guid);
if (preg_match('/^[0-9a-z]{32}$/i', $guid)) : // MD5
$guid = SyndicatedPost::alternative_guid_prefix().strtolower($guid);
elseif ((strlen(esc_url($guid)) == 0) or (esc_url($guid) != $guid)) :
$guid = SyndicatedPost::alternative_guid_prefix().md5($guid);
endif;
$guid = trim($guid);
return $guid;
} /* SyndicatedPost::normalize_guid() */
function guid () {
$guid = null;
if (isset($this->item['id'])): // Atom 0.3 / 1.0
@@ -47,13 +47,15 @@ function posts_search ($search, &$query) {
// MD5 hashes
if (preg_match('/^[0-9a-f]{32}$/i', $guid)) :
$seek[] = SyndicatedPost::normalize_guid_prefix().$guid;
$seek[] = SyndicatedPost::alternative_guid_prefix().$guid;
endif;
// Invalid URIs, URIs that WordPress just doesn't like, and URIs
// that WordPress decides to munge.
$nGuid = SyndicatedPost::normalize_guid($guid);
if ($guid != $nGuid) :
$seek[] = $nGuid;
$seek[] = SyndicatedPost::alternative_guid($guid);
endif;
// Escape to prevent frak-ups, injections, etc.

0 comments on commit dc8adbb

Please sign in to comment.