diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-05-22 18:42:12 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-05-31 16:04:05 +0200 |
commit | 5891c388bbdd48ba0440d2738155f364589a432a (patch) | |
tree | f2d4a1c7de646d6caf312761e4fc8a0834ab288d /tests/test-qobject-input-visitor.c | |
parent | 0748b3526e8cb78b9cd64208426bfc3d54a72b04 (diff) |
qobject-input-visitor: Reject non-finite numbers with keyval
The QObject input visitor can produce only finite numbers when its
input comes out of the JSON parser, because the the JSON parser
implements RFC 7159, which provides no syntax for infinity and NaN.
However, it can produce infinity and NaN when its input comes out of
keyval_parse(), because we parse with strtod() then.
The keyval variant should not be able to express things the JSON
variant can't. Rejecting non-finite numbers there is the conservative
fix. It's also minimally invasive.
We could instead extend our JSON dialect to provide for infinity and
NaN. Not today.
Note that the JSON formatter can emit non-finite numbers (marked FIXME
in commit 6e8e5cb).
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1495471335-23707-2-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'tests/test-qobject-input-visitor.c')
-rw-r--r-- | tests/test-qobject-input-visitor.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index f965743b6e..e2aabbe972 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -278,11 +278,17 @@ static void test_visitor_in_number_str_keyval(TestInputVisitorData *data, { double res = 0, value = 3.14; Visitor *v; + Error *err = NULL; v = visitor_input_test_init_full(data, true, "\"3.14\""); visit_type_number(v, NULL, &res, &error_abort); g_assert_cmpfloat(res, ==, value); + + v = visitor_input_test_init_full(data, true, "\"inf\""); + + visit_type_number(v, NULL, &res, &err); + error_free_or_abort(&err); } static void test_visitor_in_number_str_fail(TestInputVisitorData *data, |