You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alec Swan <al...@gmail.com> on 2012/01/22 08:14:47 UTC

AJAX Error in parsing: XML Parsing Error: not well-formed @L

Hello,

I am using Wicket 1.4.17 and have a panel which implements
IHeaderContributor as follows:

public void renderHead(IHeaderResponse response) {
  response.renderString("<script>if (1 == 1 && true) alert('Hello!')</script>");
}

When the panel is updated as a part of AJAX request (by adding to ART)
the following error is shown in Debugger:

ERROR: Error in parsing: XML Parsing Error: not well-formed
Location: http://localhost:8080/...
Line Number 1, Column 67:<head
xmlns:wicket="http://wicket.apache.org"><script>if (1 == 1 && true)
alert('Hello!')</script></head>

Shouldn't ART's header contributor properly escape special XML
characters such as &? How can I fix this?

Thanks,

Alec

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX Error in parsing: XML Parsing Error: not well-formed @L

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Yes, looks like a bug.
Please create a ticket + a quickstart.

On Tue, Jan 24, 2012 at 8:56 PM, Alec Swan <al...@gmail.com> wrote:
> Can anybody comment on this? Is this a bug?
>
> Thanks,
>
> Alec
>
> On Sun, Jan 22, 2012 at 11:50 AM, Alec Swan <al...@gmail.com> wrote:
>> The following workaround works but violates encapsulation. Why doesn't
>> AjaxRequestTarget.AjaxHeaderResponse class escape special XML
>> characters?
>>
>> public void renderHead(IHeaderResponse response) {
>>        String scriptToRender = "<script>if (1 == 1 && true)
>> alert('Hello!')</script>";
>>        if (scriptToRender != null) {
>>            if (AjaxRequestTarget.get() != null) {
>>                scriptToRender = scriptToRender.replace("&", "&amp;");
>> // todo: escape other XML special characters
>>            }
>>            response.renderString(scriptToRender);
>>        }
>>    }
>>
>> Thanks,
>>
>> Alec
>>
>> On Sun, Jan 22, 2012 at 12:14 AM, Alec Swan <al...@gmail.com> wrote:
>>> Hello,
>>>
>>> I am using Wicket 1.4.17 and have a panel which implements
>>> IHeaderContributor as follows:
>>>
>>> public void renderHead(IHeaderResponse response) {
>>>  response.renderString("<script>if (1 == 1 && true) alert('Hello!')</script>");
>>> }
>>>
>>> When the panel is updated as a part of AJAX request (by adding to ART)
>>> the following error is shown in Debugger:
>>>
>>> ERROR: Error in parsing: XML Parsing Error: not well-formed
>>> Location: http://localhost:8080/...
>>> Line Number 1, Column 67:<head
>>> xmlns:wicket="http://wicket.apache.org"><script>if (1 == 1 && true)
>>> alert('Hello!')</script></head>
>>>
>>> Shouldn't ART's header contributor properly escape special XML
>>> characters such as &? How can I fix this?
>>>
>>> Thanks,
>>>
>>> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX Error in parsing: XML Parsing Error: not well-formed @L

Posted by Alec Swan <al...@gmail.com>.
Can anybody comment on this? Is this a bug?

Thanks,

Alec

On Sun, Jan 22, 2012 at 11:50 AM, Alec Swan <al...@gmail.com> wrote:
> The following workaround works but violates encapsulation. Why doesn't
> AjaxRequestTarget.AjaxHeaderResponse class escape special XML
> characters?
>
> public void renderHead(IHeaderResponse response) {
>        String scriptToRender = "<script>if (1 == 1 && true)
> alert('Hello!')</script>";
>        if (scriptToRender != null) {
>            if (AjaxRequestTarget.get() != null) {
>                scriptToRender = scriptToRender.replace("&", "&amp;");
> // todo: escape other XML special characters
>            }
>            response.renderString(scriptToRender);
>        }
>    }
>
> Thanks,
>
> Alec
>
> On Sun, Jan 22, 2012 at 12:14 AM, Alec Swan <al...@gmail.com> wrote:
>> Hello,
>>
>> I am using Wicket 1.4.17 and have a panel which implements
>> IHeaderContributor as follows:
>>
>> public void renderHead(IHeaderResponse response) {
>>  response.renderString("<script>if (1 == 1 && true) alert('Hello!')</script>");
>> }
>>
>> When the panel is updated as a part of AJAX request (by adding to ART)
>> the following error is shown in Debugger:
>>
>> ERROR: Error in parsing: XML Parsing Error: not well-formed
>> Location: http://localhost:8080/...
>> Line Number 1, Column 67:<head
>> xmlns:wicket="http://wicket.apache.org"><script>if (1 == 1 && true)
>> alert('Hello!')</script></head>
>>
>> Shouldn't ART's header contributor properly escape special XML
>> characters such as &? How can I fix this?
>>
>> Thanks,
>>
>> Alec

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX Error in parsing: XML Parsing Error: not well-formed @L

Posted by Alec Swan <al...@gmail.com>.
The following workaround works but violates encapsulation. Why doesn't
AjaxRequestTarget.AjaxHeaderResponse class escape special XML
characters?

public void renderHead(IHeaderResponse response) {
        String scriptToRender = "<script>if (1 == 1 && true)
alert('Hello!')</script>";
        if (scriptToRender != null) {
            if (AjaxRequestTarget.get() != null) {
                scriptToRender = scriptToRender.replace("&", "&amp;");
// todo: escape other XML special characters
            }
            response.renderString(scriptToRender);
        }
    }

Thanks,

Alec

On Sun, Jan 22, 2012 at 12:14 AM, Alec Swan <al...@gmail.com> wrote:
> Hello,
>
> I am using Wicket 1.4.17 and have a panel which implements
> IHeaderContributor as follows:
>
> public void renderHead(IHeaderResponse response) {
>  response.renderString("<script>if (1 == 1 && true) alert('Hello!')</script>");
> }
>
> When the panel is updated as a part of AJAX request (by adding to ART)
> the following error is shown in Debugger:
>
> ERROR: Error in parsing: XML Parsing Error: not well-formed
> Location: http://localhost:8080/...
> Line Number 1, Column 67:<head
> xmlns:wicket="http://wicket.apache.org"><script>if (1 == 1 && true)
> alert('Hello!')</script></head>
>
> Shouldn't ART's header contributor properly escape special XML
> characters such as &? How can I fix this?
>
> Thanks,
>
> Alec

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org