Skip to content

Commit

Permalink
[BUGFIX] Convert URLs with ampersands in Linkvalidator
Browse files Browse the repository at this point in the history
The linkref functions return the URLs as they are displayed in the
BE form. This will return '&' as '&' HTML entity.

Linkvalidator should correctly decode the HTML entity.

Resolves: #89488
Resolves: #89682
Releases: master, 9.5
Change-Id: I17b421354d45297423437373b92a93dfbe53d2d9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62645
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
  • Loading branch information
sypets authored and ervaude committed Dec 15, 2019
1 parent 6b85d72 commit 1fa1916
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Expand Up @@ -220,7 +220,7 @@ public function fetchType($value, $type, $key)
protected function preprocessUrl(string $url): string
{
try {
return (new IdnaConvert())->encodeUri($url);
return (new IdnaConvert())->encodeUri(html_entity_decode($url));
} catch (\Exception $e) {
// in case of any error, return empty url.
$this->errorParams['errorType'] = 'exception';
Expand Down
Expand Up @@ -128,6 +128,16 @@ private function getRequestHeaderOptions(): array

public function preprocessUrlsDataProvider()
{
// regression tests for issues #89488, #89682
yield 'URL with query parameter and ampersand' => [
'https://standards.cen.eu/dyn/www/f?p=204:6:0::::FSP_ORG_ID,FSP_LANG_ID:,22&cs=1A3FFBC44FAB6B2A181C9525249C3A829',
'https://standards.cen.eu/dyn/www/f?p=204:6:0::::FSP_ORG_ID,FSP_LANG_ID:,22&cs=1A3FFBC44FAB6B2A181C9525249C3A829'
];
yield 'URL with query parameter and ampersand with HTML entities' => [
'https://standards.cen.eu/dyn/www/f?p=204:6:0::::FSP_ORG_ID,FSP_LANG_ID:,22&amp;cs=1A3FFBC44FAB6B2A181C9525249C3A829',
'https://standards.cen.eu/dyn/www/f?p=204:6:0::::FSP_ORG_ID,FSP_LANG_ID:,22&cs=1A3FFBC44FAB6B2A181C9525249C3A829'
];

// regression tests for #89378
yield 'URL with path with dashes' => [
'https://example.com/Unternehmen/Ausbildung-Qualifikation/Weiterbildung-in-Niedersachsen/',
Expand All @@ -141,9 +151,9 @@ public function preprocessUrlsDataProvider()
'http://example.com/universitaet/die-uni-im-ueberblick/lageplan/gebaeude/building/120',
'http://example.com/universitaet/die-uni-im-ueberblick/lageplan/gebaeude/building/120'
];
yield 'URL with path and query parameters' => [
yield 'URL with path and query parameters (including &, ~,; etc.)' => [
'http://example.com/tv?bcpid=1701167454001&amp;amp;amp;bckey=AQ~~,AAAAAGL7LqU~,aXlKNnCf9d9Tmck-kOc4PGFfCgHjM5JR&amp;amp;amp;bctid=1040702768001',
'http://example.com/tv?bcpid=1701167454001&amp;amp;amp;bckey=AQ~~,AAAAAGL7LqU~,aXlKNnCf9d9Tmck-kOc4PGFfCgHjM5JR&amp;amp;amp;bctid=1040702768001'
'http://example.com/tv?bcpid=1701167454001&amp;amp;bckey=AQ~~,AAAAAGL7LqU~,aXlKNnCf9d9Tmck-kOc4PGFfCgHjM5JR&amp;amp;bctid=1040702768001'
];

// make sure we correctly handle URLs with query parameters and fragment etc.
Expand Down

0 comments on commit 1fa1916

Please sign in to comment.