Re: [tools 2.0] ValueParser.getStrings splits on comma?

Claude Brisson <[email protected]> Tue, 22 Aug 2017 18:30:03 +0200
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <[email protected]>
Strangely, I've never hit this one before, but yes, the ValueParser does
consider that values can be string lists, with the coma as the default
string delimiter.

I guess it can be useful in some contexts, but I'm not sure that someone
parsing one's form results would expect this behavior where the presence
of a coma in some string is user-dependant.

The tools configuration does rely on this behavior (so that you can have
<data key="my_strings" value="foo,bar"/>), but it could use a
specifically configured instance to do so. So we can change or inhibit
the default string separator.

   Claude


On 22/08/2017 03:00, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> All,
>
> I'm not sure if I've used ValueParser.getStrings before (really,
> ParameterParser.getStrings, in this case), but I'm surprised by what
> is happening. Is this expected?
>
> Request POST parameters:
> foo=bar&comment=This, is a comment.
>
> Velocity template code:
>
> #set($comments = $parameterParser.getStrings('comment'))
> #if(0 < $comments.size())
> #foreach($comment in $comments)
>    <div class="comment">
>      <textarea name="comment"
> placeholder="$msg.label.optional_comments">#htmlEscape($comment)</textar
> ea>
>    </div>
> #end## foreach
> #end## if(comments)
>
> I would expect this to produce a single <textarea> element with the
> text "This, is a comment." in the text area. Instead, I get two
> <textarea> elements, one containing "This" and the other containing
> "is a comment.".
>
> That seems ... crazy to me. I'm sure I can just change:
>
> #set($comments = $parameterParser.getStrings('comment'))
> to
> #set($comments = $request.getParameterValues('comment'))
>
> ... but I figured that ParameterParser would do the same thing, no?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJZm4ISAAoJEBzwKT+lPKRYKnUP+wQ0ZrGhe4R5X2tCi2nmrzJW
> mgb1fqmBOd5m7TPz9iJnfj6jtLlK2u2u0cPp3BHsFyu8Y4RX5heC1RZ6fJfOPFx1
> Tq5t3JXDoK0XmOL7/VI7R5eadQww9LDbdwR10Gl7Qch9IAfsgYNINIgZwGC1OawD
> kXTc6m8lwKlvBnI7biyncDVY3pOoojh7EQNI6/sh1/hR2n2R35Fa9mpK7Y0Tjk/K
> VkvhqLcuTqii3zlGTBTS0Zzn9XE5+jzFn7wNWmrdbmMYMKKyQCne7gvzH5j3RnK+
> S9jAO/WVazKp2qI7xcAqg1upjqVfP9Rtg/cZOf0hR3swbe5+kJJcP2uw7YEDPGI0
> orFGiIVRTI8+d1FwD4rsn6uoke43p/UVm/2McCkXTkWrvcZ29BLIyin6W+i4/Z6D
> iDciX12YPD/abFsGqMEgAw4CG6WkvlZQnsAtQAtHW5EiDR4DpQQsjeYWxCE+O6SH
> r0lUhGxzed9vBR1M4l5DbnbXRaLJ+kjjZRuDPDLlfXIisD9szdgGOOG8r1dWggaa
> yZXGD/jN6MdnGp12xx7x53+RNqwAPx6o3SJqhJFUxHmOmShIOesoGdv/OsHQk4ep
> tnnlJ8c7bE8oRsH4nT3VxSymY0GCIJFzWvUr2/2lw2wSHW6Om5JoampBamerhmdk
> Lcqksts97wZmYrx+idl4
> =w9Ic
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>