Skip to content

Commit 042236b

Browse files
committed
Merge pull request #25 from aaronpk/master
adds failing test and fix for #24
2 parents 83d2d4b + 80011d5 commit 042236b

File tree

8 files changed

+428
-376
lines changed

8 files changed

+428
-376
lines changed

coverage/MentionClient.php.html

Lines changed: 359 additions & 370 deletions
Large diffs are not rendered by default.

coverage/dashboard.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ <h3>Project Risks</h3>
136136
<footer>
137137
<hr/>
138138
<p>
139-
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.3.0-3-g9b2a050</a> using <a href="http://php.net/" target="_top">PHP 5.6.19</a> and <a href="https://phpunit.de/">PHPUnit 5.4-g1206dd3</a> at Mon Apr 4 15:08:54 UTC 2016.</small>
139+
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.3.0-3-g9b2a050</a> using <a href="http://php.net/" target="_top">PHP 5.6.19</a> and <a href="https://phpunit.de/">PHPUnit 5.4-g1206dd3</a> at Fri Apr 15 6:43:46 UTC 2016.</small>
140140
</p>
141141
</footer>
142142
</div>
@@ -225,7 +225,7 @@ <h3>Project Risks</h3>
225225
chart.yAxis.axisLabel('Cyclomatic Complexity');
226226

227227
d3.select('#classComplexity svg')
228-
.datum(getComplexityData([[100,84,"<a href=\"MentionClient.php.html#4\">MentionClient<\/a>"]], 'Class Complexity'))
228+
.datum(getComplexityData([[100,83,"<a href=\"MentionClient.php.html#4\">MentionClient<\/a>"]], 'Class Complexity'))
229229
.transition()
230230
.duration(500)
231231
.call(chart);
@@ -249,7 +249,7 @@ <h3>Project Risks</h3>
249249
chart.yAxis.axisLabel('Method Complexity');
250250

