[ 
https://issues.apache.org/jira/browse/WICKET-6247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pedro Santos updated WICKET-6247:
---------------------------------
    Description: 
A property expression having a '[' character inside squar brackets like 
"bean.map[code[foo]" will fail because PropertyResolver replaces all '[' 
charaters by '.['

example:

{code:title=PropertyResolverTest.java|borderStyle=solid}
        @Test
        public void shouldAllowMapKeysWithSpecialCharacters() throws Exception
        {
                String code = "[!@#$%^&*()_+-=[{}|]";
                String expression = "[" + code + "]";
                Map<String, Integer> integerMap = new HashMap<String, 
Integer>();
                PropertyResolver.setValue(expression, integerMap, AN_INTEGER, 
CONVERTER);
                assertThat(PropertyResolver.getValue(expression, integerMap), 
is(AN_INTEGER));
                assertThat(integerMap.get(code), is(AN_INTEGER));
        }
{code}

Plus a property expression having a ']' followed by a dot will fail because the 
dot will be taken as a token separator by PropertyResolver#getNextDotIndex

{code:title=PropertyResolverTest.java|borderStyle=solid}
        @Test
        public void shouldAllowMapKeysWithADotAfterAClosingSquarBraket() throws 
Exception
        {
                String code = "].";
                String expression = "[" + code + "]";
                Map<String, Integer> integerMap = new HashMap<String, 
Integer>();
                PropertyResolver.setValue(expression, integerMap, AN_INTEGER, 
CONVERTER);
                assertThat(PropertyResolver.getValue(expression, integerMap), 
is(AN_INTEGER));
                assertThat(integerMap.get(code), is(AN_INTEGER));
        }
{code}

A possible solution is to use escape characters and there is a proposal to 
change the property expression syntax with such escape logic at: 
http://wicket-dev.markmail.org/thread/unwdqpxulw7tcd5l

If we take the lack of support for valid index characters (a map key can 
contain '[', ']' and '.' characters) as a missing feature by design, we should 
update our wiki topic [1] to make it clear.

1 - 
https://cwiki.apache.org/confluence/display/WICKET/Property+Expression+Language

  was:
A property expression having a '[' character inside squar brackets like 
"bean.map[code[foo]" will fail because PropertyResolver replaces all '[' 
charaters by '.['

example:

{code:title=PropertyResolverTest.java|borderStyle=solid}
        @Test
        public void shouldAllowMapKeysWithSpecialCharacters() throws Exception
        {
                String code = "[!@#$%^&*()_+-=[{}|]";
                String expression = "[" + code + "]";
                Map<String, Integer> integerMap = new HashMap<String, 
Integer>();
                PropertyResolver.setValue(expression, integerMap, AN_INTEGER, 
CONVERTER);
                assertThat(PropertyResolver.getValue(expression, integerMap), 
is(AN_INTEGER));
                assertThat(integerMap.get(code), is(AN_INTEGER));
        }
{code}

Plus a property expression having a ']' followed by a dot will fail because the 
dot will be taken as a token separator by PropertyResolver#getNextDotIndex

{code:title=PropertyResolverTest.java|borderStyle=solid}
        @Test
        public void shouldAllowMapKeysWithADotAfterAClosingSquarBraket() throws 
Exception
        {
                String code = "].";
                String expression = "[" + code + "]";
                Map<String, Integer> integerMap = new HashMap<String, 
Integer>();
                PropertyResolver.setValue(expression, integerMap, AN_INTEGER, 
CONVERTER);
                assertThat(PropertyResolver.getValue(expression, integerMap), 
is(AN_INTEGER));
                assertThat(integerMap.get(code), is(AN_INTEGER));
        }
{code}

If we take this lack of support for valid index characters ( a map key can 
contain '
http://wicket-dev.markmail.org/thread/unwdqpxulw7tcd5l


> Property expression don't support '[', ']' and '.' characters inside square 
> brackets
> ------------------------------------------------------------------------------------
>
>                 Key: WICKET-6247
>                 URL: https://issues.apache.org/jira/browse/WICKET-6247
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 8.0.0-M1, 7.4.0, 6.24.0
>            Reporter: Pedro Santos
>            Assignee: Pedro Santos
>
> A property expression having a '[' character inside squar brackets like 
> "bean.map[code[foo]" will fail because PropertyResolver replaces all '[' 
> charaters by '.['
> example:
> {code:title=PropertyResolverTest.java|borderStyle=solid}
>       @Test
>       public void shouldAllowMapKeysWithSpecialCharacters() throws Exception
>       {
>               String code = "[!@#$%^&*()_+-=[{}|]";
>               String expression = "[" + code + "]";
>               Map<String, Integer> integerMap = new HashMap<String, 
> Integer>();
>               PropertyResolver.setValue(expression, integerMap, AN_INTEGER, 
> CONVERTER);
>               assertThat(PropertyResolver.getValue(expression, integerMap), 
> is(AN_INTEGER));
>               assertThat(integerMap.get(code), is(AN_INTEGER));
>       }
> {code}
> Plus a property expression having a ']' followed by a dot will fail because 
> the dot will be taken as a token separator by PropertyResolver#getNextDotIndex
> {code:title=PropertyResolverTest.java|borderStyle=solid}
>       @Test
>       public void shouldAllowMapKeysWithADotAfterAClosingSquarBraket() throws 
> Exception
>       {
>               String code = "].";
>               String expression = "[" + code + "]";
>               Map<String, Integer> integerMap = new HashMap<String, 
> Integer>();
>               PropertyResolver.setValue(expression, integerMap, AN_INTEGER, 
> CONVERTER);
>               assertThat(PropertyResolver.getValue(expression, integerMap), 
> is(AN_INTEGER));
>               assertThat(integerMap.get(code), is(AN_INTEGER));
>       }
> {code}
> A possible solution is to use escape characters and there is a proposal to 
> change the property expression syntax with such escape logic at: 
> http://wicket-dev.markmail.org/thread/unwdqpxulw7tcd5l
> If we take the lack of support for valid index characters (a map key can 
> contain '[', ']' and '.' characters) as a missing feature by design, we 
> should update our wiki topic [1] to make it clear.
> 1 - 
> https://cwiki.apache.org/confluence/display/WICKET/Property+Expression+Language



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to