You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2011/04/20 22:14:31 UTC

[S1] Curly braces are unescapable in MessageResources

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I've been using S1 for years to great satisfaction. Thanks!

I'm coming up against a problem that I think I can't get around, so I'm
posing it to the community to see if anyone can help.

We have a regular expression that we want to put into a properties file
so we can

a) Use it as a <var> in our validation configuration

and

b) Use it from within our web forms as part of a "pattern" element for
   HTML5-compatible browsers

Everything seems to work great until we introduce {...} multiplicity
selectors in the regular expression (specifically, "[whatever]{5,17}").
First, we get an error from MessageFormat saying that it can't parse the
"5,17" into a meaningful format.

Once we escape the braces like this "[whatever]'{'5,17'}'" we get a new
error that was hard to diagnose because we didn't know that Struts was
escaping single-quotes in MessageResources.getMessage().

I think we're stuck, short of re-writing our expressions to use a LOT of
alternatives, making them a total PITA to maintain.

Any suggestions? Are we overlooking anything, here?

We're using version 1.3.8 specifically if that changes anything.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2vPqcACgkQ9CaO5/Lv0PAg3ACgsHfzE+TcwGGIFJfqYQgk9Uwj
31IAoI8pWkQzrLFl46IUzVzgP4J8n//7
=Yelu
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S1] Curly braces are unescapable in MessageResources

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave,

On 4/20/2011 6:46 PM, Dave Newton wrote:
> I'd play with the MessageFormat Javadocs:
> 
>> Within a String, "''" represents a single quote. A QuotedString can contain arbitrary
>> characters except single quotes; the surrounding single quotes are removed. An
>> UnquotedString can contain arbitrary characters except single quotes and left curly
>> brackets. Thus, a string that should result in the formatted message "'{0}'" can be
>> written as "'''{'0}''" or "'''{0}'''".
> 
> I'd try some combinations of that; I recall having a similar issue at
> one point but don't remember what finally resolved it.

Thanks for the reply... we're trying things like that, but reading the
"escape" code in MessageResources, it looks like any number of
single-quote characters will be doubled, so I can't escape the escaping. :(

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2wPmkACgkQ9CaO5/Lv0PDvRgCeL+L+q+WngX02RAX70FeGucw+
ZsUAnRoXF2z6TKCChD+sMQKXIVkj/b5D
=bG0s
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S1] Curly braces are unescapable in MessageResources

Posted by Dave Newton <da...@gmail.com>.
I'd play with the MessageFormat Javadocs:

> Within a String, "''" represents a single quote. A QuotedString can contain arbitrary
> characters except single quotes; the surrounding single quotes are removed. An
> UnquotedString can contain arbitrary characters except single quotes and left curly
> brackets. Thus, a string that should result in the formatted message "'{0}'" can be
> written as "'''{'0}''" or "'''{0}'''".

I'd try some combinations of that; I recall having a similar issue at
one point but don't remember what finally resolved it.

Dave

On Wed, Apr 20, 2011 at 4:14 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> All,
>
> I've been using S1 for years to great satisfaction. Thanks!
>
> I'm coming up against a problem that I think I can't get around, so I'm
> posing it to the community to see if anyone can help.
>
> We have a regular expression that we want to put into a properties file
> so we can
>
> a) Use it as a <var> in our validation configuration
>
> and
>
> b) Use it from within our web forms as part of a "pattern" element for
>   HTML5-compatible browsers
>
> Everything seems to work great until we introduce {...} multiplicity
> selectors in the regular expression (specifically, "[whatever]{5,17}").
> First, we get an error from MessageFormat saying that it can't parse the
> "5,17" into a meaningful format.
>
> Once we escape the braces like this "[whatever]'{'5,17'}'" we get a new
> error that was hard to diagnose because we didn't know that Struts was
> escaping single-quotes in MessageResources.getMessage().
>
> I think we're stuck, short of re-writing our expressions to use a LOT of
> alternatives, making them a total PITA to maintain.
>
> Any suggestions? Are we overlooking anything, here?
>
> We're using version 1.3.8 specifically if that changes anything.
>
> Thanks,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk2vPqcACgkQ9CaO5/Lv0PAg3ACgsHfzE+TcwGGIFJfqYQgk9Uwj
> 31IAoI8pWkQzrLFl46IUzVzgP4J8n//7
> =Yelu
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org