251251
d3.select('#methodComplexity svg')
252-
.datum(getComplexityData([[100,1,"<a href=\"MentionClient.php.html#24\">MentionClient::setProxy<\/a>"],[100,6,"<a href=\"MentionClient.php.html#28\">MentionClient::discoverPingbackEndpoint<\/a>"],[100,5,"<a href=\"MentionClient.php.html#63\">MentionClient::sendPingbackToEndpoint<\/a>"],[100,3,"<a href=\"MentionClient.php.html#92\">MentionClient::sendPingback<\/a>"],[100,6,"<a href=\"MentionClient.php.html#108\">MentionClient::_findWebmentionEndpointInHTML<\/a>"],[100,6,"<a href=\"MentionClient.php.html#121\">MentionClient::_findWebmentionEndpointInHeader<\/a>"],[100,9,"<a href=\"MentionClient.php.html#135\">MentionClient::discoverWebmentionEndpoint<\/a>"],[100,1,"<a href=\"MentionClient.php.html#180\">MentionClient::sendWebmentionToEndpoint<\/a>"],[100,3,"<a href=\"MentionClient.php.html#195\">MentionClient::sendWebmention<\/a>"],[100,7,"<a href=\"MentionClient.php.html#211\">MentionClient::findOutgoingLinks<\/a>"],[100,1,"<a href=\"MentionClient.php.html#241\">MentionClient::findLinksInText<\/a>"],[100,4,"<a href=\"MentionClient.php.html#246\">MentionClient::findLinksInJSON<\/a>"],[100,4,"<a href=\"MentionClient.php.html#257\">MentionClient::sendMentions<\/a>"],[100,8,"<a href=\"MentionClient.php.html#281\">MentionClient::sendFirstSupportedMention<\/a>"],[100,1,"<a href=\"MentionClient.php.html#308\">MentionClient::enableDebug<\/a>"],[100,2,"<a href=\"MentionClient.php.html#314\">MentionClient::_debug<\/a>"],[100,2,"<a href=\"MentionClient.php.html#322\">MentionClient::_head<\/a>"],[100,2,"<a href=\"MentionClient.php.html#339\">MentionClient::_get<\/a>"],[100,2,"<a href=\"MentionClient.php.html#357\">MentionClient::_post<\/a>"],[100,5,"<a href=\"MentionClient.php.html#375\">MentionClient::_parse_headers<\/a>"],[100,1,"<a href=\"MentionClient.php.html#384\">MentionClient::anonymous function<\/a>"],[100,2,"<a href=\"MentionClient.php.html#399\">MentionClient::xmlrpc_encode_request<\/a>"],[100,3,"<a href=\"MentionClient.php.html#412\">MentionClient::c<\/a>"]], 'Method Complexity'))
252+
.datum(getComplexityData([[100,1,"<a href=\"MentionClient.php.html#24\">MentionClient::setProxy<\/a>"],[100,6,"<a href=\"MentionClient.php.html#28\">MentionClient::discoverPingbackEndpoint<\/a>"],[100,5,"<a href=\"MentionClient.php.html#63\">MentionClient::sendPingbackToEndpoint<\/a>"],[100,3,"<a href=\"MentionClient.php.html#82\">MentionClient::sendPingback<\/a>"],[100,6,"<a href=\"MentionClient.php.html#98\">MentionClient::_findWebmentionEndpointInHTML<\/a>"],[100,5,"<a href=\"MentionClient.php.html#112\">MentionClient::_findWebmentionEndpointInHeader<\/a>"],[100,9,"<a href=\"MentionClient.php.html#124\">MentionClient::discoverWebmentionEndpoint<\/a>"],[100,1,"<a href=\"MentionClient.php.html#169\">MentionClient::sendWebmentionToEndpoint<\/a>"],[100,3,"<a href=\"MentionClient.php.html#184\">MentionClient::sendWebmention<\/a>"],[100,7,"<a href=\"MentionClient.php.html#200\">MentionClient::findOutgoingLinks<\/a>"],[100,1,"<a href=\"MentionClient.php.html#230\">MentionClient::findLinksInText<\/a>"],[100,4,"<a href=\"MentionClient.php.html#235\">MentionClient::findLinksInJSON<\/a>"],[100,4,"<a href=\"MentionClient.php.html#246\">MentionClient::sendMentions<\/a>"],[100,8,"<a href=\"MentionClient.php.html#270\">MentionClient::sendFirstSupportedMention<\/a>"],[100,1,"<a href=\"MentionClient.php.html#297\">MentionClient::enableDebug<\/a>"],[100,2,"<a href=\"MentionClient.php.html#303\">MentionClient::_debug<\/a>"],[100,2,"<a href=\"MentionClient.php.html#311\">MentionClient::_head<\/a>"],[100,2,"<a href=\"MentionClient.php.html#328\">MentionClient::_get<\/a>"],[100,2,"<a href=\"MentionClient.php.html#346\">MentionClient::_post<\/a>"],[100,5,"<a href=\"MentionClient.php.html#364\">MentionClient::_parse_headers<\/a>"],[100,1,"<a href=\"MentionClient.php.html#373\">MentionClient::anonymous function<\/a>"],[100,2,"<a href=\"MentionClient.php.html#388\">MentionClient::xmlrpc_encode_request<\/a>"],[100,3,"<a href=\"MentionClient.php.html#401\">MentionClient::c<\/a>"]], 'Method Complexity'))
253253
.transition()
254254
.duration(500)
255255
.call(chart);

coverage/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
</div>
5050
</td>
5151
<td class="success small"><div align="right">100.00%</div></td>
52-
<td class="success small"><div align="right">203&nbsp;/&nbsp;203</div></td>
52+
<td class="success small"><div align="right">196&nbsp;/&nbsp;196</div></td>
5353
<td class="success big"> <div class="progress">
5454
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100.00" aria-valuemin="0" aria-valuemax="100" style="width: 100.00%">
5555
<span class="sr-only">100.00% covered (success)</span>
@@ -77,7 +77,7 @@
7777
</div>
7878
</td>
7979
<td class="success small"><div align="right">100.00%</div></td>
80-
<td class="success small"><div align="right">203&nbsp;/&nbsp;203</div></td>
80+
<td class="success small"><div align="right">196&nbsp;/&nbsp;196</div></td>
8181
<td class="success big"> <div class="progress">
8282
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100.00" aria-valuemin="0" aria-valuemax="100" style="width: 100.00%">
8383
<span class="sr-only">100.00% covered (success)</span>
@@ -108,7 +108,7 @@ <h4>Legend</h4>
108108
<span class="success"><strong>High</strong>: 90% to 100%</span>
109109
</p>
110110
<p>
111-
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.3.0-3-g9b2a050</a> using <a href="http://php.net/" target="_top">PHP 5.6.19</a> and <a href="https://phpunit.de/">PHPUnit 5.4-g1206dd3</a> at Mon Apr 4 15:08:54 UTC 2016.</small>
111+
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 3.3.0-3-g9b2a050</a> using <a href="http://php.net/" target="_top">PHP 5.6.19</a> and <a href="https://phpunit.de/">PHPUnit 5.4-g1206dd3</a> at Fri Apr 15 6:43:46 UTC 2016.</small>
112112
</p>
113113
</footer>
114114
</div>

