From b272020b379f79a766595462b37e1363869e63da Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 15 Sep 2019 14:51:04 +0200 Subject: [PATCH 1/4] Harmonize RSS feed with W3C recommendations 1. Declare Atom schema support 2. Escape international characters in URL 3. Ignore locale in date --- bl-plugins/rss/plugin.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index 207dafe5..a7a1d3d9 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -32,6 +32,11 @@ class pluginRSS extends Plugin { return $html; } + + private function urlRSS($url) + { + return preg_replace_callback('/[^\x20-\x7f]/', function($match) { return urlencode($match[0]); }, $url); + } private function createXML() { @@ -54,10 +59,11 @@ class pluginRSS extends Plugin { ); $xml = ''; - $xml .= ''; + $xml .= ''; $xml .= ''; + $xml .= ''; $xml .= ''.$site->title().''; - $xml .= ''.$site->url().''; + $xml .= ''.$this->urlRSS($site->url()).''; $xml .= ''.$site->description().''; $xml .= ''.date(DATE_RSS).''; @@ -68,7 +74,7 @@ class pluginRSS extends Plugin { $page = new Page($pageKey); $xml .= ''; $xml .= ''.$page->title().''; - $xml .= ''.$page->permalink().''; + $xml .= ''.$this->urlRSS($page->permalink()).''; $xml .= ''.Sanitize::html($page->contentBreak()).''; $xml .= ''.$page->date(DATE_RSS).''; $xml .= ''.$page->uuid().''; From 0340a18dc1bcffeb3386b41b8f4aaad83170b1b2 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 15 Sep 2019 14:52:50 +0200 Subject: [PATCH 2/4] Ignore locale in date --- bl-plugins/rss/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index a7a1d3d9..c2fce8af 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -76,7 +76,7 @@ class pluginRSS extends Plugin { $xml .= ''.$page->title().''; $xml .= ''.$this->urlRSS($page->permalink()).''; $xml .= ''.Sanitize::html($page->contentBreak()).''; - $xml .= ''.$page->date(DATE_RSS).''; + $xml .= ''.date('r',strtotime($page->getValue('dateRaw'))).''; $xml .= ''.$page->uuid().''; $xml .= ''; } catch (Exception $e) { From 2e8536cc0459be0867c381327af1d3536f72cfd2 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 16 Sep 2019 11:57:51 +0200 Subject: [PATCH 3/4] Use DATE_RSS constant in RSS pubDate --- bl-plugins/rss/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index c2fce8af..3041b241 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -76,7 +76,7 @@ class pluginRSS extends Plugin { $xml .= ''.$page->title().''; $xml .= ''.$this->urlRSS($page->permalink()).''; $xml .= ''.Sanitize::html($page->contentBreak()).''; - $xml .= ''.date('r',strtotime($page->getValue('dateRaw'))).''; + $xml .= ''.date(DATE_RSS,strtotime($page->getValue('dateRaw'))).''; $xml .= ''.$page->uuid().''; $xml .= ''; } catch (Exception $e) { From b10ee19033fe4fb2fca15e84fc7eed86e78a7d52 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 19 Sep 2019 11:52:28 +0200 Subject: [PATCH 4/4] Rename function encodeURL --- bl-plugins/rss/plugin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index 3041b241..f91ebe0a 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -33,7 +33,7 @@ class pluginRSS extends Plugin { return $html; } - private function urlRSS($url) + private function encodeURL($url) { return preg_replace_callback('/[^\x20-\x7f]/', function($match) { return urlencode($match[0]); }, $url); } @@ -63,7 +63,7 @@ class pluginRSS extends Plugin { $xml .= ''; $xml .= ''; $xml .= ''.$site->title().''; - $xml .= ''.$this->urlRSS($site->url()).''; + $xml .= ''.$this->encodeURL($site->url()).''; $xml .= ''.$site->description().''; $xml .= ''.date(DATE_RSS).''; @@ -74,7 +74,7 @@ class pluginRSS extends Plugin { $page = new Page($pageKey); $xml .= ''; $xml .= ''.$page->title().''; - $xml .= ''.$this->urlRSS($page->permalink()).''; + $xml .= ''.$this->encodeURL($page->permalink()).''; $xml .= ''.Sanitize::html($page->contentBreak()).''; $xml .= ''.date(DATE_RSS,strtotime($page->getValue('dateRaw'))).''; $xml .= ''.$page->uuid().'';