Permalink
Browse files

Fixed #10967: Using a round bracket (parenthesis) in a macro. Unbalan…

…ced parentheses can now be escaped in macro calls using the backslash character.
  • Loading branch information...
1 parent f40992f commit a48b16dbfc02ac6da839b27cdb5f5bf518ef106d hao committed Sep 14, 2009
Showing with 55 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 docs/changelog/7.x.x.txt
  3. +3 −1 lib/WebGUI/Macro.pm
  4. +34 −1 t/Macro.t
  5. +16 −0 t/Macro/Quote.t
View
@@ -0,0 +1 @@
+/*.kpf
View
@@ -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
@@ -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
@@ -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
@@ -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;

0 comments on commit a48b16d

Please sign in to comment.