[Geoserver-devel] Layer preview charset

Hello,

I’m having trouble previewing layers in GeoServer 2.7.1.
It did not exist in 2.4.2.

It occurs when previewing layers with special characters in its name.
Probably related to https://osgeo-org.atlassian.net/browse/GEOS-4858

It did not work to change the document encoding of the OpenLayers3MapTemplate.ftl to UTF-8.
The output format tries to return the response in UTF-8:

OpenLayersMapOutputFormat.produceMap:


template.setOutputEncoding(“UTF-8”);
ByteArrayOutputStream buff = new ByteArrayOutputStream();
template.process(map, new OutputStreamWriter(buff, Charset.forName(“UTF-8”)));
RawMap result = new RawMap(mapContent, buff, MIME_TYPE);

return result;

But, when looking at the response in Chrome I get a content type without charset information:
Content-Type:text/html; subtype=openlayers

The following resources ol3.js and ol.css are correctly served as
Content-Type:application/x-javascript; charset=UTF-8 and

Content-Type:text/css; charset=UTF-8

When looking at the response from the GetMap response and copying the content to a text editor I can see that the encoding of the document is “UTF-8 without BOM”.
If I serve the same file locally (through IIS as plain html) I get the same behavior but when saving the document as UTF-8 I get a working layer preview page.

Any ideas on how to get the RawMap result to render the charset=UTF-8 information to the browser?

Regards,
Olle Markljung

Hi again,

Adding

to the of the ol3 template seems to solve the issue.

I’ll create a PR tonight for you to verify and hopefully you will allow a backport to the stable branch.

Regards,
Olle Markljung

tis 26 maj 2015 kl. 15:51 skrev Olle Markljung <markljung@anonymised.com>:

Hello,

I’m having trouble previewing layers in GeoServer 2.7.1.
It did not exist in 2.4.2.

It occurs when previewing layers with special characters in its name.
Probably related to https://osgeo-org.atlassian.net/browse/GEOS-4858

It did not work to change the document encoding of the OpenLayers3MapTemplate.ftl to UTF-8.
The output format tries to return the response in UTF-8:

OpenLayersMapOutputFormat.produceMap:


template.setOutputEncoding(“UTF-8”);
ByteArrayOutputStream buff = new ByteArrayOutputStream();
template.process(map, new OutputStreamWriter(buff, Charset.forName(“UTF-8”)));
RawMap result = new RawMap(mapContent, buff, MIME_TYPE);

return result;

But, when looking at the response in Chrome I get a content type without charset information:
Content-Type:text/html; subtype=openlayers

The following resources ol3.js and ol.css are correctly served as
Content-Type:application/x-javascript; charset=UTF-8 and

Content-Type:text/css; charset=UTF-8

When looking at the response from the GetMap response and copying the content to a text editor I can see that the encoding of the document is “UTF-8 without BOM”.
If I serve the same file locally (through IIS as plain html) I get the same behavior but when saving the document as UTF-8 I get a working layer preview page.

Any ideas on how to get the RawMap result to render the charset=UTF-8 information to the browser?

Regards,
Olle Markljung