Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118525 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46675 invoked from network); 26 Aug 2022 23:41:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Aug 2022 23:41:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6E8661804D0 for ; Fri, 26 Aug 2022 16:41:17 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 26 Aug 2022 16:41:16 -0700 (PDT) Received: by mail-vs1-f48.google.com with SMTP id h67so3057358vsc.11 for ; Fri, 26 Aug 2022 16:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=oc9bL5yh+2V+rmmRJRuoKY3/jHuHy6Jhrx2E9aH8Cp8=; b=ZAR7EU2jJZZQ1QNhms4ecILqKVHPMIHIGN4P8xyHS3rYiAT73na0gEprjq4vFOKY6l JTyquKXhi5IP0vX1D0uZMPjgh/Bic9xDirZ0XCG1vIswqAx8VlsmstXvsHs2fXcOTgYl BDKt5mBKOlWzlj88ew2y51AS7QJl8HAulZHGTGIk8+6yPbXJ9zKEhDA+5P/OkE4jrAry pIYjT9WQMib/vV0U7pFzr+GcRcr5i4Zc3UC+j1dXqJ74vtRDLEb9PLnfaWOufRXSOGVB ivKc2lL5/d2JwSAtMsGSlLpJe2JjXdgrMj5xGJr3DoRNszFMEyOJqLpot86aM+VSmqeE hfyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=oc9bL5yh+2V+rmmRJRuoKY3/jHuHy6Jhrx2E9aH8Cp8=; b=1wrO0WWG/ogJKnagZIC/OBMJobm6bjbBHTrlXI49amDRybYRTpCQfw0KBqhKnjWVPX M57eM1jmPhxqywSEdji2BMffvOW/g1Wc9G/hNHndIBKDLHjnMo9YmZR4MWroVXuw/75v fJxrTOlJ43yKb8a36/P/PRpDPmLx6BtuSrW9sFvAfFWAVVn1mmwcqC0wLqHLyLrAw4d3 pvdEkC8ba2b/HC/taO7MU5Io+jkUN5rLTecZL2XL+PXCMfsLWj+O5VRyq5eQY7ToxXpE Zz3DWV11jMW95903cLVcsk5hLfZpuIYuGihtJomplJ2m/TTfrrMNDZSCLtVz/j++UuKb n30w== X-Gm-Message-State: ACgBeo2gNGN/8kApTiVf8zB1pGdo1ZopuWKr8fJt7GX5DfXLZFGUTIVP Bg3GhFV+XE3F9SsTj0ubK6QevJqfnKXMuqXfuAzLgj8K6W0= X-Google-Smtp-Source: AA6agR50mdSJ7ot6aHGdcAdTxuI3TGzrEs15hetdU+mnk1f0PHDnV6lpqxFuwkZaVeKPGciFx0Q09D2O7oV9cdkDE1w= X-Received: by 2002:a05:6102:3f55:b0:390:c753:3565 with SMTP id l21-20020a0561023f5500b00390c7533565mr27200vsv.13.1661557276007; Fri, 26 Aug 2022 16:41:16 -0700 (PDT) MIME-Version: 1.0 References: <8D53AD5B-7CFC-4820-9EE4-FEB365D327A8@woofle.net> In-Reply-To: Date: Sat, 27 Aug 2022 01:41:05 +0200 Message-ID: To: PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC json_validate() - status: Under Discussion From: dev.juan.morales@gmail.com (juan carlos morales) El s=C3=A1b, 27 ago 2022 a las 1:31, juan carlos morales () escribi=C3=B3: > > =3D=3D=3D Open issues/concerns =3D=3D=3D > > > @@@ Usage of JSON_INVALID_UTF8_IGNORE @@@ > > - I have my doubts now, because of this codes: > > ``` > > var_dump(json_validate("\"a\xb0b\""), json_last_error_msg()); > var_dump("------------"); > var_dump(json_validate("\"a\xb0b\"", 512, JSON_INVALID_UTF8_IGNORE), > json_last_error_msg()); > ``` > > Results: > > bool(false) > string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" > string(12) "------------" > bool(true) > string(8) "No error" > > > Gives different results, but ... > > ``` > > var_dump(json_decode("{ \"a\xb0b\" : \"dummy\" }"), json_last_error_msg()= ); > var_dump("------------"); > var_dump(json_decode("{ \"a\xb0b\" : \"dummy\" }", 512, > JSON_INVALID_UTF8_IGNORE), json_last_error_msg()); > ``` > > Results in: > NULL > string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" > string(12) "------------" > NULL > string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" > > > > So at a first look, seems the flag should also be remove, as with > json_validate() we say its valid, but then on json_decode() we get > NULL, even with the JSON_INVALID_UTF8_IGNORE provided; does not make > sense I believe. > > What do you think? Is there a use case I am missing here? Is this flag > worth to have still? > I made a huge mistake sorry, long day here, 1:30 am , the code for json_decode should be as: var_dump(json_decode("{ \"a\xb0b\" : \"dummy\" }"), true, 512, json_last_error_msg()); var_dump("------------"); var_dump(json_decode("{ \"a\xb0b\" : \"dummy\" }", true, 512, JSON_INVALID_UTF8_IGNORE), json_last_error_msg()); Resulting in NULL bool(true) int(512) string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" string(12)"------------" array(1) { ["ab"]=3D> string(5) "dummy" } string(8) "No error" Saying so, now ... yes I support the usage of the JSON_INVALID_UTF8_IGNORE , as json_validate() result goes in the same direction with json_decode(). I think we need to have this flag. RFC: https://wiki.php.net/rfc/json_validate Implementation: https://github.com/php/php-src/pull/9399