floatdrop / floatdrop/gleam_xml2map

`parse` crashes when text is unicode

Open Beginner friendly
#1 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Erlang
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

The following code crashes with `erlang:error(Badarg)`:
```gleam
let decoder =
decode.field("#text", decode.string, decode.success)
|> decode.field("unicode_test", _, decode.success)

assert Ok("β") == echo xml2map.parse("β", decoder)
```
I was able to patch it by using `unicode:characters_to_binary/1` instead of `list_to_binary/1` in `xml2map_ffi:value_to_bin/1`:
```diff
value_to_bin(Value) when is_list(Value) ->
- list_to_binary(Value);
+ unicode:characters_to_binary(Value);
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at xml2map_ffi:value_to_bin/1, where the issue identifies the failing conversion, and reproduce the provided unicode XML assertion through xml2map.parse. Done means the assertion returns Ok("β") without an Erlang badarg error; check the surrounding FFI behavior for regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
erlang
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.