Problem/Motivation
Hi, in the submission part of a webform, there is an input with the placeholder "Enter submitted to... which allows you to search different entity types to find the submissions concerned.
I noticed that if for example, an entity type which would be a node, had parentheses in its name (example: "NODE (23/2)"), the node sought would be 23/2 and not the id of the node.
Steps to reproduce
Create an attached entity type with parenthesis at the end of name.
Proposed resolution
Modifie the regex present in submitForm
- \( matches an opening parenthesis.
- [^()]+ matches one or more characters that are not opening or closing parentheses.
- \) matches a closing parenthesis.
- $ means the match should end at the end of the string.
This expression should always capture the content between the last parentheses without including the preceding parentheses.
If we dpm($matches) in the function submitForm() for the example "NODE (23/2)"
Before :
array:2 [▼
0 => "(23/2)"
1 => "23/2"
]
After :
array:1 [▼
0 => "node:598"
]
| Comment | File | Size | Author |
|---|
Issue fork webform-3423007
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
Comment #3
alexl commentedComment #4
jrockowitz commentedI think only the regex needs to be improved by adding the $ and maybe allow for extra spaces.
Before
if (!empty($query['entity']) && preg_match('#\(([^)]+)\)#', $query['entity'], $match)) {After
if (!empty($query['entity']) && preg_match('#\(([^)]+)\)\s*$#', $query['entity'], $match)) {Comment #5
alexl commentedhi @jrockowitz
the string is give by my client and can have an open and not closed parenthesis. ex : "test (7/ "
I think my last regex covers all cases.
Comment #6
jrockowitz commented