Merge pull request #151 from aeternity/fix_numeric_escapes
Fix numeric escapes in strings
This commit is contained in:
commit
a730fcc366
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
|
- Handle numeric escapes, i.e. `"\x19Ethereum Signed Message:\n"`, and similar strings.
|
||||||
### Changed
|
### Changed
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -95,9 +95,11 @@ parse_char([$', C, $']) -> C.
|
|||||||
|
|
||||||
unescape(Str) -> unescape(Str, []).
|
unescape(Str) -> unescape(Str, []).
|
||||||
|
|
||||||
%% TODO: numeric escapes
|
|
||||||
unescape([$"], Acc) ->
|
unescape([$"], Acc) ->
|
||||||
list_to_binary(lists:reverse(Acc));
|
list_to_binary(lists:reverse(Acc));
|
||||||
|
unescape([$\\, $x, D1, D2 | Chars ], Acc) ->
|
||||||
|
C = list_to_integer([D1, D2], 16),
|
||||||
|
unescape(Chars, [C | Acc]);
|
||||||
unescape([$\\, Code | Chars], Acc) ->
|
unescape([$\\, Code | Chars], Acc) ->
|
||||||
Ok = fun(C) -> unescape(Chars, [C | Acc]) end,
|
Ok = fun(C) -> unescape(Chars, [C | Acc]) end,
|
||||||
case Code of
|
case Code of
|
||||||
|
@ -15,3 +15,5 @@ contract BasicAuth =
|
|||||||
entrypoint to_sign(h : hash, n : int) =
|
entrypoint to_sign(h : hash, n : int) =
|
||||||
Crypto.blake2b((h, n))
|
Crypto.blake2b((h, n))
|
||||||
|
|
||||||
|
entrypoint weird_string() : string =
|
||||||
|
"\x19Weird String\x42\nMore\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user