Преглед изворни кода

Trim feed links detected from a website to strip newlines - fixes ZF-8327

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19028 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic пре 16 година
родитељ
комит
23d618dd3e
2 измењених фајлова са 24 додато и 4 уклоњено
  1. 4 4
      library/Zend/Feed/Reader/FeedSet.php
  2. 20 0
      tests/Zend/Feed/ReaderTest.php

+ 4 - 4
library/Zend/Feed/Reader/FeedSet.php

@@ -62,16 +62,16 @@ class Zend_Feed_Reader_FeedSet extends ArrayObject
                 continue;
             }
             if (!isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') {
-                $this->rss = $link->getAttribute('href');
+                $this->rss = trim($link->getAttribute('href'));
             } elseif(!isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') {
-                $this->atom = $link->getAttribute('href');
+                $this->atom = trim($link->getAttribute('href'));
             } elseif(!isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') {
-                $this->rdf = $link->getAttribute('href');
+                $this->rdf = trim($link->getAttribute('href'));
             }
             $this[] = new self(array(
                 'rel' => 'alternate',
                 'type' => $link->getAttribute('type'),
-                'href' => $link->getAttribute('href'),
+                'href' => trim($link->getAttribute('href')),
             ));
         }
     }

+ 20 - 0
tests/Zend/Feed/ReaderTest.php

@@ -213,6 +213,26 @@ class Zend_Feed_ReaderTest extends PHPUnit_Framework_TestCase
         $links = Zend_Feed_Reader::findFeedLinks('http://www.example.com');
         $this->assertEquals(0, count($links));
     }
+    
+    /**
+     * @group ZF-8327
+     */
+    public function testGetsFeedLinksAndTrimsNewlines()
+    {
+        if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
+            || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
+        ) {
+            $this->markTestSkipped('testGetsFeedLinksAsValueObject() requires a network connection');
+            return;
+        }
+
+        try {
+            $links = Zend_Feed_Reader::findFeedLinks('http://www.infopod.com.br');
+        } catch(Exception $e) {
+            $this->fail($e->getMessage());
+        }
+        $this->assertEquals('http://feeds.feedburner.com/jonnyken/infoblog', $links->rss);
+    }
 
     public function testAddsPrefixPath()
     {