Unknown/unsupported html entity for single quote

36 views
Skip to first unread message

Sand

unread,
May 16, 2009, 9:44:04 AM5/16/09
to rocket-gwt
Hi ,

Can anybody give me the list for supported html entities for Rocket.
Because when i send User object with the name containing a single
quote then that user object is not sent to client side.

How can add support to single quote. I tried to add in Utilities.java
of Rocket/Util module as follows.

if (entity.equals("#39")){
buf.append('\'');
continue;
}

But still it is not working for me.
Thanks & advance


Thanks & Regards
Sandeep

Sand

unread,
May 16, 2009, 9:46:59 AM5/16/09
to rocket-gwt


On May 16, 6:44 pm, Sand <sandip.pati...@gmail.com> wrote:
> Hi ,
>
> Can anybody give me the list for supported html entities for Rocket.
> Because when i send User object with the name containing a single
> quote then that user object is not sent to client side.
>
> How can add support to single quote. I tried to add in Utilities.java
> of Rocket/Util module as follows.
forgot to add code from htmlEncode method
if ('\'' == c) {
buf.append("&#39;");
continue;
}
>
> if (entity.equals("#39")){
>         buf.append('\'');
>        continue;
>
> }
>
> But still it is not working for me.
> Thanks in advance
>
> Thanks & Regards
> Sandeep

Miroslav Pokorny

unread,
May 16, 2009, 6:54:50 PM5/16/09
to rocke...@googlegroups.com
You don't need to escape quotes in HTML.

Sand

unread,
May 17, 2009, 4:26:33 AM5/17/09
to rocket-gwt
but then what is happening to my User object with apostrophe in name
or some other field.
Rocket is not sending it to client side.

Can you suggest me something about this

Thanks & Regards
Sandeep

On May 17, 3:54 am, Miroslav Pokorny <miroslav.poko...@gmail.com>
wrote:
> You don't need to escape quotes in HTML.
> phe
> On 16/05/2009, at 11:46 PM, Sand <sandip.pati...@gmail.com> wrote:
>
>
>
>
>
> > On May 16, 6:44 pm, Sand <sandip.pati...@gmail.com> wrote:
> >> Hi ,
>
> >> Can anybody give me the list for supported html entities for Rocket.
> >> Because when i send User object with the name containing a single
> >> quote then that user object is not sent to client side.
>
> >> How can add support to single quote. I tried to add in Utilities.java
> >> of Rocket/Util module as follows.
> > forgot to add code from  htmlEncode method
> >    if ('\'' == c) {
> >     buf.append("&#39;");
> >     continue;
> >  }
>
> >> if (entity.equals("#39")){
> >>         buf.append('\'');
> >>        continue;
>
> >> }
>
> >> But still it is not working for me.
> >> Thanks in advance
>
> >> Thanks & Regards
> >> Sandeep- Hide quoted text -
>
> - Show quoted text -

Sand

unread,
May 17, 2009, 4:51:49 AM5/17/09
to rocket-gwt
Hi Miroslav,

Is following issue open with Rocket

http://code.google.com/p/rocket-gwt/issues/detail?id=50#c1

Thanks & Regards
Sandeep
> > - Show quoted text -- Hide quoted text -

Miroslav Pokorny

unread,
May 18, 2009, 12:15:27 AM5/18/09
to rocke...@googlegroups.com, rocket-gwt

Hi Sandip

Have you tried with firebug running so you can verify everything
actually got sent over the wire.

Lemme know what happens...

Sand

unread,
May 25, 2009, 8:10:20 AM5/25/09
to rocket-gwt
Hi Miroslav,

For now i am replacing apostrophe with a low order ASCII character at
server side.
And when i get that character at client side i again replace it with
apostrophe to display.


Thanks & Regards
Sandeep

On May 18, 9:15 am, Miroslav Pokorny <miroslav.poko...@gmail.com>
wrote:
> Hi Sandip
>
> Have you tried with firebug running so you can verify everything  
> actually got sent over the wire.
>
> Lemme know what happens...
>

Sand

unread,
Jun 10, 2009, 10:45:29 AM6/10/09
to rocket-gwt
Hi Miroslav,

Again I was facing same problem to send " (double quotes) across to
client side using Rocket.

I have done some changes in Utilities in htmlEncode and htmlDecode
methods.Can you please check them and give me some suggestions on
this.

While encoding I replace ' & " with lower order ASCII characters and
when they are received at client side then again I replace ASCII
characters back with ' & ".
Changes are as follows

/**
* Accepts a plain string escaping various characters so that the
given
* string is html encoded.
*
* @param plainText
* @return
*/
static final char replaceCharFroQuote = 0x11;
static final char replaceCharForDoubleQuote = 0x12;
public static String htmlEncode(final String plainText) {
Checker.notNull("parameter:plainText", plainText);

final StringBuffer buf = new StringBuffer();
final int length = plainText.length();
for (int i = 0; i < length; i++) {
final char c = plainText.charAt(i);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
start !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if('\\'==c){
i++;
final char g = plainText.charAt(i);

if(g=='\"'){
buf.append(replaceCharForDoubleQuote);
}else{
buf.append(c);
}
continue;
}
if('\''==c){

buf.append(replaceCharFroQuote);
continue;
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
END!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ('<' == c) {
buf.append("&lt;");
continue;
}
if ('>' == c) {
buf.append("&gt;");
continue;
}
if ('&' == c) {
buf.append("&amp;");
continue;
}
// if ('\'' == c) {
// buf.append("&#39;");
// continue;
// }
if ('"' == c) {
buf.append("&quot;");
continue;
}
buf.append(c);
}

return buf.toString();
}

/**
* Accepts a encoded string and returns the original decoded value.
*
* @param htmlEncodedText
* @return
*/
public static String htmlDecode(final String htmlEncodedText) {
Checker.notNull("parameter:htmlEncodedText", htmlEncodedText);

final StringBuffer buf = new StringBuffer();
final int length = htmlEncodedText.length();
for (int i = 0; i < length;) {
final char c = htmlEncodedText.charAt(i);
i++;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
START!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

if('\\'==c){
buf.append('\\');

}

if(replaceCharFroQuote==c){

buf.append('\'');
continue;
}
if(replaceCharForDoubleQuote==c){
buf.append('\\');
buf.append('\"');
continue;
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
END !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ('&' == c) {
final int semiColon = htmlEncodedText.indexOf(';', i);
final String entity = htmlEncodedText.substring(i, semiColon);
i = semiColon + 1;

if (entity.equals("lt")) {
buf.append("<");
continue;
}

if (entity.equals("gt")) {
buf.append(">");
continue;
}

if (entity.equals("amp")) {
buf.append("&");
continue;
}
if (entity.equals("quot")) {
buf.append('"');
continue;
}
// if (entity.equals("#39")){
// buf.append('\'');
// continue;
//
// }
throw new RuntimeException("Unknown/unsupported html entity &" +
entity + ";");
}
buf.append(c);
}

return buf.toString();
Reply all
Reply to author
Forward
0 new messages