-
Notifications
You must be signed in to change notification settings - Fork 11
Description
CreateParser.create takes a file path, but no option for an encoding, and so (I guess) uses the system default encoding. When the file has non-ASCII characters, as the current version does:
https://github.com/snowplow-referer-parser/referer-parser/blob/0a59810d7379ff731ccfcdeabea151e4e8b31c59/resources/referers.yml#L638
it can therefore behave inconsistently on different systems.
Library version:
1.0.0
Expected behavior:
I should be able to get the same referers.json
file to work on different systems
Actual behavior:
If I use a UTF-8 encoded file on a system with a different default encoding, I get a MalformedInputException
Steps to reproduce:
Please try to be as detailed as possible so that we can reproduce and fix the issue
as quickly as possible.
- Convert the current referers.yml file to json and save it as UTF-8
- Pass this file path to CreateParser[IO].create on a system with a different default encoding
- Results in
java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.read1(BufferedReader.java:210)
at java.io.BufferedReader.read(BufferedReader.java:286)
at java.io.Reader.read(Reader.java:140)
at scala.io.BufferedSource.mkString(BufferedSource.scala:96)
at com.snowplowanalytics.refererparser.CreateParser$$anon$3.create(Parser.scala:52)
at com.snowplowanalytics.refererparser.CreateParser$$anon$3.create(Parser.scala:50)