Revision: 1079
          http://stripes.svn.sourceforge.net/stripes/?rev=1079&view=rev
Author:   bengunter
Date:     2009-03-01 04:12:19 +0000 (Sun, 01 Mar 2009)

Log Message:
-----------
STS-262: Fixed a couple more parser quirks: allow nested braces without 
requiring that they be balanced and preserve escape characters for the 
parameter name parser when they occur inside braces.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 
2009-03-01 03:29:05 UTC (rev 1078)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 
2009-03-01 04:12:19 UTC (rev 1079)
@@ -569,8 +569,7 @@
         // parse the pattern
         String path = null;
         List<Object> components = new ArrayList<Object>();
-        int braceLevel = 0;
-        boolean escape = false;
+        boolean brace = false, escape = false;
         char[] chars = pattern.toCharArray();
         StringBuilder buf = new StringBuilder(pattern.length());
         char c = 0;
@@ -579,8 +578,8 @@
             if (!escape) {
                 switch (c) {
                 case '{':
-                    ++braceLevel;
-                    if (braceLevel == 1) {
+                    if (!brace) {
+                        brace = true;
                         if (path == null) {
                             // extract trailing non-alphanum chars as a 
literal to trim the path
                             int end = buf.length() - 1;
@@ -603,10 +602,8 @@
                     }
                     break;
                 case '}':
-                    if (braceLevel > 0) {
-                        --braceLevel;
-                    }
-                    if (braceLevel == 0) {
+                    if (brace) {
+                        brace = false;
                         components.add(parseUrlBindingParameter(beanType, 
buf.toString()));
                         buf.setLength(0);
                         continue;
@@ -614,6 +611,12 @@
                     break;
                 case '\\':
                     escape = true;
+
+                    // Preserve escape characters for parameter name parser
+                    if (brace) {
+                        buf.append(c);
+                    }
+
                     continue;
                 }
             }
@@ -626,7 +629,7 @@
         // Were we led to expect more characters?
         if (escape)
             throw new ParseException(pattern, "Expression must not end with 
escape character");
-        else if (braceLevel > 0)
+        else if (brace)
             throw new ParseException(pattern, "Unterminated left brace ('{') 
in expression");
 
         // handle whatever is left


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to