I am trying to add a string as a fallback for my title metatag that includes a pipe, but the module interprets the pipeline within the string as a separator between tokens, causing it to break.

Example: [node:field_title_social|node:field_headline|"My Awesome Title | My Company"]

I have attached a patch to cover this case.

Issue fork token_or-3491615

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

ok4p1 created an issue. See original summary.

ok4p1’s picture

ok4p1’s picture

ok4p1’s picture

pianomansam’s picture

Status: Active » Needs work

@ok4p1 thanks for the bug report and the patch file. In order for this to be considered, please open a Merge Request with your changes. Also, please write a test showing that it solves the issue.

keshav patel made their first commit to this issue’s fork.

keshav patel’s picture

Version: 2.3.0 » 2.x-dev
Issue tags: +Needs tests

Raised an MR with the provided patch on #4#4,
Keeping it on Needs work until tests are added.

  • soltz committed a8fdf103 on 2.x
    fix: #3491615 Support for pipes inside of strings
    
    By: ok4p1
    By:...
pianomansam’s picture

Status: Needs work » Fixed

Committed to 2.x, thanks everyone!

@ok4p1 thanks for the report and the original patch, and @Keshav Patel for turning it into an MR.

Quoted strings can now contain pipes:

[node:field_title_social|node:field_headline|"My Awesome Title | My Company"]

Before committing I added tests, and made one change to the approach. The lookahead regex in preg_split() re-scans to the end of the token from every pipe. On long input (around 150 KB of pipes and quotes) PCRE gave up with "JIT stack limit exhausted" and returned FALSE, which then caused a fatal error. Since token replacement can run over editor-entered content (e.g. with token_filter), I replaced it with a single pass over the string that tracks whether it's inside quotes. The result is the same for well-formed tokens, and there's a test covering the long-input case.

This will be in the next 2.x release.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.