analytics-reporter icon indicating copy to clipboard operation
analytics-reporter copied to clipboard

JSON encoding not specified

Open kqdreger opened this issue 10 years ago • 9 comments
trafficstars

Regarding a potential fix for GSA/analytics.usa.gov/issues/149, it looks like app/routes.js isn't specifying the character set for the returned JSON. Pulled from StackOverflow #16268244:

Set the res.header("Content-Type", "application/json; charset=utf-8"); so that the browser knows what character set to use.

kqdreger avatar Mar 19 '15 18:03 kqdreger

+1 this solution. The file command thinks the output is UTF-8 encoded, and vim (being utf-8 aware) displays the characters correctly

cmc333333 avatar Mar 20 '15 02:03 cmc333333

The dashboard gets JSON from S3 - the Express endpoints here are not currently used in production. This is a good note and we'll integrate the fix, but it won't resolve https://github.com/GSA/analytics.usa.gov/issues/149.

konklone avatar Mar 20 '15 15:03 konklone

Won't S3 let you set the Content-Type header to include the encoding?

shawnbot avatar Mar 20 '15 17:03 shawnbot

@shawnbot It looks like the content encoding is getting set to gzip?

https://github.com/18F/analytics-reporter/blob/master/bin/analytics#L42-L49

kqdreger avatar Mar 20 '15 18:03 kqdreger

We should update the Content-Type, not the Content-Encoding. Thanks for pointing this out -- we'll fix.

konklone avatar Mar 20 '15 18:03 konklone

Yeah sorry, I meant that the Content-Type header should be set to application/json; charset=utf-8 on S3, rather than just application/json.

shawnbot avatar Mar 20 '15 18:03 shawnbot

Was this what you had in mind? https://github.com/18F/analytics-reporter/pull/128

ArcTanSusan avatar Dec 08 '15 06:12 ArcTanSusan

@jmhooper, @laurenancona, anyone else here - game to check if https://github.com/18F/analytics-reporter/pull/128 resolved this issue?

gbinal avatar May 30 '17 19:05 gbinal

@gbinal: I believe it would have, but that is dead code now.

jmhooper avatar Jun 05 '17 15:06 jmhooper