users@jsr311.java.net

Re: JAX-RS: _at_Path limited=false templates: (?!/).+(?<!/)

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 03 Jul 2008 10:18:49 -0400

On Jul 3, 2008, at 9:32 AM, Bill Burke wrote:
>>> 1) Only allow '{' and '}' chars in the regex as part of '{…}'
>>> pairs that are not nested. The restriction applies even if a char
>>> is escaped as \{ in the regex.
>>> {foo:X{2,3}} is allowed (matching XX or XXX)
>>> {foo:X[^}]Y} is not allowed
>>>
>>> 2) Delimit the regex with ` or space (instead of : and }). These
>>> chars have no special meaning in a regex, and are not allowed in
>>> URI paths (and don't need escaping in a Java String). Consequently
>>> they shouldn't be needed in the regex so they can be forbidden.
>>> {foo`.*`} or {foo".*"} or {foo .* }
>>>
>>> 3) Disallow any '}' chars in the regex.
>>>
>> I like 3. '}' is not allowed in a URI path unless its escaped so it
>> doesn't seem like a big restriction to me.
>
> Why do you like #3? I think we should support any regex after : and
> before the last '}'.

To clarify, I meant an unpaired '}'. 3 seems to me to be the simplest
approach and doesn't IMO restrict the functionality since you are
unlikely to encounter '}' in a URI path anyway so it doesn't seem
worthwhile to complicate things to allow it.

> Its not hard to parse to create the correct path regex and
> documenting this feature becomes easier as you just point the user
> to the javadoc on Pattern.java or something similar. I liked the
> ':' delimiter because its pleasing to the eye and I've seen similar
> approaches in the past with other frameworks/languages, etc.
>
I also like the : delimiter.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.