aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2016-10-16 20:52:35 +0200
committerVirtualTam <virtualtam@flibidi.net>2016-10-16 20:58:15 +0200
commit44a718090d716e53c0e78bf3a0225fd2fb30071e (patch)
tree5f3c1db9194133b96b4a4c977a064abc6e550e12
parentbb70e690598d270951148e003a4dc253b05868b4 (diff)
downloadShaarli-44a718090d716e53c0e78bf3a0225fd2fb30071e.tar.gz
Shaarli-44a718090d716e53c0e78bf3a0225fd2fb30071e.tar.zst
Shaarli-44a718090d716e53c0e78bf3a0225fd2fb30071e.zip
Fix: return the proper value for the "self" feed attribute
Fixes https://github.com/shaarli/Shaarli/issues/629 Closes https://github.com/shaarli/Shaarli/pull/630 Note: you might need to empty the "pagecache" directory for the fix to be taken into account Signed-off-by: VirtualTam <virtualtam@flibidi.net>
-rw-r--r--application/FeedBuilder.php3
-rw-r--r--tests/FeedBuilderTest.php33
2 files changed, 35 insertions, 1 deletions
diff --git a/application/FeedBuilder.php b/application/FeedBuilder.php
index 58c6bb17..c6657fbb 100644
--- a/application/FeedBuilder.php
+++ b/application/FeedBuilder.php
@@ -124,7 +124,8 @@ class FeedBuilder
124 $data['last_update'] = $this->getLatestDateFormatted(); 124 $data['last_update'] = $this->getLatestDateFormatted();
125 $data['show_dates'] = !$this->hideDates || $this->isLoggedIn; 125 $data['show_dates'] = !$this->hideDates || $this->isLoggedIn;
126 // Remove leading slash from REQUEST_URI. 126 // Remove leading slash from REQUEST_URI.
127 $data['self_link'] = $pageaddr . escape(ltrim($this->serverInfo['REQUEST_URI'], '/')); 127 $data['self_link'] = escape(server_url($this->serverInfo))
128 . escape($this->serverInfo['REQUEST_URI']);
128 $data['index_url'] = $pageaddr; 129 $data['index_url'] = $pageaddr;
129 $data['usepermalinks'] = $this->usePermalinks === true; 130 $data['usepermalinks'] = $this->usePermalinks === true;
130 $data['links'] = $linkDisplayed; 131 $data['links'] = $linkDisplayed;
diff --git a/tests/FeedBuilderTest.php b/tests/FeedBuilderTest.php
index c9ff397d..aa57f44e 100644
--- a/tests/FeedBuilderTest.php
+++ b/tests/FeedBuilderTest.php
@@ -217,4 +217,37 @@ class FeedBuilderTest extends PHPUnit_Framework_TestCase
217 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); 217 $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links']));
218 $this->assertEquals('http://pubsubhub.io', $data['pubsubhub_url']); 218 $this->assertEquals('http://pubsubhub.io', $data['pubsubhub_url']);
219 } 219 }
220
221 /**
222 * Test buildData when Shaarli is served from a subdirectory
223 */
224 public function testBuildDataServerSubdir()
225 {
226 $serverInfo = array(
227 'HTTPS' => 'Off',
228 'SERVER_NAME' => 'host.tld',
229 'SERVER_PORT' => '8080',
230 'SCRIPT_NAME' => '/~user/shaarli/index.php',
231 'REQUEST_URI' => '/~user/shaarli/index.php?do=feed',
232 );
233 $feedBuilder = new FeedBuilder(
234 self::$linkDB,
235 FeedBuilder::$FEED_ATOM,
236 $serverInfo,
237 null,
238 false
239 );
240 $feedBuilder->setLocale(self::$LOCALE);
241 $data = $feedBuilder->buildData();
242
243 $this->assertEquals(
244 'http://host.tld:8080/~user/shaarli/index.php?do=feed',
245 $data['self_link']
246 );
247
248 // Test first link (note link)
249 $link = array_shift($data['links']);
250 $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['guid']);
251 $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['url']);
252 }
220} 253}