Commit 546fc6c2 authored by Alex Vandiver's avatar Alex Vandiver
Browse files

Strip non-word characters from CF names for variable names

The existing Simple templates did not address the issue of CF names with
spaces in them.  This strips non-word characters to establish the
variable name -- a trasformation which might cause duplication of CF
names, but this does not notably worsen the situation, as they did not
already posess any uniqueness guarantees.

Note that this may still lead to unicode variable names, as \w is UTF-8
aware, allowing for the variable "$TicketCFStraße".

Fixes I#18446.
parent 8cda28af
......@@ -129,7 +129,9 @@ use. Among them:
=item $TicketCF(Name)
For example, C<$TicketCFDepartment>.
For example, C<$TicketCFDepartment>. For CFs with more complicated
names, all non-word characters (anything that is not letters, numbers,
or underscores) are stripped to determine the appropriate variable name.
=item $TransactionType
......
......@@ -640,7 +640,10 @@ sub _MassageSimpleTemplateArgs {
my $cfs = $ticket->CustomFields;
while (my $cf = $cfs->Next) {
$template_args->{"TicketCF" . $cf->Name} = $ticket->CustomFieldValuesAsString($cf->Name);
my $simple = $cf->Name;
$simple =~ s/\W//g;
$template_args->{"TicketCF" . $simple}
= $ticket->CustomFieldValuesAsString($cf->Name);
}
}
......@@ -651,7 +654,10 @@ sub _MassageSimpleTemplateArgs {
my $cfs = $txn->CustomFields;
while (my $cf = $cfs->Next) {
$template_args->{"TransactionCF" . $cf->Name} = $txn->CustomFieldValuesAsString($cf->Name);
my $simple = $cf->Name;
$simple =~ s/\W//g;
$template_args->{"TransactionCF" . $simple}
= $txn->CustomFieldValuesAsString($cf->Name);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment