Browse Source

Merge pull request #60 from aaronpk/htmlpurifier-update

switch to htmlpurifier master
pull/64/head v1.4.14
Aaron Parecki 6 years ago
committed by GitHub
parent
commit
73ad0e6e21
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1265 additions and 15 deletions
  1. +8
    -2
      composer.json
  2. +7
    -12
      composer.lock
  3. +13
    -1
      tests/FeedTest.php
  4. +19
    -0
      tests/ParseTest.php
  5. +1218
    -0
      tests/data/source.example.com/ascraeus

+ 8
- 2
composer.json View File

@ -6,7 +6,7 @@
"description": "X-Ray returns structured data from any URL", "description": "X-Ray returns structured data from any URL",
"require": { "require": {
"mf2/mf2": "^0.3.2", "mf2/mf2": "^0.3.2",
"ezyang/htmlpurifier": "4.*",
"ezyang/htmlpurifier": "dev-master#6d6d88512a8146939a9161bb03e95e3e97840439@dev",
"indieweb/link-rel-parser": "0.1.*", "indieweb/link-rel-parser": "0.1.*",
"dg/twitter-php": "3.6.*", "dg/twitter-php": "3.6.*",
"p3k/timezone": "*", "p3k/timezone": "*",
@ -38,5 +38,11 @@
"controllers/Feeds.php", "controllers/Feeds.php",
"controllers/Certbot.php" "controllers/Certbot.php"
] ]
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git"
}
]
} }

+ 7
- 12
composer.lock View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ee0b0e99a5aeee6e95f5d642f438cde2",
"content-hash": "bcdd53e30f9960f6b39b0aa2c74d5457",
"packages": [ "packages": [
{ {
"name": "cebe/markdown", "name": "cebe/markdown",
@ -110,17 +110,11 @@
}, },
{ {
"name": "ezyang/htmlpurifier", "name": "ezyang/htmlpurifier",
"version": "v4.9.3",
"version": "dev-master",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git", "url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "95e1bae3182efc0f3422896a3236e991049dac69"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/95e1bae3182efc0f3422896a3236e991049dac69",
"reference": "95e1bae3182efc0f3422896a3236e991049dac69",
"shasum": ""
"reference": "6d6d88512a8146939a9161bb03e95e3e97840439"
}, },
"require": { "require": {
"php": ">=5.2" "php": ">=5.2"
@ -137,7 +131,6 @@
"library/HTMLPurifier.composer.php" "library/HTMLPurifier.composer.php"
] ]
}, },
"notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"LGPL" "LGPL"
], ],
@ -153,7 +146,7 @@
"keywords": [ "keywords": [
"html" "html"
], ],
"time": "2017-06-03T02:28:16+00:00"
"time": "2017-12-30T05:23:44+00:00"
}, },
{ {
"name": "facebook/graph-sdk", "name": "facebook/graph-sdk",
@ -2089,7 +2082,9 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {
"ezyang/htmlpurifier": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],

+ 13
- 1
tests/FeedTest.php View File

@ -314,4 +314,16 @@ class FeedTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('Sometimes my job requires me to listen to 55 minutes of an hour long phone call while I go for a long walk on a sunny morning and wait for my turn to give an update. Pretty nice!', $data->items[11]->content->text); $this->assertEquals('Sometimes my job requires me to listen to 55 minutes of an hour long phone call while I go for a long walk on a sunny morning and wait for my turn to give an update. Pretty nice!', $data->items[11]->content->text);
} }
}
public function testAscraeus() {
$url = 'http://source.example.com/ascraeus';
$response = $this->parse(['url' => $url, 'expect' => 'feed']);
$body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body)->data;
$this->assertEquals('feed', $data->type);
$this->assertEquals(20, count($data->items));
}
}

+ 19
- 0
tests/ParseTest.php View File

@ -613,6 +613,25 @@ class ParseTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]);
} }
public function testInputIsParsedMf2WithHTML() {
$html = '<div class="h-entry"><p class="e-content p-name"><b>Hello</b> <i>World</i></p><img src="/photo.jpg"></p></div>';
$mf2 = Mf2\parse($html, 'http://example.com/entry');
$url = 'http://example.com/entry';
$response = $this->parse([
'url' => $url,
'body' => json_encode($mf2)
]);
$body = $response->getContent();
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($body, true);
$this->assertEquals('Hello World', $data['data']['content']['text']);
$this->assertEquals('<b>Hello</b> <i>World</i>', $data['data']['content']['html']);
$this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]);
}
public function testHApp() { public function testHApp() {
$url = 'http://source.example.com/h-app'; $url = 'http://source.example.com/h-app';
$response = $this->parse(['url' => $url]); $response = $this->parse(['url' => $url]);

+ 1218
- 0
tests/data/source.example.com/ascraeus
File diff suppressed because it is too large
View File


Loading…
Cancel
Save