From 8bcc2aabca29bdb3d8ff3a7c4161e43acae21ecc Mon Sep 17 00:00:00 2001 From: onox Date: Sun, 18 Aug 2019 17:45:10 +0200 Subject: [PATCH] RFC requires subset of control characters to be escaped Section 7 of the RFC only requires bytes 00 (NUL) to 1F (US) to be escaped. Signed-off-by: onox --- src/json-tokenizers.adb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json-tokenizers.adb b/src/json-tokenizers.adb index 3ae8c8d..43a92e5 100644 --- a/src/json-tokenizers.adb +++ b/src/json-tokenizers.adb @@ -12,7 +12,6 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -with Ada.Characters.Handling; with Ada.Characters.Latin_1; with Ada.IO_Exceptions; with Ada.Strings.Bounded; @@ -28,6 +27,7 @@ package body JSON.Tokenizers is Escaped : Boolean := False; use type Streams.AS.Stream_Element_Offset; + use Ada.Characters.Latin_1; begin loop C := Stream.Read_Character (Index); @@ -49,7 +49,7 @@ package body JSON.Tokenizers is end case; elsif C /= '\' then -- Check C is not a control character - if Ada.Characters.Handling.Is_Control (C) then + if C in NUL .. US then raise Tokenizer_Error with "Unexpected control character in string"; end if; end if;