From 7d781c31298ce617408c7efeff34cc9639c3eb2f Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Mon, 16 Jan 2017 13:13:57 -0800 Subject: [PATCH] match `http-equiv=Status` in addition to `status` --- controllers/Parse.php | 2 +- tests/FetchTest.php | 14 ++++++++++++++ tests/data/source.example.com/deleted-2 | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/data/source.example.com/deleted-2 diff --git a/controllers/Parse.php b/controllers/Parse.php index 0905a13..14de6b5 100644 --- a/controllers/Parse.php +++ b/controllers/Parse.php @@ -193,7 +193,7 @@ class Parse { $xpath = new DOMXPath($doc); // Check for meta http equiv and replace the status code if present - foreach($xpath->query('//meta[@http-equiv=\'status\']') as $el) { + foreach($xpath->query('//meta[translate(@http-equiv,\'STATUS\',\'status\')=\'status\']') as $el) { $equivStatus = ''.$el->getAttribute('content'); if($equivStatus && is_string($equivStatus)) { if(preg_match('/^(\d+)/', $equivStatus, $match)) { diff --git a/tests/FetchTest.php b/tests/FetchTest.php index 7cebeef..9396b62 100644 --- a/tests/FetchTest.php +++ b/tests/FetchTest.php @@ -117,6 +117,20 @@ class FetchTest extends PHPUnit_Framework_TestCase { $this->assertEquals('This post has been deleted.', $data->data->content->text); } + public function testMetaEquivDeletedCaps() { + $url = 'http://source.example.com/deleted-2'; + $response = $this->parse([ + 'url' => $url + ]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals(410, $data->code); + $this->assertEquals('This post has been deleted.', $data->data->content->text); + } + public function testMetaEquivDeletedTargetProvided() { // for example when verifying a webmention but the source was replaced with an html deleted page diff --git a/tests/data/source.example.com/deleted-2 b/tests/data/source.example.com/deleted-2 new file mode 100644 index 0000000..658b6d2 --- /dev/null +++ b/tests/data/source.example.com/deleted-2 @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +Server: Apache +Date: Wed, 09 Dec 2015 03:29:14 GMT +Content-Type: text/html; charset=utf-8 +Connection: keep-alive + + + + Test + + + +

This post has been deleted.

+ +