Oops, forgot to give credit to Rahul Akolkar (rahul AT apache.org<http://apache.org>) for the proposed patch in the SVN log.
Craig On 11/14/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Author: craigmcc > Date: Mon Nov 14 17:53:40 2005 > New Revision: 344288 > > URL: http://svn.apache.org/viewcvs?rev=344288&view=rev > Log: > [37477] Prefix directory names starting with a digit > > Prefix the returned value for paths whose initial character after the > leading slash is a digit, in addition to prefixing reserved words. This > avoids cases where the returned value is evaluated as a variable name, > because variable names cannot start with a digit. > > Modified: > > struts/shale/trunk/core-library/src/java/org/apache/shale/view/impl/DefaultViewControllerMapper.java > > struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java > > Modified: > struts/shale/trunk/core-library/src/java/org/apache/shale/view/impl/DefaultViewControllerMapper.java > URL: > http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/view/impl/DefaultViewControllerMapper.java?rev=344288&r1=344287&r2=344288&view=diff > > ============================================================================== > --- > struts/shale/trunk/core-library/src/java/org/apache/shale/view/impl/DefaultViewControllerMapper.java > (original) > +++ > struts/shale/trunk/core-library/src/java/org/apache/shale/view/impl/DefaultViewControllerMapper.java > Mon Nov 14 17:53:40 2005 > @@ -32,6 +32,11 @@ > * <li>If the resulting name matches one of the reserved names recognized > * by the default <code>VariableResolver</code>, prefix it with an > * underscore character ("_"), to avoid problems loading managed > beans.</li> > + * <li>If the resulting name starts with a digit character, prefix it > with > + * an underscore character("_"), to avoid problems evaluating value > + * binding expressions using it (because this would be treated as a > + * variable name starting with a digit, and that is not allowed by the > + * syntax of expression evaluation).</li> > * </ul> > * > * <p>Examples of correct managed bean names for typical JSF view > identifiers, > @@ -97,6 +102,8 @@ > } > viewId = viewId.replace('/', '$'); > if (reserved.contains(viewId)) { > + return "_" + viewId; > + } else if ((viewId.length() > 0) && Character.isDigit(viewId.charAt(0))) > { > return "_" + viewId; > } else { > return viewId; > > Modified: > struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java > URL: > http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java?rev=344288&r1=344287&r2=344288&view=diff > > ============================================================================== > --- > struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java > (original) > +++ > struts/shale/trunk/core-library/src/test/org/apache/shale/view/impl/DefaultViewControllerMapperTestCase.java > Mon Nov 14 17:53:40 2005 > @@ -92,6 +92,20 @@ > } > > > + // Test numeric prefix in logical name > + public void testNumeric() { > + > + // Positive ... should be prefixed > + assertEquals("_1$a", dvcm.mapViewId("/1/a.jsp")); > + assertEquals("_1$1$a", dvcm.mapViewId("/1/1/a.jsp")); > + > + // Negative ... should not be prefixed > + assertEquals("a$1$b", dvcm.mapViewId("/a/1/b.jsp")); > + > + } > + > + > + > // Test a pristine instance > public void testPristine() { > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
