Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linkchecker-3247797
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
linkchecker-3247797
Commits
29d4e3f8
Commit
29d4e3f8
authored
8 years ago
by
Alexander Hass
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2651180
by hass: Ignore fragment used for ajax requests
parent
ba38c150
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
linkchecker.module
+9
-6
9 additions, 6 deletions
linkchecker.module
linkchecker.test
+6
-0
6 additions, 0 deletions
linkchecker.test
with
15 additions
and
6 deletions
linkchecker.module
+
9
−
6
View file @
29d4e3f8
...
...
@@ -614,17 +614,20 @@ function _linkchecker_status_handling(&$response, $link) {
$response
->
error
=
trim
(
drupal_convert_to_utf8
(
$response
->
error
,
'ISO-8859-1'
));
$response
->
status_message
=
trim
(
drupal_convert_to_utf8
(
$response
->
status_message
,
'ISO-8859-1'
));
// Destination anchors in HTML documents may be specified either by the A
// element (naming it with the name attribute), or by any other element
// (naming with the id attribute).
// Destination anchors in HTML documents may be specified either by:
// - the A element (naming it with the name attribute)
// - or by any other element (naming with the id attribute)
// - and must not contain a key/value pair as these type of hash fragments are
// typically used by AJAX applications to prevent additionally HTTP requests
// e.g. http://www.example.com/ajax.html#key1=value1&key2=value2
// - and must not contain '/' or ',' as this are not normal anchors.
// - and '#top' is a reserved fragment that must not exist in a page.
// See http://www.w3.org/TR/html401/struct/links.html
//
// Notes:
// - '#top' is a reserved fragment that must not exist in a page.
if
(
$response
->
code
==
200
&&
!
empty
(
$response
->
data
)
&&
!
empty
(
$response
->
headers
[
'content-type'
])
&&
!
empty
(
$response
->
uri
[
'fragment'
])
&&
preg_match
(
'/=|\/|,/'
,
$response
->
uri
[
'fragment'
])
==
FALSE
&&
!
in_array
(
$response
->
uri
[
'fragment'
],
array
(
'#top'
))
&&
in_array
(
$response
->
headers
[
'content-type'
],
array
(
'text/html'
,
'application/xhtml+xml'
,
'application/xml'
))
&&
!
preg_match
(
'/(\s[^>]*(name|id)(\s+)?=(\s+)?["\'])('
.
preg_quote
(
$response
->
uri
[
'fragment'
],
'/'
)
.
')(["\'][^>]*>)/i'
,
$response
->
data
)
...
...
This diff is collapsed.
Click to expand it.
linkchecker.test
+
6
−
0
View file @
29d4e3f8
...
...
@@ -75,6 +75,8 @@ class LinkCheckerLinkExtractionTest extends DrupalWebTestCase {
<!-- URL with uncommon chars that could potentially fail to extract. See http://drupal.org/node/465462. -->
<a href="http://www.lagrandeepicerie.fr/#e-boutique/Les_produits_du_moment,2/coffret_vins_doux_naturels,149">URL with uncommon chars</a>
<a href="http://example.com/foo bar/is_valid-hack.test">URL with space</a>
<a href="http://example.com/ajax.html#key1=value1&key2=value2">URL with ajax query params</a>
<a href="http://example.com/test.html#test">URL with standard anchor</a>
<!-- object tag: Embed SWF files -->
<object width="150" height="116"
...
...
@@ -227,6 +229,8 @@ EOT;
'http://v2v.cc/~j/theora_testsuite/pixel_aspect_ratio.mov'
,
'http://v2v.cc/~j/theora_testsuite/320x240.ogg'
,
'http://example.com/foo bar/is_valid-hack.test'
,
'http://example.com/ajax.html#key1=value1&key2=value2'
,
'http://example.com/test.html#test'
,
);
foreach
(
$urls_fqdn
as
$org_url
=>
$check_url
)
{
...
...
@@ -349,6 +353,8 @@ EOT;
'http://example.org/video/player3.swf'
,
'http://example.com/iframe/'
,
'http://example.com/foo bar/is_valid-hack.test'
,
'http://example.com/ajax.html#key1=value1&key2=value2'
,
'http://example.com/test.html#test'
,
);
foreach
(
$documentation_urls
as
$documentation_url
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment