carviaso / google-checkout-dotnet-sample-code

Automatically exported from code.google.com/p/google-checkout-dotnet-sample-code
0 stars 0 forks source link

© ® aren't encoded correctly #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Post a cart with an item with © ® in the name.

What is the expected output? What do you see instead?
I'd expect to see the © ® characters on the Google Checkout page. I do seem
them, but there is another junk character after them as well.

Original issue reported on code.google.com by martin.o...@gmail.com on 13 Sep 2006 at 3:51

GoogleCodeExporter commented 9 years ago

Original comment by martin.o...@gmail.com on 28 Oct 2006 at 12:26

GoogleCodeExporter commented 9 years ago

Original comment by martin.o...@gmail.com on 24 Dec 2006 at 9:05

GoogleCodeExporter commented 9 years ago
Scandinavian characters (åäö) are also encoded incorrectly.

Original comment by martin.o...@gmail.com on 24 Dec 2006 at 9:12

GoogleCodeExporter commented 9 years ago
I attempted to fix the bug. I am able to send a message to GC containing (c) 
(r) and 
TM characters and they display properly, but the new-order-notification message 
is 
corrupted and all that is returned for any high level ascii characters(>127) is 
?.

It would appear that GC is not processing the Item Name and Description is not 
being 
handled as UTF-8, or Google is not able to handle Numeric Character References 
(NCRs).

Original comment by joseph.f...@gmail.com on 3 Jan 2007 at 3:03

GoogleCodeExporter commented 9 years ago
I performed a separate test to ensure there is a bug in Google Checkout related 
to 
how the Item name and Description are processed and returned.

I used a product with the name of:

Black Walnut Burl < © ® ™ >

and a description of:

Black Walnut Burl Wine Stopper < © ® ™ >

Both displayed correctly, calling either version of the EscapeXmlChars function 
as 
seen below.

The results that were returned in the new order confirmation were as follows.

Name: Black Walnut Burl &amp;lt; ? ? ? &amp;gt;
Description: Black Walnut Burl Wine Stopper &amp;lt; ? ? ? &amp;gt;

It appears that any high level ascii character is not being handled correctly. 
Any 
Numeric Character References 
(NCRs) are being replaced with a ?.

Usually this happens when a stream is read as ascii when it should be read as 
utf-8.

I have to assume this is done for security reasons.

Are we too assume that any non us English character will not be properly 
handled by 
Google checkout?

If I do not perform the conversion for the (c) or (r) symbols, I receive a Cart 
Signature Error from GC.

If you would like any additional code, please contact me.

Joe Feser

Sample changes to EncoderHelper.EscapeXmlChars

public static string EscapeXmlChars(string In) {
    string RetVal = In;
    RetVal = RetVal.Replace("&", "&#x26;");
    RetVal = RetVal.Replace("<", "&#x3c;");
    RetVal = RetVal.Replace(">", "&#x3e;");
    RetVal = RetVal.Replace("©", "&copy;");
    RetVal = RetVal.Replace("®", "&reg;");
    RetVal = RetVal.Replace("™", "&trade;");
    return RetVal;
}

public static string EscapeXmlChars(string In) {
    string RetVal = In;
    RetVal = RetVal.Replace("&", "&#x26;");
    RetVal = RetVal.Replace("<", "&#x3c;");
    RetVal = RetVal.Replace(">", "&#x3e;");
    RetVal = RetVal.Replace("©", "&#xA9;");
    RetVal = RetVal.Replace("®", "&#xAE;");
    RetVal = RetVal.Replace("™", "&#x2122;");
    return RetVal;
}

Original comment by joseph.f...@gmail.com on 4 Jan 2007 at 12:21

GoogleCodeExporter commented 9 years ago
Fixed in version 31 of the code. The Dev Guide said that the content-type 
header of
requests sent to Google should say "application/pdf", but it should say
"application/pdf; charset=UTF-8" instead.

Original comment by martin.o...@gmail.com on 20 Jan 2007 at 10:30

GoogleCodeExporter commented 9 years ago
Silly me. My Jan 20 comment on this bug should have read:

Fixed in version 31 of the code. The Dev Guide said that the content-type 
header of
requests sent to Google should say "application/xml", but it should say
"application/xml; charset=UTF-8" instead.

Forget the nonsense about "pdf" in yesterday's comment.

Original comment by martin.o...@gmail.com on 21 Jan 2007 at 11:10