You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an issue because of the sexagesimal support in Yams. When you work with scalars, you can expect the Int initializer to return nil in the following scenarios:
Int("a") // return nil
Int("a:b") // returns nil
But YAMLDecoder has support for "sexagesimal" numbers (which was dropped from the YAML spec in 2009). If you use singleValueContainer and try to decode Int using YAMLDecoder, like this:
It hits the scalar.contains(":") condition and at this point, the parser is convinced it is a number and never bails out, even if it's not a proper sexagesimal number. So the Int.self decoding produces the following result:
It breaks certain assumptions that are true for JSONDecoder. I'm not sure if I did a great job describing the issue, but I suggest revising support of pre YAML 1.2 features.
The text was updated successfully, but these errors were encountered:
In version 1.1[17] of the YAML data storage format, sexagesimals are supported for plain scalars, and formally specified both for integers[18] and floating point numbers.[19] This has led to confusion, as e.g. some MAC addresses would be recognised as sexagesimals and loaded as integers, where others were not and loaded as strings. In YAML 1.2 support for sexagesimals was dropped.[20]
That's basically exactly the issue I'm encountering. But I think it's a bit worse in Yams because it thinks that anything with ":" is an integer, e.g. "https://example.com/webhook" is an integer.
Hi,
I've encountered an issue because of the sexagesimal support in Yams. When you work with scalars, you can expect the
Int
initializer to returnnil
in the following scenarios:But
YAMLDecoder
has support for "sexagesimal" numbers (which was dropped from the YAML spec in 2009). If you usesingleValueContainer
and try to decodeInt
usingYAMLDecoder
, like this:It hits the
scalar.contains(":")
condition and at this point, the parser is convinced it is a number and never bails out, even if it's not a proper sexagesimal number. So theInt.self
decoding produces the following result:It breaks certain assumptions that are true for
JSONDecoder
. I'm not sure if I did a great job describing the issue, but I suggest revising support of pre YAML 1.2 features.The text was updated successfully, but these errors were encountered: