[ https://issues.apache.org/jira/browse/SLING-1761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Sedding updated SLING-1761: ---------------------------------- Attachment: SLING-1761.patch A patch for the content-length issue, which also sets content type to "text/plain" and character encoding to "UTF-8" for non-binary properties. I am not 100% certain that it is correct to set all of these in the ResourceMetadata, as the issue I observed was with the StreamRendererServlet. So I would be grateful if you could carefully review the patch before applying. > JcrPropertyResource sets incorrect content length for strings containing > non-ascii character > -------------------------------------------------------------------------------------------- > > Key: SLING-1761 > URL: https://issues.apache.org/jira/browse/SLING-1761 > Project: Sling > Issue Type: Bug > Components: JCR > Affects Versions: JCR Resource 2.0.6 > Reporter: Julian Sedding > Attachments: SLING-1761-tests.patch, SLING-1761.patch > > > JcrPropertyResource sets the content length of the property in its metadata. > To do so, it uses javax.jcr.Property#getLength() to determine the content > length. > The documentation for javax.jcr.Property#getLength() states "[...] Returns > the length in bytes if the value is a PropertyType.BINARY, otherwise it > returns the number of characters needed to display the value in its string > form. [...]". > The documentation in ResourceMetadata is not explicit, but from its usage in > StreamRendererServlet I conclude that ResourceMetadata.getContentLength() is > intended for use in the Content-Length HTTP header. If my assumptions are > correct, the content length indicates the number of bytes in the string, > while javax.jcr.Property#getLength() returns the number of characters. > The effect of this can be observed by the following steps: > * create a string property "/utf8string" with value "Bär" > * access this property using a browser (e.g. > http://localhost:8888/utf8string), so that the property gets rendered by the > StreamRendererServlet > => the string is rendered incorrectly (due to a missing Content-Type header) > => the string is cut off (due to the incorrectly set Content-Length header) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.