Browse Source

match `http-equiv=Status` in addition to `status`

pull/39/head
Aaron Parecki 4 years ago
parent
commit
7d781c3129
No known key found for this signature in database GPG Key ID: 276C2817346D6056
3 changed files with 30 additions and 1 deletions
  1. +1
    -1
      controllers/Parse.php
  2. +14
    -0
      tests/FetchTest.php
  3. +15
    -0
      tests/data/source.example.com/deleted-2

+ 1
- 1
controllers/Parse.php View File

@ -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)) {

+ 14
- 0
tests/FetchTest.php View File

@ -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

+ 15
- 0
tests/data/source.example.com/deleted-2 View File

@ -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
<html>
<head>
<title>Test</title>
<meta http-equiv="Status" content="410 Gone" />
</head>
<body class="h-entry">
<p class="e-content">This post has been deleted.</p>
</body>
</html>

Loading…
Cancel
Save