[MDEV-11909] Must reject numbers in incorrect floating point format Created: 2017-01-25  Updated: 2022-06-01

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: Andrii Nikitin (Inactive) Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None


 Description   

These incorrect values shouldn't be accepted by st_geomfromjson :

select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,-.e]}'));
select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,-.0]}'));
select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,5eeeeee10eee]}'));
select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,5e]}'));

current output:

MariaDB [test]> select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,-.e]}'));
+---------------------------------------------------------------------------+
| st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,-.e]}')) |
+---------------------------------------------------------------------------+
| POINT(1 0)                                                                |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,-.0]}'));
+---------------------------------------------------------------------------+
| st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,-.0]}')) |
+---------------------------------------------------------------------------+
| POINT(1 0)                                                                |
+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,5eeeeee10eee]}'));
+------------------------------------------------------------------------------------+
| st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,5eeeeee10eee]}')) |
+------------------------------------------------------------------------------------+
| POINT(1 5)                                                                         |
+------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,5e]}'));
+--------------------------------------------------------------------------+
| st_astext(st_geomfromgeojson('{"type": "Point","coordinates": [1,5e]}')) |
+--------------------------------------------------------------------------+
| POINT(1 5)                                                               |
+--------------------------------------------------------------------------+
1 row in set (0.00 sec)



 Comments   
Comment by Andrii Nikitin (Inactive) [ 2017-01-25 ]

These formats are incorrect according to rfc7159 https://tools.ietf.org/html/rfc7159

json_valid() has problem only with the last value - let me know if I should create another ticket for it or it will be fixed as part of this:

MariaDB [test]> select json_valid('{"a": -.e}');
+--------------------------+
| json_valid('{"a": -.e}') |
+--------------------------+
|                        0 |
+--------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select json_valid('{"a": -.0}');
+--------------------------+
| json_valid('{"a": -.0}') |
+--------------------------+
|                        0 |
+--------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select json_valid('{"a": 5ee10e}');
+-----------------------------+
| json_valid('{"a": 5ee10e}') |
+-----------------------------+
|                           0 |
+-----------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select json_valid('{"a": 5e}');
+-------------------------+
| json_valid('{"a": 5e}') |
+-------------------------+
|                       1 |
+-------------------------+
1 row in set (0.00 sec)

Generated at Thu Feb 08 07:53:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.