src/IndieWeb/MentionClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function sendPingback($sourceURL, $targetURL) {
9797

9898
protected function _findWebmentionEndpointInHTML($body, $targetURL=false) {
9999
$endpoint = false;
100+
$body = preg_replace('/<!--(.*)-->/Us', '', $body);
100101
if(preg_match('/<(?:link|a)[ ]+href="([^"]+)"[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]*\/?>/i', $body, $match)
101102
|| preg_match('/<(?:link|a)[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]+href="([^"]+)"[ ]*\/?>/i', $body, $match)) {
102103
$endpoint = $match[1];

tests/DiscoverTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ public function testDiscoverWebmentionEndpointInBodyA() {
6969
$this->assertEquals('http://webmention.example/webmention', $endpoint);
7070
}
7171

72+
public function testShouldNotDiscoverWebmentionEndpointInBodyComment() {
73+
$target = 'http://target.example.com/false-endpoint-in-comment.html';
74+
$endpoint = $this->client->discoverWebmentionEndpoint($target);
75+
$this->assertEquals('http://webmention.example/correct', $endpoint);
76+
}
77+
78+
public function testDiscoverWebmentionEndpointInDocumentOrder1() {
79+
$target = 'http://target.example.com/document-order-1.html';
80+
$endpoint = $this->client->discoverWebmentionEndpoint($target);
81+
$this->assertEquals('http://webmention.example/link', $endpoint);
82+
}
83+
84+
public function testDiscoverWebmentionEndpointInDocumentOrder2() {
85+
$target = 'http://target.example.com/document-order-2.html';
86+
$endpoint = $this->client->discoverWebmentionEndpoint($target);
87+
$this->assertEquals('http://webmention.example/a', $endpoint);
88+
}
89+
7290
public function testDiscoverWebmentionEndpointInWebmentionRocksTest1() {
7391
$target = "http://target.example.com/webmention-rocks-test-1.html";
7492
$endpoint = $this->client->discoverWebmentionEndpoint($target);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
HTTP/1.1 200 OK
2+
Server: Apache
3+
Date: Wed, 09 Dec 2015 03:29:14 GMT
4+
Content-Type: text/html; charset=utf-8
5+
Connection: keep-alive
6+
7+
<html>
8+
<head>
9+
<link rel="webmention" href="http://webmention.example/link">
10+
</head>
11+
<body>
12+
<p>You can send me a <a rel="webmention" href="http://webmention.example/a">webmention</a> or pingback</p>
13+
</body>
14+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HTTP/1.1 200 OK
2+
Server: Apache
3+
Date: Wed, 09 Dec 2015 03:29:14 GMT
4+
Content-Type: text/html; charset=utf-8
5+
Connection: keep-alive
6+
7+
<html>
8+
<body>
9+
<p>You can send me a <a rel="webmention" href="http://webmention.example/a">webmention</a> or pingback</p>
10+
<link rel="webmention" href="http://webmention.example/link">
11+
</body>
12+
</html>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
HTTP/1.1 200 OK
2+
Server: Apache
3+
Date: Wed, 09 Dec 2015 03:29:14 GMT
4+
Content-Type: text/html; charset=utf-8
5+
Connection: keep-alive
6+
7+
<html>
8+
<head>
9+
<title>Test</title>
10+
</head>
11+
<body>
12+
<p>You can send me a webmention</p>
13+
<!--
14+
<a rel="webmention" href="http://webmention.example/wrong"></a>
15+
-->
16+
<a rel="webmention" href="http://webmention.example/correct"></a>
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)