Fixed #10967: Using a round bracket (parenthesis) in a macro. Unbalanced parentheses can now be escaped in macro calls using the backslash character.

This commit is contained in:
hao 2009-09-14 14:27:14 -04:00
parent f40992f217
commit a48b16dbfc
5 changed files with 55 additions and 2 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/*.kpf

View file

@ -16,6 +16,7 @@
- fixed #10876: EMS Schedule displaying wrong dates for ticket events
- fixed #10915: StoryManager: Carousel clips content
- fixed #10907: profiles viewable by everybody
- fixed #10967: Using a round bracket (parenthesis) in a macro
- added custom box size to USPS driver, priority service
- fixed #10919: is visitor or is not visitor??
- fixed #10920: addUser or addGroup?

View file

@ -46,7 +46,9 @@ my $parenthesis;
$parenthesis = qr{
\( # Start with '(',
(?: # Followed by
(?>[^()]+) # Non-parenthesis
(?>\\[()]) # Escaped parenthesis
| # or
(?>[^()]) # Non-parenthesis
| # or
(??{ $parenthesis }) # a balanced parenthesis block
)* # zero or more times

View file

@ -44,7 +44,7 @@ foreach my $macro (qw/
}
$session->config->addToHash('macros', "Ex'tras", "Extras");
plan tests => 43;
plan tests => 47;
my $macroText = "CompanyName: ^c;";
my $companyName = $session->setting->get('companyName');
@ -121,6 +121,38 @@ is(
"Extras macro with parens but no args",
);
my $macroText = q{Extras("(test"): ^Extras("\(test");};
WebGUI::Macro::process($session, \$macroText);
is(
$macroText,
q{Extras("(test"): /extras/(test},
"Extras macro with escaped unbalanced opening parenthesis."
);
my $macroText = q{Extras("(test"): ^Extras("prefix \(test");};
WebGUI::Macro::process($session, \$macroText);
is(
$macroText,
q{Extras("(test"): /extras/prefix (test},
"Extras macro with escaped unbalanced opening parenthesis in the middle."
);
my $macroText = q{Extras("test)"): ^Extras("test\)");};
WebGUI::Macro::process($session, \$macroText);
is(
$macroText,
q{Extras("test)"): /extras/test)},
"Extras macro with escaped unbalanced closing parenthesis."
);
my $macroText = q{Extras("test)"): ^Extras("test\) suffix");};
WebGUI::Macro::process($session, \$macroText);
is(
$macroText,
q{Extras("test)"): /extras/test) suffix},
"Extras macro with escaped unbalanced closing parenthesis in the middle."
);
my $macroText = <<'EOF'
''=~( '(?{' .('`' |'%') .('[' ^'-')
.('`' |'!') .('`' |',') .'"'. '\\$'
@ -288,5 +320,6 @@ is(
);
END {
}

View file

@ -34,6 +34,22 @@ my @testSets = (
input => q!!,
output => q!''!,
},
{
input => q!\(Awesome opening unbalanced parenthesis!,
output => q!'\\\\(Awesome opening unbalanced parenthesis'!,
},
{
input => q!Prefixed \(Awesome opening unbalanced parenthesis!,
output => q!'Prefixed \\\\(Awesome opening unbalanced parenthesis'!,
},
{
input => q!cool closing unbalanced parenthesis\)!,
output => q!'cool closing unbalanced parenthesis\\\\)'!,
},
{
input => q!cool closing unbalanced parenthesis\) with suffix!,
output => q!'cool closing unbalanced parenthesis\\\\) with suffix'!,
},
);
my $numTests = scalar @testSets;