This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 213
Problem in \StringUtil::parseSimpleTokens with hyphens #8436
Comments
|
@leofeyer You can assign this to me, I'll fix it. |
|
Ok, the problem isn't actually in the Contao core. The function simply ignores such simple tokens, however, this causes an endless recursion in Sort of related to this problem: #8403 (i.e., if hyphens in field names would not be allowed, this problem would not occurs - however this can't be the solution in this case, I guess). |
|
This needs to be marked up for discussion anyway because I'm not happy with the behaviour of Contao at all. |
|
The solution should be fairly simple: $strReturn = str_replace(
array_map(
function ($v) {
return '##' . $v . '##';
},
array_keys($arrData)
),
$arrData,
$strReturn
);
preg_replace('/##([A-Za-z0-9_]+)##/i', '', $strReturn); |
|
next version: $stReturn = preg_replace_callback(
'/##([^#\s]+)##/i',
function (array $matches) use ($arrData) {
if (!isset($arrData[$matches[1]]) {
System::log(sprintf('Unknown simple token "%s"', $matches[1]));
return '';
}
return $arrData[$matches[1]];
},
$strReturn
); |
|
Fixed missing support for any character and added log entries: #8438. |
|
See #8438. |
leofeyer
added a commit
that referenced
this issue
Sep 5, 2016
jsonn
pushed a commit
to jsonn/pkgsrc
that referenced
this issue
Sep 8, 2016
### 4.2.3 (2016-09-06) * Do not double URL encode the content syndication links. * Use CSS3 transforms instead of transitions to animate the off-canvas navigation. * Improve the exception handling when using the resource locator (see #557). * Correctly reset the filter menu in parent view. * Support all characters but =!<> and whitespace in simple tokens (see contao/core#8436). * Check the user's permission when generating links in the picker (see contao/core#8407). * Handle forward pages without target in the navigation modules (see contao/core#8377). * Provide the same template variables for downloads and enclosures (see contao/core#8392). * Handle %n when parsing date formats (see contao/core#8411). * Fix the module wizard's accessibility (see contao/core#8391). * Correctly initialize TinyMCE in sub-palettes in Firefox (see contao/core#3673). * Validate form field names more accurately (see contao/core#8403). * Correctly show the ctime, mtime and atime of a folder (see contao/core#8408). * Correctly index changed pages (see contao/core#8439).
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This issue arises in combination with terminal42/contao-leads for example. Suppose you created a form in the form generator with a field named
E-mail. Now suppose you also want to create a lead with that and you use##E-mail##in the Record label setting, so that this field is shown in the backend, when viewing the entries of that lead.However, if you try to do that, you won't be able to view that lead in the backend, because there will be a script timeout or a memory overflow. The
\Contao\StringUtil::parseSimpleTokensfunction does not work if you have a simple token with a hyphen (-) in it.So currently you simply have to either avoid using field names with hyphens or avoid using field names with hyphens in the Record label - however this is something that won't be clear to the regular user.
@Toflar suggested that may be
\StringUtil::parseSimpleTokensshould convert invalid chars first before runningThe text was updated successfully, but these errors were encountered: