Problem/Motivation

We are including tokens into href's (once converted it will be a valid URL). Because of the "Correct invalid HTML" filter, the token will br stripped, and this is called sometimes when editing the content and breaks the token. We have then converted the token into a proper URL, it now passes through the filter without breaking the token. However they are now being converted by linky.

Steps to reproduce

If we convert a token to something like "/?tok=[node:url]" linky will convert this into a entity.

Proposed resolution

Add a config entry which will be a regular expression to give full flexibility. We can add this to \Drupal\linkyreplacer\LinkyEntityUtility::getLinkyByHref() to do something similar to the check if the link is a linkly link.

CommentFileSizeAuthor
#3 3387452-3.patch2.02 KBgordon
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gordon created an issue. See original summary.

gordon’s picture

Project: Linky » Linky Replacer
Version: 8.x-1.x-dev » 2.x-dev
gordon’s picture

StatusFileSize
new2.02 KB

This was a pretty small change with a new config entry.

jibran’s picture

Status: Active » Needs work
  1. +++ b/config/install/linkyreplacer.settings.yml
    @@ -2,3 +2,4 @@ internal_patterns: ""
    +exclude_patter: ''
    

    We need a post update hook to update the existing config.

  2. +++ b/src/LinkyEntityUtility.php
    @@ -167,6 +167,14 @@ class LinkyEntityUtility implements LinkyEntityUtilityInterface {
    +    if ($exclude = $this->configFactory->get('linkyreplacer.settings')->get('exclude_pattern')) {
    

    We need some kind of validation for valid regex.

  3. +++ b/src/LinkyEntityUtility.php
    @@ -167,6 +167,14 @@ class LinkyEntityUtility implements LinkyEntityUtilityInterface {
    +      if (preg_match($exclude, $href)) {
    

    We need tests for this.

gordon’s picture

gordon’s picture

Status: Needs work » Needs review

1. I have fixed up the typo and added in an update to update to set the default value.
2. I have looked into this and to test the regular expression is to use preg_match(). If the expression is invalid it will return false, as opposed to not matching which will return 0.
3. I have added in a test to check the if the exclusion will work.