Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
JCR Resource 2.0.6
-
None
Description
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)