UrlPercentEncodeLoneSurrogateTest
Issue: elm/url#54
`Url.percentEncode` returns a string for a string holding a lone surrogate.
The bug of <https://github.com/elm/url/issues/54>, with a program that follows A Standard Definition of Elm? The issue, and `UrlIssue54PercentEncodeLoneSurrogateTest` (tagged `elm19-bug`), write the
lone surrogate as the escape `"\u{d800}"`, which ruling A8 makes invalid: an escape must denote a
Unicode scalar value. <https://elm-test-suite.netlify.app/standard/restrictions/core-escape-unicode>
Here the lone surrogate is computed, `Char.fromCode 0xD800`, so the program is valid under A8, and
the string is the same. elm/url 1.0.0 calls `encodeURIComponent` unguarded, which throws `URIError:
URI malformed` for it. `percentEncode : String -> String` must return a string (`percentDecode`
already catches the same exception).Results
elm-0.19.1
failran in 55 msexit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:3944
return encodeURIComponent(string);
^
URIError: URI malformed
at encodeURIComponent (<anonymous>)
at _Url_percentEncode (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:3944:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4464:4
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4466:2
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.1/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4467:146)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
Node.js v22.23.5
elm-0.19.2
failran in 38 msexit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:3944
return encodeURIComponent(string);
^
URIError: URI malformed
at encodeURIComponent (<anonymous>)
at _Url_percentEncode (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:3944:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4464:4
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4466:2
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.2/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4467:146)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
Node.js v22.23.5
elm-0.19.3
failran in 42 msexit code 1, expected 0
--- output ---
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:3944
return encodeURIComponent(string);
^
URIError: URI malformed
at encodeURIComponent (<anonymous>)
at _Url_percentEncode (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:3944:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4464:4
at /home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4466:2
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/elm-0.19.3/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:4467:146)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
Node.js v22.23.5
lamdera-1.5.0
failran in 61 msexit code 1, expected 0
--- output ---
/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:5040
return encodeURIComponent(string);
^
URIError: URI malformed
at encodeURIComponent (<anonymous>)
at _Url_percentEncode (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:5040:9)
at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:5534:4
at /home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:5536:2
at Object.<anonymous> (/home/runner/work/elm-test-suite/elm-test-suite/.work/lamdera-1.5.0/elm-url/out/UrlPercentEncodeLoneSurrogateTest.js:5539:3)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
Node.js v22.23.5
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-url/UrlPercentEncodeLoneSurrogateTest] in its title.
Source
The -- CHECK: lines give the expected output.
module UrlPercentEncodeLoneSurrogateTest exposing (main)
{-| `Url.percentEncode` returns a string for a string holding a lone surrogate.
The bug of <https://github.com/elm/url/issues/54>, with a program that follows A Standard Definition of Elm? The issue, and `UrlIssue54PercentEncodeLoneSurrogateTest` (tagged `elm19-bug`), write the
lone surrogate as the escape `"\u{d800}"`, which ruling A8 makes invalid: an escape must denote a
Unicode scalar value. <https://elm-test-suite.netlify.app/standard/restrictions/core-escape-unicode>
Here the lone surrogate is computed, `Char.fromCode 0xD800`, so the program is valid under A8, and
the string is the same. elm/url 1.0.0 calls `encodeURIComponent` unguarded, which throws `URIError:
URI malformed` for it. `percentEncode : String -> String` must return a string (`percentDecode`
already catches the same exception).
-}
-- CHECK: encoded: True
import Html exposing (text)
import Url
main =
let
withLoneSurrogate =
"a" ++ String.fromChar (Char.fromCode 0xD800) ++ "b"
_ =
Debug.log "encoded" (String.length (Url.percentEncode withLoneSurrogate) > 0)
in
text "done"