[
https://issues.apache.org/jira/browse/SLING-11538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17578976#comment-17578976
]
Konrad Windszus commented on SLING-11538:
-----------------------------------------
The JSON spec
([https://www.ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf])
says the following for chapter 9 (String):
{quote}A string is a sequence of Unicode code points wrapped with quotation
marks (U+0022). All code points may
be placed within the quotation marks except for the code points that must be
escaped: quotation mark
(U+0022), reverse solidus (U+005C), and the control characters U+0000 to
U+001F. There are two-character
escape sequence representations of some characters.
\" represents the quotation mark character (U+0022).
represents the reverse solidus character (U+005C).
\/ represents the solidus character (U+002F).
\b represents the backspace character (U+0008).
\f represents the form feed character (U+000C).
\n represents the line feed character (U+000A).
\r represents the carriage return character (U+000D).
\t represents the character tabulation character (U+0009).
So, for example, a string containing only a single reverse solidus character
may be represented as "
".
Any code point may be represented as a hexadecimal escape sequence. The meaning
of such a hexadecimal
number is determined by ISO/IEC 10646. If the code point is in the Basic
Multilingual Plane (U+0000 through
U+FFFF), then it may be represented as a six-character sequence: a reverse
solidus, followed by the
lowercase letter u, followed by four hexadecimal digits that encode the code
point. Hexadecimal digits can be
© Ecma International 2017 5
digits (U+0030 through U+0039) or the hexadecimal letters A through F in
uppercase (U+0041 through
U+0046) or lowercase (U+0061 through U+0066). So, for example, a string
containing only a single reverse
solidus character may be represented as "\u005C".
The following four cases all produce the same result:
"\u002F"
"\u002f"
"\/"
"/"
To escape a code point that is not in the Basic Multilingual Plane, the
character may be represented as a
twelve-character sequence, encoding the UTF-16 surrogate pair corresponding to
the code point. So for
example, a string containing only the G clef character (U+1D11E) may be
represented as "\uD834\uDD1E".
However, whether a processor of JSON texts interprets such a surrogate pair as
a single code point or as an
explicit surrogate pair is a semantic decision that is determined by the
specific processor.
Note that the JSON grammar permits code points for which Unicode does not
currently provide character
assignments.
{quote}
> Add display context for JSON string
> -----------------------------------
>
> Key: SLING-11538
> URL: https://issues.apache.org/jira/browse/SLING-11538
> Project: Sling
> Issue Type: Improvement
> Components: HTL
> Reporter: Konrad Windszus
> Priority: Major
> Fix For: Scripting HTL Runtime 1.2.8-1.4.0
>
>
> It would be useful to add an output context to HTL to be used inside JSON. As
> JSON is very complex, the most essential one which currently cannot be
> achieved with any other existing contexts is escaping for a JSON String value
> (compare with https://github.com/adobe/htl-spec/issues/5).
> I propose to introduce a new context {{jsonString}} next to {{scriptString}}
> in
> https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/192d953514e6e579428cda157a7e83fc2a05cc01/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/XSSRuntimeExtension.java#L93.
> As it is not part of the official HTL spec at
> https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#121-display-context
> it needs to be listed as Sling-specific addition in
> https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html#extensions-of-the-htl-specification.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)