@fails-components/webtransport 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +1 -3
- package/src/http3eventloop.cc +83 -9
- package/src/http3eventloop.h +13 -3
- package/src/http3server.cc +22 -22
- package/src/http3server.h +7 -20
- package/src/http3wtstreamvisitor.cc +31 -10
- package/src/http3wtstreamvisitor.h +38 -11
- package/src/webtransport.js +91 -23
- package/test/echoserver.js +29 -5
- package/test/testsuite.js +242 -220
- package/third_party/boringssl/src/CMakeLists.txt +2 -0
- package/third_party/boringssl/src/crypto/CMakeLists.txt +1 -0
- package/third_party/boringssl/src/crypto/asn1/a_bitstr.c +174 -177
- package/third_party/boringssl/src/crypto/asn1/a_bool.c +46 -48
- package/third_party/boringssl/src/crypto/asn1/a_d2i_fp.c +21 -23
- package/third_party/boringssl/src/crypto/asn1/a_dup.c +21 -23
- package/third_party/boringssl/src/crypto/asn1/a_gentm.c +84 -187
- package/third_party/boringssl/src/crypto/asn1/a_i2d_fp.c +19 -21
- package/third_party/boringssl/src/crypto/asn1/a_int.c +305 -329
- package/third_party/boringssl/src/crypto/asn1/a_mbstr.c +190 -195
- package/third_party/boringssl/src/crypto/asn1/a_object.c +182 -189
- package/third_party/boringssl/src/crypto/asn1/a_octet.c +6 -9
- package/third_party/boringssl/src/crypto/asn1/a_print.c +15 -16
- package/third_party/boringssl/src/crypto/asn1/a_strex.c +386 -399
- package/third_party/boringssl/src/crypto/asn1/a_strnid.c +110 -131
- package/third_party/boringssl/src/crypto/asn1/a_time.c +118 -111
- package/third_party/boringssl/src/crypto/asn1/a_type.c +59 -60
- package/third_party/boringssl/src/crypto/asn1/a_utctm.c +114 -186
- package/third_party/boringssl/src/crypto/asn1/a_utf8.c +171 -159
- package/third_party/boringssl/src/crypto/asn1/asn1_lib.c +245 -260
- package/third_party/boringssl/src/crypto/asn1/asn1_par.c +41 -40
- package/third_party/boringssl/src/crypto/asn1/asn1_test.cc +31 -0
- package/third_party/boringssl/src/crypto/asn1/asn_pack.c +31 -33
- package/third_party/boringssl/src/crypto/asn1/f_int.c +36 -33
- package/third_party/boringssl/src/crypto/asn1/f_string.c +29 -26
- package/third_party/boringssl/src/crypto/asn1/internal.h +62 -61
- package/third_party/boringssl/src/crypto/asn1/tasn_dec.c +706 -702
- package/third_party/boringssl/src/crypto/asn1/tasn_enc.c +507 -524
- package/third_party/boringssl/src/crypto/asn1/tasn_fre.c +141 -133
- package/third_party/boringssl/src/crypto/asn1/tasn_new.c +207 -199
- package/third_party/boringssl/src/crypto/asn1/tasn_typ.c +19 -22
- package/third_party/boringssl/src/crypto/asn1/tasn_utl.c +24 -24
- package/third_party/boringssl/src/crypto/asn1/time_support.c +13 -13
- package/third_party/boringssl/src/crypto/bio/connect.c +9 -3
- package/third_party/boringssl/src/crypto/bytestring/bytestring_test.cc +125 -1
- package/third_party/boringssl/src/crypto/bytestring/cbb.c +4 -7
- package/third_party/boringssl/src/crypto/bytestring/cbs.c +167 -9
- package/third_party/boringssl/src/crypto/cipher_extra/e_aesctrhmac.c +0 -2
- package/third_party/boringssl/src/crypto/cipher_extra/e_aesgcmsiv.c +23 -54
- package/third_party/boringssl/src/crypto/cipher_extra/e_chacha20poly1305.c +0 -2
- package/third_party/boringssl/src/crypto/cipher_extra/e_tls.c +0 -2
- package/third_party/boringssl/src/crypto/curve25519/curve25519.c +6 -8
- package/third_party/boringssl/src/crypto/evp/evp_ctx.c +25 -22
- package/third_party/boringssl/src/crypto/evp/internal.h +15 -9
- package/third_party/boringssl/src/crypto/evp/p_dsa_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_ec_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_ed25519.c +3 -3
- package/third_party/boringssl/src/crypto/evp/p_ed25519_asn1.c +10 -7
- package/third_party/boringssl/src/crypto/evp/p_hkdf.c +241 -0
- package/third_party/boringssl/src/crypto/evp/p_rsa_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_x25519_asn1.c +1 -0
- package/third_party/boringssl/src/crypto/fipsmodule/aes/aes_nohw.c +9 -10
- package/third_party/boringssl/src/crypto/fipsmodule/aes/key_wrap.c +2 -6
- package/third_party/boringssl/src/crypto/fipsmodule/bn/exponentiation.c +5 -11
- package/third_party/boringssl/src/crypto/fipsmodule/bn/internal.h +1 -1
- package/third_party/boringssl/src/crypto/fipsmodule/bn/prime.c +2 -0
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aes.c +10 -26
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aesccm.c +2 -3
- package/third_party/boringssl/src/crypto/fipsmodule/digestsign/digestsign.c +1 -0
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p256-nistz.c +44 -43
- package/third_party/boringssl/src/crypto/fipsmodule/modes/cbc.c +5 -9
- package/third_party/boringssl/src/crypto/fipsmodule/modes/gcm.c +14 -21
- package/third_party/boringssl/src/crypto/fipsmodule/rand/ctrdrbg.c +8 -8
- package/third_party/boringssl/src/crypto/fipsmodule/rand/internal.h +1 -4
- package/third_party/boringssl/src/crypto/hkdf/hkdf_test.cc +104 -0
- package/third_party/boringssl/src/crypto/internal.h +18 -4
- package/third_party/boringssl/src/crypto/lhash/internal.h +13 -1
- package/third_party/boringssl/src/crypto/obj/obj_dat.h +4 -1
- package/third_party/boringssl/src/crypto/obj/obj_mac.num +1 -0
- package/third_party/boringssl/src/crypto/obj/objects.txt +2 -0
- package/third_party/boringssl/src/crypto/pem/pem_all.c +77 -86
- package/third_party/boringssl/src/crypto/pem/pem_info.c +221 -233
- package/third_party/boringssl/src/crypto/pem/pem_lib.c +639 -608
- package/third_party/boringssl/src/crypto/pem/pem_oth.c +17 -16
- package/third_party/boringssl/src/crypto/pem/pem_pk8.c +133 -142
- package/third_party/boringssl/src/crypto/pem/pem_pkey.c +96 -92
- package/third_party/boringssl/src/crypto/poly1305/poly1305_vec.c +12 -28
- package/third_party/boringssl/src/crypto/siphash/siphash.c +8 -11
- package/third_party/boringssl/src/crypto/siphash/siphash_test.cc +5 -7
- package/third_party/boringssl/src/crypto/stack/stack.c +33 -16
- package/third_party/boringssl/src/crypto/thread_pthread.c +0 -2
- package/third_party/boringssl/src/crypto/thread_win.c +0 -2
- package/third_party/boringssl/src/crypto/trust_token/internal.h +14 -0
- package/third_party/boringssl/src/crypto/trust_token/pmbtoken.c +127 -30
- package/third_party/boringssl/src/crypto/trust_token/trust_token.c +40 -0
- package/third_party/boringssl/src/crypto/trust_token/trust_token_test.cc +165 -0
- package/third_party/boringssl/src/crypto/trust_token/voprf.c +55 -6
- package/third_party/boringssl/src/crypto/x509/a_digest.c +23 -24
- package/third_party/boringssl/src/crypto/x509/a_sign.c +52 -55
- package/third_party/boringssl/src/crypto/x509/a_verify.c +33 -34
- package/third_party/boringssl/src/crypto/x509/algorithm.c +17 -18
- package/third_party/boringssl/src/crypto/x509/asn1_gen.c +618 -612
- package/third_party/boringssl/src/crypto/x509/by_dir.c +320 -337
- package/third_party/boringssl/src/crypto/x509/by_file.c +186 -186
- package/third_party/boringssl/src/crypto/x509/i2d_pr.c +11 -14
- package/third_party/boringssl/src/crypto/x509/internal.h +22 -22
- package/third_party/boringssl/src/crypto/x509/name_print.c +155 -150
- package/third_party/boringssl/src/crypto/x509/rsa_pss.c +27 -29
- package/third_party/boringssl/src/crypto/x509/t_crl.c +67 -70
- package/third_party/boringssl/src/crypto/x509/t_req.c +3 -5
- package/third_party/boringssl/src/crypto/x509/t_x509.c +280 -251
- package/third_party/boringssl/src/crypto/x509/t_x509a.c +52 -47
- package/third_party/boringssl/src/crypto/x509/x509.c +3 -4
- package/third_party/boringssl/src/crypto/x509/x509_att.c +234 -223
- package/third_party/boringssl/src/crypto/x509/x509_cmp.c +286 -296
- package/third_party/boringssl/src/crypto/x509/x509_d2.c +37 -32
- package/third_party/boringssl/src/crypto/x509/x509_def.c +14 -30
- package/third_party/boringssl/src/crypto/x509/x509_ext.c +55 -84
- package/third_party/boringssl/src/crypto/x509/x509_lu.c +545 -581
- package/third_party/boringssl/src/crypto/x509/x509_obj.c +131 -121
- package/third_party/boringssl/src/crypto/x509/x509_req.c +120 -139
- package/third_party/boringssl/src/crypto/x509/x509_set.c +128 -142
- package/third_party/boringssl/src/crypto/x509/x509_trs.c +185 -193
- package/third_party/boringssl/src/crypto/x509/x509_txt.c +70 -72
- package/third_party/boringssl/src/crypto/x509/x509_v3.c +172 -161
- package/third_party/boringssl/src/crypto/x509/x509_vfy.c +2041 -2053
- package/third_party/boringssl/src/crypto/x509/x509_vpm.c +441 -461
- package/third_party/boringssl/src/crypto/x509/x509cset.c +152 -170
- package/third_party/boringssl/src/crypto/x509/x509name.c +274 -260
- package/third_party/boringssl/src/crypto/x509/x509rset.c +43 -20
- package/third_party/boringssl/src/crypto/x509/x509spki.c +62 -63
- package/third_party/boringssl/src/crypto/x509/x_algor.c +64 -62
- package/third_party/boringssl/src/crypto/x509/x_all.c +103 -133
- package/third_party/boringssl/src/crypto/x509/x_attrib.c +23 -24
- package/third_party/boringssl/src/crypto/x509/x_crl.c +310 -321
- package/third_party/boringssl/src/crypto/x509/x_exten.c +6 -5
- package/third_party/boringssl/src/crypto/x509/x_info.c +31 -28
- package/third_party/boringssl/src/crypto/x509/x_name.c +361 -365
- package/third_party/boringssl/src/crypto/x509/x_pkey.c +38 -32
- package/third_party/boringssl/src/crypto/x509/x_pubkey.c +114 -117
- package/third_party/boringssl/src/crypto/x509/x_req.c +27 -29
- package/third_party/boringssl/src/crypto/x509/x_sig.c +2 -2
- package/third_party/boringssl/src/crypto/x509/x_spki.c +8 -10
- package/third_party/boringssl/src/crypto/x509/x_val.c +2 -2
- package/third_party/boringssl/src/crypto/x509/x_x509.c +212 -226
- package/third_party/boringssl/src/crypto/x509/x_x509a.c +112 -109
- package/third_party/boringssl/src/crypto/x509v3/ext_dat.h +10 -13
- package/third_party/boringssl/src/crypto/x509v3/internal.h +72 -87
- package/third_party/boringssl/src/crypto/x509v3/pcy_cache.c +184 -176
- package/third_party/boringssl/src/crypto/x509v3/pcy_data.c +58 -56
- package/third_party/boringssl/src/crypto/x509v3/pcy_lib.c +71 -70
- package/third_party/boringssl/src/crypto/x509v3/pcy_map.c +56 -58
- package/third_party/boringssl/src/crypto/x509v3/pcy_node.c +89 -91
- package/third_party/boringssl/src/crypto/x509v3/pcy_tree.c +585 -590
- package/third_party/boringssl/src/crypto/x509v3/v3_akey.c +118 -112
- package/third_party/boringssl/src/crypto/x509v3/v3_akeya.c +3 -3
- package/third_party/boringssl/src/crypto/x509v3/v3_alt.c +447 -451
- package/third_party/boringssl/src/crypto/x509v3/v3_bcons.c +44 -38
- package/third_party/boringssl/src/crypto/x509v3/v3_bitst.c +39 -43
- package/third_party/boringssl/src/crypto/x509v3/v3_conf.c +321 -320
- package/third_party/boringssl/src/crypto/x509v3/v3_cpols.c +352 -327
- package/third_party/boringssl/src/crypto/x509v3/v3_crld.c +437 -383
- package/third_party/boringssl/src/crypto/x509v3/v3_enum.c +23 -16
- package/third_party/boringssl/src/crypto/x509v3/v3_extku.c +62 -53
- package/third_party/boringssl/src/crypto/x509v3/v3_genn.c +118 -115
- package/third_party/boringssl/src/crypto/x509v3/v3_ia5.c +30 -31
- package/third_party/boringssl/src/crypto/x509v3/v3_info.c +112 -98
- package/third_party/boringssl/src/crypto/x509v3/v3_int.c +40 -15
- package/third_party/boringssl/src/crypto/x509v3/v3_lib.c +248 -252
- package/third_party/boringssl/src/crypto/x509v3/v3_ncons.c +390 -386
- package/third_party/boringssl/src/crypto/x509v3/v3_ocsp.c +45 -32
- package/third_party/boringssl/src/crypto/x509v3/v3_pci.c +206 -209
- package/third_party/boringssl/src/crypto/x509v3/v3_pcia.c +6 -8
- package/third_party/boringssl/src/crypto/x509v3/v3_pcons.c +54 -50
- package/third_party/boringssl/src/crypto/x509v3/v3_pmaps.c +66 -65
- package/third_party/boringssl/src/crypto/x509v3/v3_prn.c +144 -133
- package/third_party/boringssl/src/crypto/x509v3/v3_purp.c +695 -709
- package/third_party/boringssl/src/crypto/x509v3/v3_skey.c +75 -69
- package/third_party/boringssl/src/crypto/x509v3/v3_utl.c +1102 -1082
- package/third_party/boringssl/src/include/openssl/base.h +3 -1
- package/third_party/boringssl/src/include/openssl/bn.h +3 -0
- package/third_party/boringssl/src/include/openssl/bytestring.h +20 -0
- package/third_party/boringssl/src/include/openssl/evp.h +6 -5
- package/third_party/boringssl/src/include/openssl/kdf.h +91 -0
- package/third_party/boringssl/src/include/openssl/nid.h +4 -0
- package/third_party/boringssl/src/include/openssl/ssl.h +6 -1
- package/third_party/boringssl/src/include/openssl/stack.h +47 -32
- package/third_party/boringssl/src/include/openssl/trust_token.h +18 -3
- package/third_party/boringssl/src/include/openssl/x509.h +18 -0
- package/third_party/boringssl/src/ssl/ssl_file.cc +61 -99
- package/third_party/boringssl/src/ssl/ssl_test.cc +101 -0
- package/third_party/boringssl/src/util/doc.config +2 -1
- package/third_party/boringssl/src/util/fipstools/acvp/acvptool/subprocess/subprocess.go +8 -0
- package/third_party/googleurl/AUTHORS +16 -2
- package/third_party/googleurl/base/BUILD +1 -0
- package/third_party/googleurl/base/compiler_specific.h +16 -17
- package/third_party/googleurl/base/containers/contiguous_iterator.h +13 -9
- package/third_party/googleurl/base/containers/span.h +23 -8
- package/third_party/googleurl/base/memory/raw_ptr.h +17 -25
- package/third_party/googleurl/base/memory/raw_ptr_exclusion.h +21 -0
- package/third_party/googleurl/base/strings/escape.cc +14 -2
- package/third_party/googleurl/base/strings/safe_sprintf.h +1 -1
- package/third_party/googleurl/base/strings/string_number_conversions.cc +5 -3
- package/third_party/googleurl/base/strings/string_number_conversions_internal.h +5 -5
- package/third_party/googleurl/base/strings/string_piece.h +3 -3
- package/third_party/googleurl/base/strings/string_util.cc +4 -27
- package/third_party/googleurl/base/strings/string_util.h +43 -8
- package/third_party/googleurl/base/strings/string_util_internal.h +11 -12
- package/third_party/googleurl/base/strings/string_util_unittest.cc +33 -0
- package/third_party/googleurl/base/strings/string_util_win.cc +0 -5
- package/third_party/googleurl/base/strings/string_util_win.h +9 -1
- package/third_party/googleurl/base/strings/utf_offset_string_conversions.cc +1 -1
- package/third_party/googleurl/base/strings/utf_string_conversion_utils.cc +5 -8
- package/third_party/googleurl/base/strings/utf_string_conversion_utils.h +13 -10
- package/third_party/googleurl/base/strings/utf_string_conversions.cc +32 -25
- package/third_party/googleurl/base/template_util.h +23 -35
- package/third_party/googleurl/build/build_config.h +14 -3
- package/third_party/googleurl/copy.bara.sky +1 -1
- package/third_party/googleurl/url/gurl.cc +8 -4
- package/third_party/googleurl/url/gurl.h +1 -0
- package/third_party/googleurl/url/gurl_unittest.cc +1 -0
- package/third_party/googleurl/url/origin.h +36 -26
- package/third_party/googleurl/url/scheme_host_port.h +4 -1
- package/third_party/googleurl/url/url_canon.h +2 -1
- package/third_party/googleurl/url/url_canon_internal.cc +9 -7
- package/third_party/googleurl/url/url_canon_internal.h +16 -16
- package/third_party/googleurl/url/url_canon_stdstring.h +2 -1
- package/third_party/googleurl/url/url_util.cc +9 -8
- package/third_party/quiche/build/source_list.bzl +7 -0
- package/third_party/quiche/build/source_list.gni +7 -0
- package/third_party/quiche/build/source_list.json +7 -0
- package/third_party/quiche/quiche/common/platform/api/quiche_mem_slice.h +7 -3
- package/third_party/quiche/quiche/http2/adapter/nghttp2_adapter_test.cc +86 -2
- package/third_party/quiche/quiche/http2/adapter/oghttp2_adapter_test.cc +104 -2
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.cc +23 -0
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.h +6 -1
- package/third_party/quiche/quiche/quic/core/congestion_control/send_algorithm_test.cc +0 -16
- package/third_party/quiche/quiche/quic/core/crypto/crypto_protocol.h +1 -1
- package/third_party/quiche/quiche/quic/core/http/end_to_end_test.cc +56 -2
- package/third_party/quiche/quiche/quic/core/http/http_constants.cc +1 -0
- package/third_party/quiche/quiche/quic/core/http/http_constants.h +1 -0
- package/third_party/quiche/quiche/quic/core/http/http_encoder.cc +28 -17
- package/third_party/quiche/quiche/quic/core/http/http_encoder.h +5 -0
- package/third_party/quiche/quiche/quic/core/http/http_encoder_test.cc +26 -30
- package/third_party/quiche/quiche/quic/core/http/http_frames.h +1 -0
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base.cc +4 -4
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base_test.cc +1 -1
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_client_session.cc +5 -1
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.cc +6 -33
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.h +0 -17
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream_test.cc +5 -20
- package/third_party/quiche/quiche/quic/core/io/quic_event_loop.h +81 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.cc +265 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.h +152 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop_test.cc +341 -0
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.cc +3 -1
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.h +7 -7
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store_test.cc +4 -3
- package/third_party/quiche/quiche/quic/core/quic_connection.cc +69 -19
- package/third_party/quiche/quiche/quic/core/quic_connection.h +9 -3
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.cc +29 -10
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.h +5 -3
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager_test.cc +85 -22
- package/third_party/quiche/quiche/quic/core/quic_connection_test.cc +186 -30
- package/third_party/quiche/quiche/quic/core/quic_crypto_stream.cc +2 -1
- package/third_party/quiche/quiche/quic/core/quic_default_clock.cc +31 -0
- package/third_party/quiche/quiche/quic/core/quic_default_clock.h +34 -0
- package/third_party/quiche/quiche/quic/core/quic_default_connection_helper.h +49 -0
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.cc +53 -37
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.h +19 -11
- package/third_party/quiche/quiche/quic/core/quic_dispatcher_test.cc +15 -2
- package/third_party/quiche/quiche/quic/core/quic_flags_list.h +10 -4
- package/third_party/quiche/quiche/quic/core/quic_idle_network_detector.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_idle_network_detector_test.cc +4 -4
- package/third_party/quiche/quiche/quic/core/quic_packet_creator.cc +14 -3
- package/third_party/quiche/quiche/quic/core/quic_packet_creator_test.cc +145 -2
- package/third_party/quiche/quiche/quic/core/quic_packets.cc +3 -1
- package/third_party/quiche/quiche/quic/core/quic_packets.h +4 -0
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.cc +13 -11
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.h +9 -0
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager_test.cc +6 -0
- package/third_party/quiche/quiche/quic/core/quic_session.cc +3 -2
- package/third_party/quiche/quiche/quic/core/quic_session.h +8 -3
- package/third_party/quiche/quiche/quic/core/quic_types.cc +18 -0
- package/third_party/quiche/quiche/quic/core/quic_types.h +3 -0
- package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.cc +3 -0
- package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.h +10 -0
- package/third_party/quiche/quiche/quic/test_tools/mock_quic_session_visitor.h +1 -1
- package/third_party/quiche/quiche/quic/test_tools/quic_test_utils.h +1 -1
- package/third_party/quiche/quiche/quic/test_tools/server_thread.cc +3 -2
- package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.cc +7 -1
- package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.h +3 -0
- package/third_party/quiche/quiche/quic/test_tools/simulator/quic_endpoint.h +4 -2
- package/certs/ca.cnf +0 -69
- package/certs/generate_certs.sh +0 -53
- package/certs/generate_certs_leaf.sh +0 -53
- package/certs/leaf.cnf +0 -24
- package/certs/readme.txt +0 -2
- package/third_party/quiche/build/BUILD.bazel +0 -7
|
@@ -252,7 +252,7 @@ StringT DoubleToStringT(double value) {
|
|
|
252
252
|
char buffer[32];
|
|
253
253
|
double_conversion::StringBuilder builder(buffer, sizeof(buffer));
|
|
254
254
|
GetDoubleToStringConverter()->ToShortest(value, &builder);
|
|
255
|
-
return ToString<StringT>(buffer, builder.position());
|
|
255
|
+
return ToString<StringT>(buffer, static_cast<size_t>(builder.position()));
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
template <typename STRING, typename CHAR>
|
|
@@ -263,8 +263,8 @@ bool StringToDoubleImpl(STRING input, const CHAR* data, double& output) {
|
|
|
263
263
|
0.0, 0, nullptr, nullptr);
|
|
264
264
|
|
|
265
265
|
int processed_characters_count;
|
|
266
|
-
output =
|
|
267
|
-
|
|
266
|
+
output = converter.StringToDouble(data, checked_cast<int>(input.size()),
|
|
267
|
+
&processed_characters_count);
|
|
268
268
|
|
|
269
269
|
// Cases to return false:
|
|
270
270
|
// - If the input string is empty, there was nothing to parse.
|
|
@@ -278,7 +278,7 @@ bool StringToDoubleImpl(STRING input, const CHAR* data, double& output) {
|
|
|
278
278
|
!IsUnicodeWhitespace(input[0]);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
template <typename OutIter>
|
|
281
|
+
template <typename Char, typename OutIter>
|
|
282
282
|
static bool HexStringToByteContainer(StringPiece input, OutIter output) {
|
|
283
283
|
size_t count = input.size();
|
|
284
284
|
if (count == 0 || (count % 2) != 0)
|
|
@@ -291,7 +291,7 @@ static bool HexStringToByteContainer(StringPiece input, OutIter output) {
|
|
|
291
291
|
if (!msb || !lsb) {
|
|
292
292
|
return false;
|
|
293
293
|
}
|
|
294
|
-
*(output++) = (*msb << 4) | *lsb;
|
|
294
|
+
*(output++) = static_cast<Char>((*msb << 4) | *lsb);
|
|
295
295
|
}
|
|
296
296
|
return true;
|
|
297
297
|
}
|
|
@@ -607,10 +607,10 @@ struct StringPieceHashImpl {
|
|
|
607
607
|
// This is a custom hash function. We don't use the ones already defined for
|
|
608
608
|
// string and std::u16string directly because it would require the string
|
|
609
609
|
// constructors to be called, which we don't want.
|
|
610
|
-
|
|
611
|
-
|
|
610
|
+
size_t operator()(StringPieceType sp) const {
|
|
611
|
+
size_t result = 0;
|
|
612
612
|
for (auto c : sp)
|
|
613
|
-
result = (result * 131) + c;
|
|
613
|
+
result = (result * 131) + static_cast<size_t>(c);
|
|
614
614
|
return result;
|
|
615
615
|
}
|
|
616
616
|
};
|
|
@@ -90,16 +90,6 @@ int CompareCaseInsensitiveASCII(StringPiece16 a, StringPiece16 b) {
|
|
|
90
90
|
return internal::CompareCaseInsensitiveASCIIT(a, b);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
bool EqualsCaseInsensitiveASCII(StringPiece a, StringPiece b) {
|
|
94
|
-
return a.size() == b.size() &&
|
|
95
|
-
internal::CompareCaseInsensitiveASCIIT(a, b) == 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
bool EqualsCaseInsensitiveASCII(StringPiece16 a, StringPiece16 b) {
|
|
99
|
-
return a.size() == b.size() &&
|
|
100
|
-
internal::CompareCaseInsensitiveASCIIT(a, b) == 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
93
|
const std::string& EmptyString() {
|
|
104
94
|
static const gurl_base::NoDestructor<std::string> s;
|
|
105
95
|
return *s;
|
|
@@ -185,8 +175,7 @@ void TruncateUTF8ToByteSize(const std::string& input,
|
|
|
185
175
|
int32_t prev = char_index;
|
|
186
176
|
base_icu::UChar32 code_point = 0;
|
|
187
177
|
CBU8_NEXT(data, char_index, truncation_length, code_point);
|
|
188
|
-
if (!IsValidCharacter(code_point)
|
|
189
|
-
!IsValidCodepoint(code_point)) {
|
|
178
|
+
if (!IsValidCharacter(code_point)) {
|
|
190
179
|
char_index = prev - 1;
|
|
191
180
|
} else {
|
|
192
181
|
break;
|
|
@@ -301,24 +290,12 @@ bool EndsWith(StringPiece16 str,
|
|
|
301
290
|
return internal::EndsWithT(str, search_for, case_sensitivity);
|
|
302
291
|
}
|
|
303
292
|
|
|
304
|
-
char HexDigitToInt(
|
|
293
|
+
char HexDigitToInt(char c) {
|
|
305
294
|
GURL_DCHECK(IsHexDigit(c));
|
|
306
295
|
if (c >= '0' && c <= '9')
|
|
307
296
|
return static_cast<char>(c - '0');
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (c >= 'a' && c <= 'f')
|
|
311
|
-
return static_cast<char>(c - 'a' + 10);
|
|
312
|
-
return 0;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
bool IsUnicodeWhitespace(wchar_t c) {
|
|
316
|
-
// kWhitespaceWide is a NULL-terminated string
|
|
317
|
-
for (const wchar_t* cur = kWhitespaceWide; *cur; ++cur) {
|
|
318
|
-
if (*cur == c)
|
|
319
|
-
return true;
|
|
320
|
-
}
|
|
321
|
-
return false;
|
|
297
|
+
return (c >= 'A' && c <= 'F') ? static_cast<char>(c - 'A' + 10)
|
|
298
|
+
: static_cast<char>(c - 'a' + 10);
|
|
322
299
|
}
|
|
323
300
|
|
|
324
301
|
static const char* const kByteStringsUnlocalized[] = {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <stddef.h>
|
|
13
13
|
#include <stdint.h>
|
|
14
14
|
|
|
15
|
+
#include <algorithm>
|
|
15
16
|
#include <initializer_list>
|
|
16
17
|
#include <string>
|
|
17
18
|
#include <type_traits>
|
|
@@ -122,7 +123,7 @@ CharT ToLowerASCII(CharT c) {
|
|
|
122
123
|
template <typename CharT,
|
|
123
124
|
typename = std::enable_if_t<std::is_integral<CharT>::value>>
|
|
124
125
|
CharT ToUpperASCII(CharT c) {
|
|
125
|
-
return (c >= 'a' && c <= 'z') ? (c +
|
|
126
|
+
return (c >= 'a' && c <= 'z') ? static_cast<CharT>(c + 'A' - 'a') : c;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
// Converts the given string to it's ASCII-lowercase equivalent.
|
|
@@ -153,16 +154,37 @@ template<typename Char> struct CaseInsensitiveCompareASCII {
|
|
|
153
154
|
// 0 (a == b)
|
|
154
155
|
// 1 (a > b)
|
|
155
156
|
// (unlike strcasecmp which can return values greater or less than 1/-1). For
|
|
156
|
-
// full Unicode support, use gurl_base::i18n::ToLower or gurl_base::
|
|
157
|
+
// full Unicode support, use gurl_base::i18n::ToLower or gurl_base::i18n::FoldCase
|
|
157
158
|
// and then just call the normal string operators on the result.
|
|
158
159
|
BASE_EXPORT int CompareCaseInsensitiveASCII(StringPiece a, StringPiece b);
|
|
159
160
|
BASE_EXPORT int CompareCaseInsensitiveASCII(StringPiece16 a, StringPiece16 b);
|
|
160
161
|
|
|
162
|
+
namespace internal {
|
|
163
|
+
template <typename CharT, typename CharU>
|
|
164
|
+
inline bool EqualsCaseInsensitiveASCIIT(BasicStringPiece<CharT> a,
|
|
165
|
+
BasicStringPiece<CharU> b) {
|
|
166
|
+
return std::equal(a.begin(), a.end(), b.begin(), b.end(),
|
|
167
|
+
[](auto lhs, auto rhs) {
|
|
168
|
+
return ToLowerASCII(lhs) == ToLowerASCII(rhs);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
} // namespace internal
|
|
172
|
+
|
|
161
173
|
// Equality for ASCII case-insensitive comparisons. For full Unicode support,
|
|
162
|
-
// use gurl_base::i18n::ToLower or gurl_base::
|
|
174
|
+
// use gurl_base::i18n::ToLower or gurl_base::i18n::FoldCase and then compare with either
|
|
163
175
|
// == or !=.
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
inline bool EqualsCaseInsensitiveASCII(StringPiece a, StringPiece b) {
|
|
177
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
178
|
+
}
|
|
179
|
+
inline bool EqualsCaseInsensitiveASCII(StringPiece16 a, StringPiece16 b) {
|
|
180
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
181
|
+
}
|
|
182
|
+
inline bool EqualsCaseInsensitiveASCII(StringPiece16 a, StringPiece b) {
|
|
183
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
184
|
+
}
|
|
185
|
+
inline bool EqualsCaseInsensitiveASCII(StringPiece a, StringPiece16 b) {
|
|
186
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
187
|
+
}
|
|
166
188
|
|
|
167
189
|
// These threadsafe functions return references to globally unique empty
|
|
168
190
|
// strings.
|
|
@@ -395,11 +417,24 @@ inline bool IsHexDigit(Char c) {
|
|
|
395
417
|
// '4' -> 4
|
|
396
418
|
// 'a' -> 10
|
|
397
419
|
// 'B' -> 11
|
|
398
|
-
// Assumes the input is a valid hex character.
|
|
399
|
-
BASE_EXPORT char HexDigitToInt(
|
|
420
|
+
// Assumes the input is a valid hex character.
|
|
421
|
+
BASE_EXPORT char HexDigitToInt(char c);
|
|
422
|
+
inline char HexDigitToInt(char16_t c) {
|
|
423
|
+
GURL_DCHECK(IsHexDigit(c));
|
|
424
|
+
return HexDigitToInt(static_cast<char>(c));
|
|
425
|
+
}
|
|
400
426
|
|
|
401
427
|
// Returns true if it's a Unicode whitespace character.
|
|
402
|
-
|
|
428
|
+
template <typename Char>
|
|
429
|
+
inline bool IsUnicodeWhitespace(Char c) {
|
|
430
|
+
// kWhitespaceWide is a NUL-terminated string
|
|
431
|
+
for (const auto* cur = kWhitespaceWide; *cur; ++cur) {
|
|
432
|
+
if (static_cast<typename std::make_unsigned_t<wchar_t>>(*cur) ==
|
|
433
|
+
static_cast<typename std::make_unsigned_t<Char>>(c))
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
return false;
|
|
437
|
+
};
|
|
403
438
|
|
|
404
439
|
// Return a byte string in human-readable format with a unit suffix. Not
|
|
405
440
|
// appropriate for use in any UI; use of FormatBytes and friends in ui/base is
|
|
@@ -26,7 +26,7 @@ struct ReplacementOffset {
|
|
|
26
26
|
: parameter(parameter), offset(offset) {}
|
|
27
27
|
|
|
28
28
|
// Index of the parameter.
|
|
29
|
-
|
|
29
|
+
size_t parameter;
|
|
30
30
|
|
|
31
31
|
// Starting position in the string.
|
|
32
32
|
size_t offset;
|
|
@@ -147,7 +147,7 @@ std::basic_string<CharT> CollapseWhitespaceT(
|
|
|
147
147
|
bool in_whitespace = true;
|
|
148
148
|
bool already_trimmed = true;
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
size_t chars_written = 0;
|
|
151
151
|
for (auto c : text) {
|
|
152
152
|
if (IsUnicodeWhitespace(c)) {
|
|
153
153
|
if (!in_whitespace) {
|
|
@@ -196,7 +196,7 @@ bool DoIsStringASCII(const Char* characters, size_t length) {
|
|
|
196
196
|
|
|
197
197
|
// Prologue: align the input.
|
|
198
198
|
while (!IsMachineWordAligned(characters) && characters < end)
|
|
199
|
-
all_char_bits |= *characters
|
|
199
|
+
all_char_bits |= static_cast<MachineWord>(*characters++);
|
|
200
200
|
if (all_char_bits & non_ascii_bit_mask)
|
|
201
201
|
return false;
|
|
202
202
|
|
|
@@ -222,19 +222,19 @@ bool DoIsStringASCII(const Char* characters, size_t length) {
|
|
|
222
222
|
|
|
223
223
|
// Process the remaining bytes.
|
|
224
224
|
while (characters < end)
|
|
225
|
-
all_char_bits |= *characters
|
|
225
|
+
all_char_bits |= static_cast<MachineWord>(*characters++);
|
|
226
226
|
|
|
227
227
|
return !(all_char_bits & non_ascii_bit_mask);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
template <bool (*Validator)(
|
|
230
|
+
template <bool (*Validator)(base_icu::UChar32)>
|
|
231
231
|
inline bool DoIsStringUTF8(StringPiece str) {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
const uint8_t* src = reinterpret_cast<const uint8_t*>(str.data());
|
|
233
|
+
size_t src_len = str.length();
|
|
234
|
+
size_t char_index = 0;
|
|
235
235
|
|
|
236
236
|
while (char_index < src_len) {
|
|
237
|
-
|
|
237
|
+
base_icu::UChar32 code_point;
|
|
238
238
|
CBU8_NEXT(src, char_index, src_len, code_point);
|
|
239
239
|
if (!Validator(code_point))
|
|
240
240
|
return false;
|
|
@@ -583,10 +583,9 @@ std::basic_string<CharT> DoReplaceStringPlaceholders(
|
|
|
583
583
|
GURL_DLOG(ERROR) << "Invalid placeholder: $" << *i;
|
|
584
584
|
continue;
|
|
585
585
|
}
|
|
586
|
-
|
|
586
|
+
size_t index = static_cast<size_t>(*i - '1');
|
|
587
587
|
if (offsets) {
|
|
588
|
-
ReplacementOffset r_offset(index,
|
|
589
|
-
static_cast<int>(formatted.size()));
|
|
588
|
+
ReplacementOffset r_offset(index, formatted.size());
|
|
590
589
|
r_offsets.insert(
|
|
591
590
|
ranges::upper_bound(r_offsets, r_offset, &CompareParameter),
|
|
592
591
|
r_offset);
|
|
@@ -1472,6 +1472,39 @@ TEST(StringUtilTest, EqualsCaseInsensitiveASCII) {
|
|
|
1472
1472
|
EXPECT_TRUE(EqualsCaseInsensitiveASCII("Asdf", "aSDF"));
|
|
1473
1473
|
EXPECT_FALSE(EqualsCaseInsensitiveASCII("bsdf", "aSDF"));
|
|
1474
1474
|
EXPECT_FALSE(EqualsCaseInsensitiveASCII("Asdf", "aSDFz"));
|
|
1475
|
+
|
|
1476
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(u"", u""));
|
|
1477
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(u"Asdf", u"aSDF"));
|
|
1478
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(u"bsdf", u"aSDF"));
|
|
1479
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(u"Asdf", u"aSDFz"));
|
|
1480
|
+
|
|
1481
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(u"", ""));
|
|
1482
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(u"Asdf", "aSDF"));
|
|
1483
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(u"bsdf", "aSDF"));
|
|
1484
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(u"Asdf", "aSDFz"));
|
|
1485
|
+
|
|
1486
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII("", u""));
|
|
1487
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII("Asdf", u"aSDF"));
|
|
1488
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII("bsdf", u"aSDF"));
|
|
1489
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII("Asdf", u"aSDFz"));
|
|
1490
|
+
|
|
1491
|
+
// The `WStringPiece` overloads are only defined on Windows.
|
|
1492
|
+
#if BUILDFLAG(IS_WIN)
|
|
1493
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(L"", L""));
|
|
1494
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(L"Asdf", L"aSDF"));
|
|
1495
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(L"bsdf", L"aSDF"));
|
|
1496
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(L"Asdf", L"aSDFz"));
|
|
1497
|
+
|
|
1498
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(L"", ""));
|
|
1499
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII(L"Asdf", "aSDF"));
|
|
1500
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(L"bsdf", "aSDF"));
|
|
1501
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII(L"Asdf", "aSDFz"));
|
|
1502
|
+
|
|
1503
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII("", L""));
|
|
1504
|
+
EXPECT_TRUE(EqualsCaseInsensitiveASCII("Asdf", L"aSDF"));
|
|
1505
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII("bsdf", L"aSDF"));
|
|
1506
|
+
EXPECT_FALSE(EqualsCaseInsensitiveASCII("Asdf", L"aSDFz"));
|
|
1507
|
+
#endif
|
|
1475
1508
|
}
|
|
1476
1509
|
|
|
1477
1510
|
TEST(StringUtilTest, IsUnicodeWhitespace) {
|
|
@@ -24,11 +24,6 @@ int CompareCaseInsensitiveASCII(WStringPiece a, WStringPiece b) {
|
|
|
24
24
|
return internal::CompareCaseInsensitiveASCIIT(a, b);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
bool EqualsCaseInsensitiveASCII(WStringPiece a, WStringPiece b) {
|
|
28
|
-
return a.size() == b.size() &&
|
|
29
|
-
internal::CompareCaseInsensitiveASCIIT(a, b) == 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
27
|
bool RemoveChars(WStringPiece input,
|
|
33
28
|
WStringPiece remove_chars,
|
|
34
29
|
std::wstring* output) {
|
|
@@ -117,7 +117,15 @@ BASE_EXPORT std::wstring ToUpperASCII(WStringPiece str);
|
|
|
117
117
|
|
|
118
118
|
BASE_EXPORT int CompareCaseInsensitiveASCII(WStringPiece a, WStringPiece b);
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
inline bool EqualsCaseInsensitiveASCII(WStringPiece a, WStringPiece b) {
|
|
121
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
122
|
+
}
|
|
123
|
+
inline bool EqualsCaseInsensitiveASCII(WStringPiece a, StringPiece b) {
|
|
124
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
125
|
+
}
|
|
126
|
+
inline bool EqualsCaseInsensitiveASCII(StringPiece a, WStringPiece b) {
|
|
127
|
+
return internal::EqualsCaseInsensitiveASCIIT(a, b);
|
|
128
|
+
}
|
|
121
129
|
|
|
122
130
|
BASE_EXPORT bool RemoveChars(WStringPiece input,
|
|
123
131
|
WStringPiece remove_chars,
|
|
@@ -192,7 +192,7 @@ bool ConvertUnicode(const SrcChar* src,
|
|
|
192
192
|
bool success = true;
|
|
193
193
|
int32_t src_len32 = static_cast<int32_t>(src_len);
|
|
194
194
|
for (int32_t i = 0; i < src_len32; i++) {
|
|
195
|
-
|
|
195
|
+
base_icu::UChar32 code_point;
|
|
196
196
|
size_t original_i = i;
|
|
197
197
|
size_t chars_written = 0;
|
|
198
198
|
if (ReadUnicodeCharacter(src, src_len32, &i, &code_point)) {
|
|
@@ -14,13 +14,10 @@ namespace gurl_base {
|
|
|
14
14
|
bool ReadUnicodeCharacter(const char* src,
|
|
15
15
|
int32_t src_len,
|
|
16
16
|
int32_t* char_index,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// use a signed type for code_point. But this function returns false
|
|
20
|
-
// on error anyway, so code_point_out is unsigned.
|
|
21
|
-
int32_t code_point;
|
|
17
|
+
base_icu::UChar32* code_point_out) {
|
|
18
|
+
base_icu::UChar32 code_point;
|
|
22
19
|
CBU8_NEXT(src, *char_index, src_len, code_point);
|
|
23
|
-
*code_point_out =
|
|
20
|
+
*code_point_out = code_point;
|
|
24
21
|
|
|
25
22
|
// The ICU macro above moves to the next char, we want to point to the last
|
|
26
23
|
// char consumed.
|
|
@@ -33,7 +30,7 @@ bool ReadUnicodeCharacter(const char* src,
|
|
|
33
30
|
bool ReadUnicodeCharacter(const char16_t* src,
|
|
34
31
|
int32_t src_len,
|
|
35
32
|
int32_t* char_index,
|
|
36
|
-
|
|
33
|
+
base_icu::UChar32* code_point) {
|
|
37
34
|
if (CBU16_IS_SURROGATE(src[*char_index])) {
|
|
38
35
|
if (!CBU16_IS_SURROGATE_LEAD(src[*char_index]) ||
|
|
39
36
|
*char_index + 1 >= src_len ||
|
|
@@ -58,7 +55,7 @@ bool ReadUnicodeCharacter(const char16_t* src,
|
|
|
58
55
|
bool ReadUnicodeCharacter(const wchar_t* src,
|
|
59
56
|
int32_t src_len,
|
|
60
57
|
int32_t* char_index,
|
|
61
|
-
|
|
58
|
+
base_icu::UChar32* code_point) {
|
|
62
59
|
// Conversion is easy since the source is 32-bit.
|
|
63
60
|
*code_point = src[*char_index];
|
|
64
61
|
|
|
@@ -14,26 +14,29 @@
|
|
|
14
14
|
#include <string>
|
|
15
15
|
|
|
16
16
|
#include "polyfills/base/base_export.h"
|
|
17
|
+
#include "base/third_party/icu/icu_utf.h"
|
|
18
|
+
#include "build/build_config.h"
|
|
17
19
|
|
|
18
20
|
namespace gurl_base {
|
|
19
21
|
|
|
20
|
-
inline bool IsValidCodepoint(
|
|
22
|
+
inline bool IsValidCodepoint(base_icu::UChar32 code_point) {
|
|
21
23
|
// Excludes code points that are not Unicode scalar values, i.e.
|
|
22
24
|
// surrogate code points ([0xD800, 0xDFFF]). Additionally, excludes
|
|
23
25
|
// code points larger than 0x10FFFF (the highest codepoint allowed).
|
|
24
26
|
// Non-characters and unassigned code points are allowed.
|
|
25
27
|
// https://unicode.org/glossary/#unicode_scalar_value
|
|
26
|
-
return code_point <
|
|
27
|
-
(code_point >=
|
|
28
|
+
return (code_point >= 0 && code_point < 0xD800) ||
|
|
29
|
+
(code_point >= 0xE000 && code_point <= 0x10FFFF);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
inline bool IsValidCharacter(
|
|
32
|
+
inline bool IsValidCharacter(base_icu::UChar32 code_point) {
|
|
31
33
|
// Excludes non-characters (U+FDD0..U+FDEF, and all code points
|
|
32
34
|
// ending in 0xFFFE or 0xFFFF) from the set of valid code points.
|
|
33
35
|
// https://unicode.org/faq/private_use.html#nonchar1
|
|
34
|
-
return code_point
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
return (code_point >= 0 && code_point < 0xD800) ||
|
|
37
|
+
(code_point >= 0xE000 && code_point < 0xFDD0) ||
|
|
38
|
+
(code_point > 0xFDEF && code_point <= 0x10FFFF &&
|
|
39
|
+
(code_point & 0xFFFE) != 0xFFFE);
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
// ReadUnicodeCharacter --------------------------------------------------------
|
|
@@ -48,20 +51,20 @@ inline bool IsValidCharacter(uint32_t code_point) {
|
|
|
48
51
|
BASE_EXPORT bool ReadUnicodeCharacter(const char* src,
|
|
49
52
|
int32_t src_len,
|
|
50
53
|
int32_t* char_index,
|
|
51
|
-
|
|
54
|
+
base_icu::UChar32* code_point_out);
|
|
52
55
|
|
|
53
56
|
// Reads a UTF-16 character. The usage is the same as the 8-bit version above.
|
|
54
57
|
BASE_EXPORT bool ReadUnicodeCharacter(const char16_t* src,
|
|
55
58
|
int32_t src_len,
|
|
56
59
|
int32_t* char_index,
|
|
57
|
-
|
|
60
|
+
base_icu::UChar32* code_point);
|
|
58
61
|
|
|
59
62
|
#if defined(WCHAR_T_IS_UTF32)
|
|
60
63
|
// Reads UTF-32 character. The usage is the same as the 8-bit version above.
|
|
61
64
|
BASE_EXPORT bool ReadUnicodeCharacter(const wchar_t* src,
|
|
62
65
|
int32_t src_len,
|
|
63
66
|
int32_t* char_index,
|
|
64
|
-
|
|
67
|
+
base_icu::UChar32* code_point);
|
|
65
68
|
#endif // defined(WCHAR_T_IS_UTF32)
|
|
66
69
|
|
|
67
70
|
// WriteUnicodeCharacter -------------------------------------------------------
|
|
@@ -20,7 +20,7 @@ namespace gurl_base {
|
|
|
20
20
|
|
|
21
21
|
namespace {
|
|
22
22
|
|
|
23
|
-
constexpr
|
|
23
|
+
constexpr base_icu::UChar32 kErrorCodePoint = 0xFFFD;
|
|
24
24
|
|
|
25
25
|
// Size coefficient ----------------------------------------------------------
|
|
26
26
|
// The maximum number of codeunits in the destination encoding corresponding to
|
|
@@ -71,17 +71,23 @@ using EnableIfBitsAre = std::enable_if_t<std::is_integral<Char>::value &&
|
|
|
71
71
|
bool>;
|
|
72
72
|
|
|
73
73
|
template <typename Char, EnableIfBitsAre<Char, 8> = true>
|
|
74
|
-
void UnicodeAppendUnsafe(Char* out,
|
|
75
|
-
|
|
74
|
+
void UnicodeAppendUnsafe(Char* out,
|
|
75
|
+
size_t* size,
|
|
76
|
+
base_icu::UChar32 code_point) {
|
|
77
|
+
CBU8_APPEND_UNSAFE(reinterpret_cast<uint8_t*>(out), *size, code_point);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
template <typename Char, EnableIfBitsAre<Char, 16> = true>
|
|
79
|
-
void UnicodeAppendUnsafe(Char* out,
|
|
81
|
+
void UnicodeAppendUnsafe(Char* out,
|
|
82
|
+
size_t* size,
|
|
83
|
+
base_icu::UChar32 code_point) {
|
|
80
84
|
CBU16_APPEND_UNSAFE(out, *size, code_point);
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
template <typename Char, EnableIfBitsAre<Char, 32> = true>
|
|
84
|
-
void UnicodeAppendUnsafe(Char* out,
|
|
88
|
+
void UnicodeAppendUnsafe(Char* out,
|
|
89
|
+
size_t* size,
|
|
90
|
+
base_icu::UChar32 code_point) {
|
|
85
91
|
out[(*size)++] = code_point;
|
|
86
92
|
}
|
|
87
93
|
|
|
@@ -91,14 +97,14 @@ void UnicodeAppendUnsafe(Char* out, int32_t* size, uint32_t code_point) {
|
|
|
91
97
|
|
|
92
98
|
template <typename DestChar>
|
|
93
99
|
bool DoUTFConversion(const char* src,
|
|
94
|
-
|
|
100
|
+
size_t src_len,
|
|
95
101
|
DestChar* dest,
|
|
96
|
-
|
|
102
|
+
size_t* dest_len) {
|
|
97
103
|
bool success = true;
|
|
98
104
|
|
|
99
|
-
for (
|
|
100
|
-
|
|
101
|
-
CBU8_NEXT(src, i, src_len, code_point);
|
|
105
|
+
for (size_t i = 0; i < src_len;) {
|
|
106
|
+
base_icu::UChar32 code_point;
|
|
107
|
+
CBU8_NEXT(reinterpret_cast<const uint8_t*>(src), i, src_len, code_point);
|
|
102
108
|
|
|
103
109
|
if (!IsValidCodepoint(code_point)) {
|
|
104
110
|
success = false;
|
|
@@ -113,12 +119,12 @@ bool DoUTFConversion(const char* src,
|
|
|
113
119
|
|
|
114
120
|
template <typename DestChar>
|
|
115
121
|
bool DoUTFConversion(const char16_t* src,
|
|
116
|
-
|
|
122
|
+
size_t src_len,
|
|
117
123
|
DestChar* dest,
|
|
118
|
-
|
|
124
|
+
size_t* dest_len) {
|
|
119
125
|
bool success = true;
|
|
120
126
|
|
|
121
|
-
auto ConvertSingleChar = [&success](char16_t in) ->
|
|
127
|
+
auto ConvertSingleChar = [&success](char16_t in) -> base_icu::UChar32 {
|
|
122
128
|
if (!CBU16_IS_SINGLE(in) || !IsValidCodepoint(in)) {
|
|
123
129
|
success = false;
|
|
124
130
|
return kErrorCodePoint;
|
|
@@ -126,12 +132,12 @@ bool DoUTFConversion(const char16_t* src,
|
|
|
126
132
|
return in;
|
|
127
133
|
};
|
|
128
134
|
|
|
129
|
-
|
|
135
|
+
size_t i = 0;
|
|
130
136
|
|
|
131
137
|
// Always have another symbol in order to avoid checking boundaries in the
|
|
132
138
|
// middle of the surrogate pair.
|
|
133
|
-
while (i < src_len
|
|
134
|
-
|
|
139
|
+
while (i + 1 < src_len) {
|
|
140
|
+
base_icu::UChar32 code_point;
|
|
135
141
|
|
|
136
142
|
if (CBU16_IS_LEAD(src[i]) && CBU16_IS_TRAIL(src[i + 1])) {
|
|
137
143
|
code_point = CBU16_GET_SUPPLEMENTARY(src[i], src[i + 1]);
|
|
@@ -148,8 +154,9 @@ bool DoUTFConversion(const char16_t* src,
|
|
|
148
154
|
UnicodeAppendUnsafe(dest, dest_len, code_point);
|
|
149
155
|
}
|
|
150
156
|
|
|
151
|
-
if (i < src_len)
|
|
157
|
+
if (i < src_len) {
|
|
152
158
|
UnicodeAppendUnsafe(dest, dest_len, ConvertSingleChar(src[i]));
|
|
159
|
+
}
|
|
153
160
|
|
|
154
161
|
return success;
|
|
155
162
|
}
|
|
@@ -158,13 +165,13 @@ bool DoUTFConversion(const char16_t* src,
|
|
|
158
165
|
|
|
159
166
|
template <typename DestChar>
|
|
160
167
|
bool DoUTFConversion(const wchar_t* src,
|
|
161
|
-
|
|
168
|
+
size_t src_len,
|
|
162
169
|
DestChar* dest,
|
|
163
|
-
|
|
170
|
+
size_t* dest_len) {
|
|
164
171
|
bool success = true;
|
|
165
172
|
|
|
166
|
-
for (
|
|
167
|
-
|
|
173
|
+
for (size_t i = 0; i < src_len; ++i) {
|
|
174
|
+
base_icu::UChar32 code_point = src[i];
|
|
168
175
|
|
|
169
176
|
if (!IsValidCodepoint(code_point)) {
|
|
170
177
|
success = false;
|
|
@@ -197,12 +204,12 @@ bool UTFConversion(const InputString& src_str, DestString* dest_str) {
|
|
|
197
204
|
auto* dest = &(*dest_str)[0];
|
|
198
205
|
|
|
199
206
|
// ICU requires 32 bit numbers.
|
|
200
|
-
|
|
201
|
-
|
|
207
|
+
size_t src_len = src_str.length();
|
|
208
|
+
size_t dest_len = 0;
|
|
202
209
|
|
|
203
|
-
bool res = DoUTFConversion(src_str.data(),
|
|
210
|
+
bool res = DoUTFConversion(src_str.data(), src_len, dest, &dest_len);
|
|
204
211
|
|
|
205
|
-
dest_str->resize(
|
|
212
|
+
dest_str->resize(dest_len);
|
|
206
213
|
dest_str->shrink_to_fit();
|
|
207
214
|
|
|
208
215
|
return res;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#define BASE_TEMPLATE_UTIL_H_
|
|
7
7
|
|
|
8
8
|
#include <stddef.h>
|
|
9
|
+
|
|
9
10
|
#include <iosfwd>
|
|
10
11
|
#include <iterator>
|
|
11
12
|
#include <type_traits>
|
|
@@ -15,10 +16,6 @@
|
|
|
15
16
|
|
|
16
17
|
namespace gurl_base {
|
|
17
18
|
|
|
18
|
-
template <class T> struct is_non_const_reference : std::false_type {};
|
|
19
|
-
template <class T> struct is_non_const_reference<T&> : std::true_type {};
|
|
20
|
-
template <class T> struct is_non_const_reference<const T&> : std::false_type {};
|
|
21
|
-
|
|
22
19
|
namespace internal {
|
|
23
20
|
|
|
24
21
|
// Uses expression SFINAE to detect whether using operator<< would work.
|
|
@@ -59,35 +56,6 @@ struct priority_tag<0> {};
|
|
|
59
56
|
|
|
60
57
|
} // namespace internal
|
|
61
58
|
|
|
62
|
-
// gurl_base::in_place_t is an implementation of std::in_place_t from
|
|
63
|
-
// C++17. A tag type used to request in-place construction in template vararg
|
|
64
|
-
// constructors.
|
|
65
|
-
|
|
66
|
-
// Specification:
|
|
67
|
-
// https://en.cppreference.com/w/cpp/utility/in_place
|
|
68
|
-
struct in_place_t {};
|
|
69
|
-
constexpr in_place_t in_place = {};
|
|
70
|
-
|
|
71
|
-
// gurl_base::in_place_type_t is an implementation of std::in_place_type_t from
|
|
72
|
-
// C++17. A tag type used for in-place construction when the type to construct
|
|
73
|
-
// needs to be specified, such as with gurl_base::unique_any, designed to be a
|
|
74
|
-
// drop-in replacement.
|
|
75
|
-
|
|
76
|
-
// Specification:
|
|
77
|
-
// http://en.cppreference.com/w/cpp/utility/in_place
|
|
78
|
-
template <typename T>
|
|
79
|
-
struct in_place_type_t {};
|
|
80
|
-
|
|
81
|
-
template <typename T>
|
|
82
|
-
struct is_in_place_type_t {
|
|
83
|
-
static constexpr bool value = false;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
template <typename... Ts>
|
|
87
|
-
struct is_in_place_type_t<in_place_type_t<Ts...>> {
|
|
88
|
-
static constexpr bool value = true;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
59
|
namespace internal {
|
|
92
60
|
|
|
93
61
|
// The indirection with std::is_enum<T> is required, because instantiating
|
|
@@ -145,8 +113,28 @@ constexpr bool is_constant_evaluated() noexcept {
|
|
|
145
113
|
//
|
|
146
114
|
// Reference: https://wg21.link/readable.traits#2
|
|
147
115
|
template <typename Iter>
|
|
148
|
-
|
|
149
|
-
|
|
116
|
+
struct IterValueImpl {
|
|
117
|
+
using value_type = typename std::iterator_traits<Iter>::value_type;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
template <typename T, bool Cond = false>
|
|
121
|
+
struct IterValuePointerImpl {
|
|
122
|
+
// The `iterator_traits<T*>::value_type` member is not defined if T is not an
|
|
123
|
+
// object in C++20.
|
|
124
|
+
};
|
|
125
|
+
template <typename T>
|
|
126
|
+
struct IterValuePointerImpl<T*, true> {
|
|
127
|
+
using value_type = typename std::iterator_traits<T*>::value_type;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
template <typename T>
|
|
131
|
+
struct IterValueImpl<T*> {
|
|
132
|
+
using value_type =
|
|
133
|
+
typename IterValuePointerImpl<T*, std::is_object_v<T>>::value_type;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
template <typename Iter>
|
|
137
|
+
using iter_value_t = typename IterValueImpl<remove_cvref_t<Iter>>::value_type;
|
|
150
138
|
|
|
151
139
|
// Simplified implementation of C++20's std::iter_reference_t.
|
|
152
140
|
// As opposed to std::iter_reference_t, this implementation does not restrict
|