jsonpath_encoding.out 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. --
  2. -- encoding-sensitive tests for jsonpath
  3. --
  4. SELECT getdatabaseencoding(); -- just to label the results files
  5. getdatabaseencoding
  6. ---------------------
  7. UTF8
  8. (1 row)
  9. -- checks for double-quoted values
  10. -- basic unicode input
  11. SELECT '"\u"'::jsonpath; -- ERROR, incomplete escape
  12. ERROR: invalid unicode sequence at or near "\u" of jsonpath input
  13. LINE 1: SELECT '"\u"'::jsonpath;
  14. ^
  15. SELECT '"\u00"'::jsonpath; -- ERROR, incomplete escape
  16. ERROR: invalid unicode sequence at or near "\u00" of jsonpath input
  17. LINE 1: SELECT '"\u00"'::jsonpath;
  18. ^
  19. SELECT '"\u000g"'::jsonpath; -- ERROR, g is not a hex digit
  20. ERROR: invalid unicode sequence at or near "\u000" of jsonpath input
  21. LINE 1: SELECT '"\u000g"'::jsonpath;
  22. ^
  23. SELECT '"\u0000"'::jsonpath; -- OK, legal escape
  24. ERROR: unsupported Unicode escape sequence
  25. LINE 1: SELECT '"\u0000"'::jsonpath;
  26. ^
  27. DETAIL: \u0000 cannot be converted to text.
  28. SELECT '"\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
  29. jsonpath
  30. ----------
  31. "ꯍ"
  32. (1 row)
  33. -- handling of unicode surrogate pairs
  34. select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
  35. correct_in_utf8
  36. -----------------
  37. "😄🐶"
  38. (1 row)
  39. select '"\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
  40. ERROR: invalid input syntax for type jsonpath
  41. LINE 1: select '"\ud83d\ud83d"'::jsonpath;
  42. ^
  43. DETAIL: Unicode high surrogate must not follow a high surrogate.
  44. select '"\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
  45. ERROR: invalid input syntax for type jsonpath
  46. LINE 1: select '"\ude04\ud83d"'::jsonpath;
  47. ^
  48. DETAIL: Unicode low surrogate must follow a high surrogate.
  49. select '"\ud83dX"'::jsonpath; -- orphan high surrogate
  50. ERROR: invalid input syntax for type jsonpath
  51. LINE 1: select '"\ud83dX"'::jsonpath;
  52. ^
  53. DETAIL: Unicode low surrogate must follow a high surrogate.
  54. select '"\ude04X"'::jsonpath; -- orphan low surrogate
  55. ERROR: invalid input syntax for type jsonpath
  56. LINE 1: select '"\ude04X"'::jsonpath;
  57. ^
  58. DETAIL: Unicode low surrogate must follow a high surrogate.
  59. --handling of simple unicode escapes
  60. select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
  61. correct_in_utf8
  62. ------------------------
  63. "the Copyright © sign"
  64. (1 row)
  65. select '"dollar \u0024 character"'::jsonpath as correct_everywhere;
  66. correct_everywhere
  67. ----------------------
  68. "dollar $ character"
  69. (1 row)
  70. select '"dollar \\u0024 character"'::jsonpath as not_an_escape;
  71. not_an_escape
  72. ----------------------------
  73. "dollar \\u0024 character"
  74. (1 row)
  75. select '"null \u0000 escape"'::jsonpath as not_unescaped;
  76. ERROR: unsupported Unicode escape sequence
  77. LINE 1: select '"null \u0000 escape"'::jsonpath as not_unescaped;
  78. ^
  79. DETAIL: \u0000 cannot be converted to text.
  80. select '"null \\u0000 escape"'::jsonpath as not_an_escape;
  81. not_an_escape
  82. -----------------------
  83. "null \\u0000 escape"
  84. (1 row)
  85. -- checks for quoted key names
  86. -- basic unicode input
  87. SELECT '$."\u"'::jsonpath; -- ERROR, incomplete escape
  88. ERROR: invalid unicode sequence at or near "\u" of jsonpath input
  89. LINE 1: SELECT '$."\u"'::jsonpath;
  90. ^
  91. SELECT '$."\u00"'::jsonpath; -- ERROR, incomplete escape
  92. ERROR: invalid unicode sequence at or near "\u00" of jsonpath input
  93. LINE 1: SELECT '$."\u00"'::jsonpath;
  94. ^
  95. SELECT '$."\u000g"'::jsonpath; -- ERROR, g is not a hex digit
  96. ERROR: invalid unicode sequence at or near "\u000" of jsonpath input
  97. LINE 1: SELECT '$."\u000g"'::jsonpath;
  98. ^
  99. SELECT '$."\u0000"'::jsonpath; -- OK, legal escape
  100. ERROR: unsupported Unicode escape sequence
  101. LINE 1: SELECT '$."\u0000"'::jsonpath;
  102. ^
  103. DETAIL: \u0000 cannot be converted to text.
  104. SELECT '$."\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
  105. jsonpath
  106. ----------
  107. $."ꯍ"
  108. (1 row)
  109. -- handling of unicode surrogate pairs
  110. select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
  111. correct_in_utf8
  112. -----------------
  113. $."😄🐶"
  114. (1 row)
  115. select '$."\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
  116. ERROR: invalid input syntax for type jsonpath
  117. LINE 1: select '$."\ud83d\ud83d"'::jsonpath;
  118. ^
  119. DETAIL: Unicode high surrogate must not follow a high surrogate.
  120. select '$."\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
  121. ERROR: invalid input syntax for type jsonpath
  122. LINE 1: select '$."\ude04\ud83d"'::jsonpath;
  123. ^
  124. DETAIL: Unicode low surrogate must follow a high surrogate.
  125. select '$."\ud83dX"'::jsonpath; -- orphan high surrogate
  126. ERROR: invalid input syntax for type jsonpath
  127. LINE 1: select '$."\ud83dX"'::jsonpath;
  128. ^
  129. DETAIL: Unicode low surrogate must follow a high surrogate.
  130. select '$."\ude04X"'::jsonpath; -- orphan low surrogate
  131. ERROR: invalid input syntax for type jsonpath
  132. LINE 1: select '$."\ude04X"'::jsonpath;
  133. ^
  134. DETAIL: Unicode low surrogate must follow a high surrogate.
  135. --handling of simple unicode escapes
  136. select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
  137. correct_in_utf8
  138. --------------------------
  139. $."the Copyright © sign"
  140. (1 row)
  141. select '$."dollar \u0024 character"'::jsonpath as correct_everywhere;
  142. correct_everywhere
  143. ------------------------
  144. $."dollar $ character"
  145. (1 row)
  146. select '$."dollar \\u0024 character"'::jsonpath as not_an_escape;
  147. not_an_escape
  148. ------------------------------
  149. $."dollar \\u0024 character"
  150. (1 row)
  151. select '$."null \u0000 escape"'::jsonpath as not_unescaped;
  152. ERROR: unsupported Unicode escape sequence
  153. LINE 1: select '$."null \u0000 escape"'::jsonpath as not_unescaped;
  154. ^
  155. DETAIL: \u0000 cannot be converted to text.
  156. select '$."null \\u0000 escape"'::jsonpath as not_an_escape;
  157. not_an_escape
  158. -------------------------
  159. $."null \\u0000 escape"
  160. (1 row)