Description
Is your change request related to a problem? Please describe.
We ran into a crashing bug in our production front-end where using print
from URI.Extra.QueryPairs
would result in an error which we traced down to fromJust
against encodeURIComponent
's result.
Examples:
Both keyToString
and valueToString
in URI.Extra.QueryPairs
will error if their usage of encodeURIComponent
results in a Nothing. This can happen if unprintable characters. For example a
Dooli\U001001a9leinside of a string given to
encodeURIComponentresults in
Nothing`.
I'm not sure exactly what in the string is causing encodeURIComponent
to return a Nothing
there.
Describe the solution you'd like
Broadly it'd be nice if usages of fromJust
here were eliminated entirely. The Maybe
ness of the entire API could be represented in its external interface.
Alternatively the API could be split into safe and unsafe versions. This is a little tricky since there's already some "unsafe" functions here which are labeled and documented as such for different kinds of safety reasons.
I'm happy to work on a PR but would wanted to get some insight into the appetite for the various solutions to this.
Additional context
In the meantime we're going to mitigate this issue on our end locally by testing our input to the problematic functions against encodeURIComponent
first - and possibly by additional input filtering elsewhere in our app.