Following external link: [[|1]]

Will crash with following exception:

InvalidArgumentException: The URI 'http:1' is invalid. You must use a valid URI scheme. in Drupal\Core\Url::fromUri() (line 281 of core/lib/Drupal/Core/Url.php).

Drupal\freelinking\Plugin\freelinking\External->buildLink(Array) (Line: 80)
Drupal\freelinking\FreelinkingManager->buildLink(Object, Array) (Line: 173)
Drupal\freelinking\FreelinkingManager->createFreelinkElement('external', '//|1', 'http', 'und', 'a:3:{s:6:"plugin";s:8:"external";s:7:"enabled";b:1;s:8:"settings";a:1:{s:6:"scrape";s:1:"0";}}')

The problem is the get param in the url, which confuses FreelinkingManager::parseTarget().

Members fund testing for the Drupal project. Drupal Association Learn more


swentel created an issue. See original summary.

swentel’s picture

Title: External links with a numeric title crash on Url » External links with a get param in the url will crash
Issue summary: View changes

Changing title as it's get params in the url that will crash this, the problem lies within FreelinkingManager::parseTarget()

swentel’s picture

Issue summary: View changes
swentel’s picture

Weirdly enough, If I change the numeric titles (1 and 2) with some sort of string, the plugin doesn't crash, but the link is still completely wrong

swentel’s picture

Status: Active » Needs review
1.01 KB

Changing the strpos check fixes this, feels like the right fix to me, but I might be missing something.

mradcliffe’s picture

Thank you for the patch.

I added a test parseTarget, and am surprised I didn't add coverage for it before. I think we need to add more into the data provider to test out the logic. It's mainly coming from the drupal 7 version.