jsonpath_encoding.sql 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --
  2. -- encoding-sensitive tests for jsonpath
  3. --
  4. SELECT getdatabaseencoding(); -- just to label the results files
  5. -- checks for double-quoted values
  6. -- basic unicode input
  7. SELECT '"\u"'::jsonpath; -- ERROR, incomplete escape
  8. SELECT '"\u00"'::jsonpath; -- ERROR, incomplete escape
  9. SELECT '"\u000g"'::jsonpath; -- ERROR, g is not a hex digit
  10. SELECT '"\u0000"'::jsonpath; -- OK, legal escape
  11. SELECT '"\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
  12. -- handling of unicode surrogate pairs
  13. select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
  14. select '"\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
  15. select '"\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
  16. select '"\ud83dX"'::jsonpath; -- orphan high surrogate
  17. select '"\ude04X"'::jsonpath; -- orphan low surrogate
  18. --handling of simple unicode escapes
  19. select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
  20. select '"dollar \u0024 character"'::jsonpath as correct_everywhere;
  21. select '"dollar \\u0024 character"'::jsonpath as not_an_escape;
  22. select '"null \u0000 escape"'::jsonpath as not_unescaped;
  23. select '"null \\u0000 escape"'::jsonpath as not_an_escape;
  24. -- checks for quoted key names
  25. -- basic unicode input
  26. SELECT '$."\u"'::jsonpath; -- ERROR, incomplete escape
  27. SELECT '$."\u00"'::jsonpath; -- ERROR, incomplete escape
  28. SELECT '$."\u000g"'::jsonpath; -- ERROR, g is not a hex digit
  29. SELECT '$."\u0000"'::jsonpath; -- OK, legal escape
  30. SELECT '$."\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
  31. -- handling of unicode surrogate pairs
  32. select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
  33. select '$."\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
  34. select '$."\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
  35. select '$."\ud83dX"'::jsonpath; -- orphan high surrogate
  36. select '$."\ude04X"'::jsonpath; -- orphan low surrogate
  37. --handling of simple unicode escapes
  38. select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
  39. select '$."dollar \u0024 character"'::jsonpath as correct_everywhere;
  40. select '$."dollar \\u0024 character"'::jsonpath as not_an_escape;
  41. select '$."null \u0000 escape"'::jsonpath as not_unescaped;
  42. select '$."null \\u0000 escape"'::jsonpath as not_an_escape;