You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Martin Grigorov <mg...@apache.org> on 2010/12/28 10:53:50 UTC

Re: svn commit: r1053077 - in /wicket/trunk: wicket-core/src/main/java/org/apache/wicket/Component.java wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java

Hi,

I am not sure whether I fix this properly yesterday.
With the change in Component.java now every character which is not in range
32-159 is being xml encoded.
This led to two test expectation changes (see r1053284 and r1053288).

To keep the old behavior and still encode chars < 32 for WICKET-2264 the
patch could look like:

https://gist.github.com/757094

Since Ajax responses always have <?xml encoding="(app.setting)"> I think it
is safe to not use xml entities representation for characters > 159.

Currently everything works fine, the HTML content is correct. It is just
that the Ajax response for non-ASCII chars looks "uglier" because they are
represented with their html entities.

Opinions whether to keep it like it is now or to revert to the old behavior
+ fix for wicket-2264 (see gist) ?

On Mon, Dec 27, 2010 at 3:34 PM, <mg...@apache.org> wrote:

> Author: mgrigorov
> Date: Mon Dec 27 14:34:23 2010
> New Revision: 1053077
>
> URL: http://svn.apache.org/viewvc?rev=1053077&view=rev
> Log:
> WICKET-2264 Ajax xml response is not validated correct
>
> HTML escape all characters which are not in range 32-159 (incl.)
>
> Modified:
>    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
>
>  wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
>
> Modified:
> wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
> URL:
> http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java?rev=1053077&r1=1053076&r2=1053077&view=diff
>
> ==============================================================================
> --- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
> (original)
> +++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
> Mon Dec 27 14:34:23 2010
> @@ -1728,7 +1728,7 @@ public abstract class Component
>                                if (getFlag(FLAG_ESCAPE_MODEL_STRINGS))
>                                {
>                                        // Escape HTML sensitive characters
> only. Not all none-ascii chars
> -                                       return
> Strings.escapeMarkup(modelString, false, false).toString();
> +                                       return
> Strings.escapeMarkup(modelString, false, true).toString();
>                                }
>                                return modelString;
>                        }
>
> Modified:
> wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
> URL:
> http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java?rev=1053077&r1=1053076&r2=1053077&view=diff
>
> ==============================================================================
> ---
> wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
> (original)
> +++
> wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
> Mon Dec 27 14:34:23 2010
> @@ -354,7 +354,7 @@ public final class Strings
>                                                if
> (convertToHtmlUnicodeEscapes)
>                                                {
>                                                        int ci = 0xffff & c;
> -                                                       if (ci < 160)
> +                                                       if (ci > 31 && ci <
> 160)
>                                                        {
>                                                                // nothing
> special only 7 Bit
>
>  buffer.append(c);
>
>
>

Re: svn commit: r1053077 - in /wicket/trunk: wicket-core/src/main/java/org/apache/wicket/Component.java wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java

Posted by Martin Grigorov <mg...@apache.org>.
Ping (just to raise this email at the top of your mailboxes :-)

On Tue, Dec 28, 2010 at 10:53 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> I am not sure whether I fix this properly yesterday.
> With the change in Component.java now every character which is not in range
> 32-159 is being xml encoded.
> This led to two test expectation changes (see r1053284 and r1053288).
>
> To keep the old behavior and still encode chars < 32 for WICKET-2264 the
> patch could look like:
>
> https://gist.github.com/757094
>
> Since Ajax responses always have <?xml encoding="(app.setting)"> I think it
> is safe to not use xml entities representation for characters > 159.
>
> Currently everything works fine, the HTML content is correct. It is just
> that the Ajax response for non-ASCII chars looks "uglier" because they are
> represented with their html entities.
>
> Opinions whether to keep it like it is now or to revert to the old behavior
> + fix for wicket-2264 (see gist) ?
>
> On Mon, Dec 27, 2010 at 3:34 PM, <mg...@apache.org> wrote:
>
>> Author: mgrigorov
>> Date: Mon Dec 27 14:34:23 2010
>> New Revision: 1053077
>>
>> URL: http://svn.apache.org/viewvc?rev=1053077&view=rev
>> Log:
>> WICKET-2264 Ajax xml response is not validated correct
>>
>> HTML escape all characters which are not in range 32-159 (incl.)
>>
>> Modified:
>>    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
>>
>>  wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
>>
>> Modified:
>> wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
>> URL:
>> http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java?rev=1053077&r1=1053076&r2=1053077&view=diff
>>
>> ==============================================================================
>> ---
>> wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
>> (original)
>> +++
>> wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java Mon
>> Dec 27 14:34:23 2010
>> @@ -1728,7 +1728,7 @@ public abstract class Component
>>                                if (getFlag(FLAG_ESCAPE_MODEL_STRINGS))
>>                                {
>>                                        // Escape HTML sensitive characters
>> only. Not all none-ascii chars
>> -                                       return
>> Strings.escapeMarkup(modelString, false, false).toString();
>> +                                       return
>> Strings.escapeMarkup(modelString, false, true).toString();
>>                                }
>>                                return modelString;
>>                        }
>>
>> Modified:
>> wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
>> URL:
>> http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java?rev=1053077&r1=1053076&r2=1053077&view=diff
>>
>> ==============================================================================
>> ---
>> wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
>> (original)
>> +++
>> wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
>> Mon Dec 27 14:34:23 2010
>> @@ -354,7 +354,7 @@ public final class Strings
>>                                                if
>> (convertToHtmlUnicodeEscapes)
>>                                                {
>>                                                        int ci = 0xffff &
>> c;
>> -                                                       if (ci < 160)
>> +                                                       if (ci > 31 && ci
>> < 160)
>>                                                        {
>>                                                                // nothing
>> special only 7 Bit
>>
>>  buffer.append(c);
>>
>>
>>
>