From 26f2c07d44d8c415b12253cb95b537ad1169db22 Mon Sep 17 00:00:00 2001 From: John Turpish Date: Mon, 4 Nov 2024 13:34:15 -0500 Subject: [PATCH] Some maintenance tasks --- .github/doc.sh | 3 +- .github/ut.sh | 3 +- .../chrome/browser/BUILD.gn.patch | 27 ++++ .../chrome/browser/about_flags.cc.patch | 38 +++++ ...me_autocomplete_scheme_classifier.cc.patch | 51 ++++++ .../chrome_content_browser_client.cc.patch | 81 ++++++++++ .../chrome/browser/flag-metadata.json.patch | 16 ++ .../chrome/browser/flag_descriptions.cc.patch | 16 ++ .../chrome/browser/flag_descriptions.h.patch | 24 +++ .../chrome/browser/ipfs_extra_parts.cc | 10 ++ .../chrome/browser/ipfs_extra_parts.h | 10 ++ .../chrome/browser/prefs/BUILD.gn.patch | 23 +++ .../browser/prefs/browser_prefs.cc.patch | 36 +++++ .../browser/shell_integration_mac.mm.patch | 13 ++ .../common/chrome_content_client.cc.patch | 17 ++ .../linux/common/desktop.template.patch | 13 ++ .../chrome/installer/util/shell_util.cc.patch | 20 +++ .../components/cbor/reader.cc.patch | 44 ++++++ .../components/cbor/reader.h.patch | 26 ++++ .../components/cbor/reader_unittest.cc.patch | 47 ++++++ .../components/cbor/values.cc.patch | 145 ++++++++++++++++++ .../components/cbor/values.h.patch | 79 ++++++++++ .../components/cbor/writer.cc.patch | 14 ++ .../components/cbor/writer_unittest.cc.patch | 36 +++++ .../clipboard_recent_content_generic.cc.patch | 13 ++ .../net/dns/dns_config_service_linux.cc.patch | 18 +++ .../weborigin/scheme_registry.cc.patch | 15 ++ .../132.0.6811.2/url/BUILD.gn.patch | 32 ++++ .../132.0.6811.2/url/url_canon.h.patch | 26 ++++ .../132.0.6811.2/url/url_canon_ipfs.cc | 54 +++++++ .../132.0.6811.2/url/url_util.cc.patch | 45 ++++++ .../chrome/browser/BUILD.gn.patch | 27 ++++ .../chrome/browser/about_flags.cc.patch | 38 +++++ ...me_autocomplete_scheme_classifier.cc.patch | 51 ++++++ .../chrome_content_browser_client.cc.patch | 81 ++++++++++ .../chrome/browser/flag-metadata.json.patch | 16 ++ .../chrome/browser/flag_descriptions.cc.patch | 16 ++ .../chrome/browser/flag_descriptions.h.patch | 24 +++ .../chrome/browser/ipfs_extra_parts.cc | 10 ++ .../chrome/browser/ipfs_extra_parts.h | 10 ++ .../chrome/browser/prefs/BUILD.gn.patch | 23 +++ .../browser/prefs/browser_prefs.cc.patch | 36 +++++ .../browser/shell_integration_mac.mm.patch | 13 ++ .../common/chrome_content_client.cc.patch | 17 ++ .../linux/common/desktop.template.patch | 13 ++ .../chrome/installer/util/shell_util.cc.patch | 20 +++ .../components/cbor/reader.cc.patch | 44 ++++++ .../components/cbor/reader.h.patch | 26 ++++ .../components/cbor/reader_unittest.cc.patch | 47 ++++++ .../components/cbor/values.cc.patch | 145 ++++++++++++++++++ .../components/cbor/values.h.patch | 79 ++++++++++ .../components/cbor/writer.cc.patch | 14 ++ .../components/cbor/writer_unittest.cc.patch | 36 +++++ .../clipboard_recent_content_generic.cc.patch | 13 ++ .../net/dns/dns_config_service_linux.cc.patch | 18 +++ .../weborigin/scheme_registry.cc.patch | 15 ++ .../132.0.6834.6/url/BUILD.gn.patch | 32 ++++ .../132.0.6834.6/url/url_canon.h.patch | 26 ++++ .../132.0.6834.6/url/url_canon_ipfs.cc | 54 +++++++ .../132.0.6834.6/url/url_util.cc.patch | 45 ++++++ .../chrome/browser/BUILD.gn.patch | 27 ++++ .../chrome/browser/about_flags.cc.patch | 38 +++++ ...me_autocomplete_scheme_classifier.cc.patch | 51 ++++++ .../chrome_content_browser_client.cc.patch | 81 ++++++++++ .../chrome/browser/flag-metadata.json.patch | 16 ++ .../chrome/browser/flag_descriptions.cc.patch | 16 ++ .../chrome/browser/flag_descriptions.h.patch | 24 +++ .../chrome/browser/ipfs_extra_parts.cc | 10 ++ .../chrome/browser/ipfs_extra_parts.h | 10 ++ .../chrome/browser/prefs/BUILD.gn.patch | 23 +++ .../browser/prefs/browser_prefs.cc.patch | 36 +++++ .../browser/shell_integration_mac.mm.patch | 13 ++ .../common/chrome_content_client.cc.patch | 17 ++ .../linux/common/desktop.template.patch | 13 ++ .../chrome/installer/util/shell_util.cc.patch | 20 +++ .../components/cbor/reader.cc.patch | 44 ++++++ .../components/cbor/reader.h.patch | 26 ++++ .../components/cbor/reader_unittest.cc.patch | 47 ++++++ .../components/cbor/values.cc.patch | 145 ++++++++++++++++++ .../components/cbor/values.h.patch | 79 ++++++++++ .../components/cbor/writer.cc.patch | 14 ++ .../components/cbor/writer_unittest.cc.patch | 36 +++++ .../clipboard_recent_content_generic.cc.patch | 13 ++ .../net/dns/dns_config_service_linux.cc.patch | 18 +++ .../weborigin/scheme_registry.cc.patch | 15 ++ .../133.0.6835.3/url/BUILD.gn.patch | 32 ++++ .../133.0.6835.3/url/url_canon.h.patch | 26 ++++ .../133.0.6835.3/url/url_canon_ipfs.cc | 54 +++++++ .../133.0.6835.3/url/url_util.cc.patch | 45 ++++++ cmake/CodeCoverage.cmake | 4 +- cmake/patch.py | 80 +++++----- cmake/pylint_thresh.py | 14 +- cmake/release.py | 11 +- library/include/ipfs_client/crypto/hasher.h | 5 +- .../ipfs_client/crypto/signature_verifier.h | 2 + library/include/ipfs_client/ctx/cbor_parser.h | 5 +- .../include/ipfs_client/ctx/dns_txt_lookup.h | 2 + .../include/ipfs_client/ctx/gateway_config.h | 4 + library/include/ipfs_client/ctx/http_api.h | 2 + library/include/ipfs_client/ctx/json_parser.h | 5 +- .../ipfs_client/ctx/null_cbor_parser.h | 2 + .../ipfs_client/gw/dnslink_requestor.h | 4 +- .../include/ipfs_client/gw/gateway_request.h | 9 +- .../ipfs_client/gw/inline_request_handler.h | 6 +- library/include/ipfs_client/gw/requestor.h | 3 + .../ipfs_client/gw/terminating_requestor.h | 3 +- .../include/ipfs_client/ipld/block_source.h | 2 + .../include/ipfs_client/ipld/dag_headers.h | 3 + library/include/ipfs_client/ipld/dag_node.h | 8 +- library/include/ipfs_client/ipld/link.h | 2 +- .../ipfs_client/ipld/resolution_state.h | 9 +- library/include/ipfs_client/ipns_record.h | 4 +- library/include/ipfs_client/multi_base.h | 2 +- library/include/ipfs_client/partition.h | 2 - library/include/ipfs_client/pb_dag.h | 4 + library/include/ipfs_client/response.h | 3 + library/include/vocab/raw_ptr.h | 2 + library/include/vocab/slash_delimited.h | 2 + library/src/ipfs_client/car.cc | 12 +- library/src/ipfs_client/cid.cc | 42 +++-- .../ipfs_client/crypto/openssl_sha2_256.cc | 6 +- .../src/ipfs_client/ctx/default_gateways.cc | 53 +++---- .../src/ipfs_client/ctx/null_http_provider.cc | 8 +- .../ctx/transitory_gateway_config.cc | 16 +- .../ipfs_client/gw/block_request_splitter.cc | 12 +- library/src/ipfs_client/gw/gateway_request.cc | 42 ++--- .../gw/gateway_request_unittest.cc | 5 +- library/src/ipfs_client/gw/gateway_state.cc | 18 ++- library/src/ipfs_client/gw/gateway_state.h | 6 +- .../ipfs_client/gw/inline_request_handler.cc | 4 +- .../gw/inline_request_handler_unittest.cc | 2 +- .../ipfs_client/gw/multi_gateway_requestor.h | 2 + .../src/ipfs_client/gw/providers_response.cc | 8 +- library/src/ipfs_client/ipfs_request.cc | 4 +- library/src/ipfs_client/ipld/block_source.cc | 17 +- library/src/ipfs_client/ipld/chunk.cc | 4 +- library/src/ipfs_client/ipld/chunk.h | 5 +- library/src/ipfs_client/ipld/dag_cbor_node.h | 2 + library/src/ipfs_client/ipld/dag_headers.cc | 4 +- .../src/ipfs_client/ipld/directory_shard.h | 3 + library/src/ipfs_client/ipld/link.cc | 5 +- library/src/ipfs_client/ipld/root.h | 8 +- library/src/ipfs_client/ipld/symlink.h | 6 + library/src/ipfs_client/ipns_names.cc | 25 +-- library/src/ipfs_client/pb_dag.cc | 6 +- library/src/ipfs_client/redirects.cc | 12 +- library/src/ipfs_client/redirects.h | 6 +- ...WB1zup8nMqK7MZ3z8p585DK2ymfhFtbDQnx2BSAhWC | 2 - ...KQaPhbXLCa7EA5nbRrjVt3XpZJKpWegqGFnbYucX98 | 2 - ...5kuaumzx5ymaqg46f3ij4afpquy4r553evbhmqbh44 | 1 - 150 files changed, 3305 insertions(+), 220 deletions(-) create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/BUILD.gn.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/about_flags.cc.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/chrome_content_browser_client.cc.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/flag-metadata.json.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.cc.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.h.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.cc create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.h create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/prefs/BUILD.gn.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/prefs/browser_prefs.cc.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/browser/shell_integration_mac.mm.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/common/chrome_content_client.cc.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/installer/linux/common/desktop.template.patch create mode 100644 chromium_edits/132.0.6811.2/chrome/installer/util/shell_util.cc.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/reader.cc.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/reader.h.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/reader_unittest.cc.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/values.cc.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/values.h.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/writer.cc.patch create mode 100644 chromium_edits/132.0.6811.2/components/cbor/writer_unittest.cc.patch create mode 100644 chromium_edits/132.0.6811.2/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch create mode 100644 chromium_edits/132.0.6811.2/net/dns/dns_config_service_linux.cc.patch create mode 100644 chromium_edits/132.0.6811.2/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch create mode 100644 chromium_edits/132.0.6811.2/url/BUILD.gn.patch create mode 100644 chromium_edits/132.0.6811.2/url/url_canon.h.patch create mode 100644 chromium_edits/132.0.6811.2/url/url_canon_ipfs.cc create mode 100644 chromium_edits/132.0.6811.2/url/url_util.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/BUILD.gn.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/about_flags.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/chrome_content_browser_client.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/flag-metadata.json.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.h.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.cc create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.h create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/prefs/BUILD.gn.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/prefs/browser_prefs.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/browser/shell_integration_mac.mm.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/common/chrome_content_client.cc.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/installer/linux/common/desktop.template.patch create mode 100644 chromium_edits/132.0.6834.6/chrome/installer/util/shell_util.cc.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/reader.cc.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/reader.h.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/reader_unittest.cc.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/values.cc.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/values.h.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/writer.cc.patch create mode 100644 chromium_edits/132.0.6834.6/components/cbor/writer_unittest.cc.patch create mode 100644 chromium_edits/132.0.6834.6/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch create mode 100644 chromium_edits/132.0.6834.6/net/dns/dns_config_service_linux.cc.patch create mode 100644 chromium_edits/132.0.6834.6/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch create mode 100644 chromium_edits/132.0.6834.6/url/BUILD.gn.patch create mode 100644 chromium_edits/132.0.6834.6/url/url_canon.h.patch create mode 100644 chromium_edits/132.0.6834.6/url/url_canon_ipfs.cc create mode 100644 chromium_edits/132.0.6834.6/url/url_util.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/BUILD.gn.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/about_flags.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/chrome_content_browser_client.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/flag-metadata.json.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.h.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.cc create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.h create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/prefs/BUILD.gn.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/prefs/browser_prefs.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/browser/shell_integration_mac.mm.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/common/chrome_content_client.cc.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/installer/linux/common/desktop.template.patch create mode 100644 chromium_edits/133.0.6835.3/chrome/installer/util/shell_util.cc.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/reader.cc.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/reader.h.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/reader_unittest.cc.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/values.cc.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/values.h.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/writer.cc.patch create mode 100644 chromium_edits/133.0.6835.3/components/cbor/writer_unittest.cc.patch create mode 100644 chromium_edits/133.0.6835.3/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch create mode 100644 chromium_edits/133.0.6835.3/net/dns/dns_config_service_linux.cc.patch create mode 100644 chromium_edits/133.0.6835.3/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch create mode 100644 chromium_edits/133.0.6835.3/url/BUILD.gn.patch create mode 100644 chromium_edits/133.0.6835.3/url/url_canon.h.patch create mode 100644 chromium_edits/133.0.6835.3/url/url_canon_ipfs.cc create mode 100644 chromium_edits/133.0.6835.3/url/url_util.cc.patch delete mode 100644 test_data/blocks/QmaMWB1zup8nMqK7MZ3z8p585DK2ymfhFtbDQnx2BSAhWC delete mode 100644 test_data/blocks/QmaiKQaPhbXLCa7EA5nbRrjVt3XpZJKpWegqGFnbYucX98 delete mode 100644 test_data/blocks/bafkreifckuj4pyhw5kuaumzx5ymaqg46f3ij4afpquy4r553evbhmqbh44 diff --git a/.github/doc.sh b/.github/doc.sh index 6120b4cf..8a8d4571 100755 --- a/.github/doc.sh +++ b/.github/doc.sh @@ -1,6 +1,7 @@ #!/bin/bash -ex -export here="$(dirname "${0}")" +here="$(dirname "${0}")" +export here source "${here}/ubuntu-deps.env" sudo apt install doxygen diff --git a/.github/ut.sh b/.github/ut.sh index ea2a6a39..db9563d8 100755 --- a/.github/ut.sh +++ b/.github/ut.sh @@ -1,6 +1,7 @@ #!/bin/bash -ex -export here="$(dirname "${0}")" +here="$(dirname "${0}")" +export here source "${here}/ubuntu-deps.env" conan profile detect diff --git a/chromium_edits/132.0.6811.2/chrome/browser/BUILD.gn.patch b/chromium_edits/132.0.6811.2/chrome/browser/BUILD.gn.patch new file mode 100644 index 00000000..8bc6042e --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/BUILD.gn.patch @@ -0,0 +1,27 @@ +diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn +index e317244c17821..4fdd153858654 100644 +--- a/chrome/browser/BUILD.gn ++++ b/chrome/browser/BUILD.gn +@@ -42,6 +42,7 @@ import("//sandbox/features.gni") + import("//services/screen_ai/buildflags/features.gni") + import("//testing/libfuzzer/fuzzer_test.gni") + import("//third_party/blink/public/public_features.gni") ++import("//third_party/ipfs_client/args.gni") + import("//third_party/protobuf/proto_library.gni") + import("//third_party/webrtc/webrtc.gni") + import("//third_party/widevine/cdm/widevine.gni") +@@ -2502,6 +2503,14 @@ static_library("browser") { + "//ui/webui", + ] + ++ if (enable_ipfs) { ++ sources += [ ++ "ipfs_extra_parts.cc", ++ "ipfs_extra_parts.h", ++ ] ++ deps += [ "//components/ipfs" ] ++ } ++ + # Platforms that have a network diagnostics dialog. All others fall through + # to the stub which is not implemented. + if (is_chromeos_ash) { diff --git a/chromium_edits/132.0.6811.2/chrome/browser/about_flags.cc.patch b/chromium_edits/132.0.6811.2/chrome/browser/about_flags.cc.patch new file mode 100644 index 00000000..12b8e4c7 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/about_flags.cc.patch @@ -0,0 +1,38 @@ +diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc +index 01ee570f4540c..eb152633d156c 100644 +--- a/chrome/browser/about_flags.cc ++++ b/chrome/browser/about_flags.cc +@@ -229,6 +229,7 @@ + #include "third_party/blink/public/common/features_generated.h" + #include "third_party/blink/public/common/forcedark/forcedark_switches.h" + #include "third_party/blink/public/common/switches.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "ui/accessibility/accessibility_features.h" + #include "ui/accessibility/accessibility_switches.h" + #include "ui/base/ozone_buildflags.h" +@@ -330,6 +331,10 @@ + #include "extensions/common/switches.h" + #endif // BUILDFLAG(ENABLE_EXTENSIONS) + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#endif ++ + #if BUILDFLAG(ENABLE_PDF) + #include "pdf/pdf_features.h" + #endif +@@ -9578,6 +9583,14 @@ const FeatureEntry kFeatureEntries[] = { + flag_descriptions::kOmitCorsClientCertDescription, kOsAll, + FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)}, + ++#if BUILDFLAG(ENABLE_IPFS) ++ {"enable-ipfs", ++ flag_descriptions::kEnableIpfsName, ++ flag_descriptions::kEnableIpfsDescription, ++ kOsMac | kOsWin | kOsLinux,//TODO: These are the only variants currently getting built, but that is not likely to remain the case ++ FEATURE_VALUE_TYPE(ipfs::kEnableIpfs)}, ++#endif ++ + {"use-idna2008-non-transitional", + flag_descriptions::kUseIDNA2008NonTransitionalName, + flag_descriptions::kUseIDNA2008NonTransitionalDescription, kOsAll, diff --git a/chromium_edits/132.0.6811.2/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch b/chromium_edits/132.0.6811.2/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch new file mode 100644 index 00000000..f9965a24 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch @@ -0,0 +1,51 @@ +diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +index 9f234a2a7d41d..a9378ca80dc1e 100644 +--- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc ++++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +@@ -13,6 +13,7 @@ + #include "chrome/browser/profiles/profile_io_data.h" + #include "components/custom_handlers/protocol_handler_registry.h" + #include "content/public/common/url_constants.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "url/url_util.h" + + #if BUILDFLAG(IS_ANDROID) +@@ -20,6 +21,11 @@ + #include "chrome/browser/ui/android/omnibox/jni_headers/ChromeAutocompleteSchemeClassifier_jni.h" + #endif + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#endif ++ ++ + #if BUILDFLAG(IS_ANDROID) + static jlong + JNI_ChromeAutocompleteSchemeClassifier_CreateAutocompleteClassifier( +@@ -53,12 +59,20 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( + if (scheme.empty()) { + return metrics::OmniboxInputType::EMPTY; + } +- if (base::IsStringASCII(scheme) && +- (ProfileIOData::IsHandledProtocol(scheme) || +- base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || +- base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || +- base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme))) { +- return metrics::OmniboxInputType::URL; ++ if (base::IsStringASCII(scheme)) { ++ if (ProfileIOData::IsHandledProtocol(scheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme)) { ++ return metrics::OmniboxInputType::URL; ++ } ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs) && ++ (base::EqualsCaseInsensitiveASCII(scheme, "ipfs") || base::EqualsCaseInsensitiveASCII(scheme, "ipns")) ++ ) { ++ return metrics::OmniboxInputType::URL; ++ } ++#endif + } + + // Also check for schemes registered via registerProtocolHandler(), which diff --git a/chromium_edits/132.0.6811.2/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/132.0.6811.2/chrome/browser/chrome_content_browser_client.cc.patch new file mode 100644 index 00000000..97d758a6 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/chrome_content_browser_client.cc.patch @@ -0,0 +1,81 @@ +diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc +index 2fc837a03f4ba..898946f836b6c 100644 +--- a/chrome/browser/chrome_content_browser_client.cc ++++ b/chrome/browser/chrome_content_browser_client.cc +@@ -409,6 +409,7 @@ + #include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h" + #include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h" + #include "third_party/blink/public/public_buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "third_party/widevine/cdm/buildflags.h" + #include "ui/base/clipboard/clipboard_format_type.h" + #include "ui/base/l10n/l10n_util.h" +@@ -536,6 +537,13 @@ + #include "chrome/browser/chrome_browser_main_posix.h" + #endif + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "chrome/browser/ipfs_extra_parts.h" ++#include "components/ipfs/interceptor.h" ++#include "components/ipfs/ipfs_features.h" ++#include "components/ipfs/url_loader_factory.h" ++#endif ++ + #if !BUILDFLAG(IS_ANDROID) + #include "chrome/browser/digital_credentials/digital_identity_provider_desktop.h" + #include "chrome/browser/preloading/preview/preview_navigation_throttle.h" +@@ -1877,6 +1885,11 @@ ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) { + main_parts->AddParts( + std::make_unique()); + ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ main_parts->AddParts(std::make_unique()); ++ } ++#endif + return main_parts; + } + +@@ -6562,12 +6575,29 @@ void ChromeContentBrowserClient:: + const std::optional& request_initiator_origin, + NonNetworkURLLoaderFactoryMap* factories) { + #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ +- !BUILDFLAG(IS_ANDROID) ++ !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) + content::RenderFrameHost* frame_host = + RenderFrameHost::FromID(render_process_id, render_frame_id); + WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); + #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ + // !BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(ENABLE_IPFS) ++ if (!web_contents) { ++ VLOG(2) << "No web contents, can't register url loader factory."; ++ } else if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); ++ auto* context = web_contents->GetBrowserContext(); ++ ipfs::IpfsURLLoaderFactory::Create( ++ factories, ++ context, ++ default_factory, ++ GetSystemNetworkContext(), ++ Profile::FromBrowserContext(context)->GetPrefs() ++ ); ++ } else { ++ LOG(INFO) << "IPFS disabled."; ++ } ++#endif // BUILDFLAG(ENABLE_IPFS) + + #if BUILDFLAG(IS_CHROMEOS_ASH) + if (web_contents) { +@@ -6715,6 +6745,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( + scoped_refptr navigation_response_task_runner) { + std::vector> + interceptors; ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ interceptors.push_back(std::make_unique(g_browser_process->system_network_context_manager()->GetURLLoaderFactory(), GetSystemNetworkContext())); ++ } ++#endif + #if BUILDFLAG(ENABLE_OFFLINE_PAGES) + interceptors.push_back( + std::make_unique( diff --git a/chromium_edits/132.0.6811.2/chrome/browser/flag-metadata.json.patch b/chromium_edits/132.0.6811.2/chrome/browser/flag-metadata.json.patch new file mode 100644 index 00000000..2e187f45 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/flag-metadata.json.patch @@ -0,0 +1,16 @@ +diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json +index c99018a18cf15..c66f6d93de12b 100644 +--- a/chrome/browser/flag-metadata.json ++++ b/chrome/browser/flag-metadata.json +@@ -3321,6 +3321,11 @@ + "owners": [ "adamta@google.com", "bling-get-set-up@google.com" ], + "expiry_milestone": 140 + }, ++ { ++ "name": "enable-ipfs", ++ "owners": [ "//components/ipfs/OWNERS" ], ++ "expiry_milestone": 150 ++ }, + { + "name": "enable-isolated-sandboxed-iframes", + "owners": [ "wjmaclean@chromium.org", "alexmos@chromium.org", "creis@chromium.org" ], diff --git a/chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.cc.patch b/chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.cc.patch new file mode 100644 index 00000000..28202165 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.cc.patch @@ -0,0 +1,16 @@ +diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc +index 25244ee7bc775..810d8916ae193 100644 +--- a/chrome/browser/flag_descriptions.cc ++++ b/chrome/browser/flag_descriptions.cc +@@ -360,6 +360,11 @@ const char kEnableBookmarksSelectedTypeOnSigninForTestingDescription[] = + "sync-enable-bookmarks-in-transport-mode. Enables the bookmarks " + "UserSelectableType upon sign-in"; + ++#if BUILDFLAG(ENABLE_IPFS) ++extern const char kEnableIpfsName[] = "Enable IPFS"; ++extern const char kEnableIpfsDescription[] = "Enable ipfs:// and ipns:// URLs"; ++#endif ++ + const char kPreloadingOnPerformancePageName[] = + "Preloading Settings on Performance Page"; + const char kPreloadingOnPerformancePageDescription[] = diff --git a/chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.h.patch b/chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.h.patch new file mode 100644 index 00000000..66c5cfa8 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/flag_descriptions.h.patch @@ -0,0 +1,24 @@ +diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h +index 56ccd6fa2a12c..4604fdf9633c8 100644 +--- a/chrome/browser/flag_descriptions.h ++++ b/chrome/browser/flag_descriptions.h +@@ -25,6 +25,7 @@ + #include "printing/buildflags/buildflags.h" + #include "skia/buildflags.h" + #include "third_party/blink/public/common/buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + + // This file declares strings used in chrome://flags. These messages are not + // translated, because instead of end-users they target Chromium developers and +@@ -218,6 +219,11 @@ extern const char kEnableBenchmarkingChoiceMatchFieldTrialTestingConfig[]; + extern const char kEnableBookmarksSelectedTypeOnSigninForTestingName[]; + extern const char kEnableBookmarksSelectedTypeOnSigninForTestingDescription[]; + ++#if BUILDFLAG(ENABLE_IPFS) ++extern const char kEnableIpfsName[]; ++extern const char kEnableIpfsDescription[]; ++#endif ++ + extern const char kFontationsFontBackendName[]; + extern const char kFontationsFontBackendDescription[]; + diff --git a/chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.cc b/chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.cc new file mode 100644 index 00000000..90d2596f --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.cc @@ -0,0 +1,10 @@ +#include "ipfs_extra_parts.h" + +#include "profiles/profile.h" + +#include + +void IpfsExtraParts::PostProfileInit(Profile* profile, bool /* is_initial_profile */ ) { + DCHECK(profile); + ipfs::InterRequestState::CreateForBrowserContext(profile, profile->GetPrefs()); +} diff --git a/chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.h b/chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.h new file mode 100644 index 00000000..2059c437 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/ipfs_extra_parts.h @@ -0,0 +1,10 @@ +#ifndef IPFS_EXTRA_PART_H_ +#define IPFS_EXTRA_PART_H_ + +#include + +class IpfsExtraParts : public ChromeBrowserMainExtraParts { + void PostProfileInit(Profile* profile, bool is_initial_profile) override; +}; + +#endif // IPFS_EXTRA_PART_H_ diff --git a/chromium_edits/132.0.6811.2/chrome/browser/prefs/BUILD.gn.patch b/chromium_edits/132.0.6811.2/chrome/browser/prefs/BUILD.gn.patch new file mode 100644 index 00000000..9d74fa1b --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/prefs/BUILD.gn.patch @@ -0,0 +1,23 @@ +diff --git a/chrome/browser/prefs/BUILD.gn b/chrome/browser/prefs/BUILD.gn +index 6af45fd10c466..ec2f3915c9be2 100644 +--- a/chrome/browser/prefs/BUILD.gn ++++ b/chrome/browser/prefs/BUILD.gn +@@ -7,6 +7,7 @@ import("//components/safe_browsing/buildflags.gni") + import("//components/services/on_device_translation/buildflags/features.gni") + import("//extensions/buildflags/buildflags.gni") + import("//pdf/features.gni") ++import("//third_party/ipfs_client/args.gni") + + assert(is_win || is_mac || is_linux || is_chromeos || is_android) + +@@ -125,7 +126,9 @@ source_set("impl") { + "//services/preferences/public/mojom", + "//services/preferences/tracked", + ] +- ++ if (enable_ipfs) { ++ deps += [ "//components/ipfs" ] ++ } + if (is_chromeos) { + deps += [ + "//ash", diff --git a/chromium_edits/132.0.6811.2/chrome/browser/prefs/browser_prefs.cc.patch b/chromium_edits/132.0.6811.2/chrome/browser/prefs/browser_prefs.cc.patch new file mode 100644 index 00000000..0ae0c45f --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/prefs/browser_prefs.cc.patch @@ -0,0 +1,36 @@ +diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc +index faf4d343375b5..474c4d7dba247 100644 +--- a/chrome/browser/prefs/browser_prefs.cc ++++ b/chrome/browser/prefs/browser_prefs.cc +@@ -197,6 +197,7 @@ + #include "ppapi/buildflags/buildflags.h" + #include "printing/buildflags/buildflags.h" + #include "rlz/buildflags/buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + + #if BUILDFLAG(ENABLE_BACKGROUND_MODE) + #include "chrome/browser/background/background_mode_manager.h" +@@ -245,6 +246,11 @@ + #include "chrome/browser/pdf/pdf_pref_names.h" + #endif // BUILDFLAG(ENABLE_PDF) + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#include "components/ipfs/preferences.h" ++#endif ++ + #if BUILDFLAG(IS_ANDROID) + #include "chrome/browser/accessibility/accessibility_prefs/android/accessibility_prefs_controller.h" + #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h" +@@ -2007,6 +2013,11 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, + IncognitoModePrefs::RegisterProfilePrefs(registry); + invalidation::PerUserTopicSubscriptionManager::RegisterProfilePrefs(registry); + invalidation::InvalidatorRegistrarWithMemory::RegisterProfilePrefs(registry); ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ ipfs::RegisterPreferences(registry); ++ } ++#endif + language::LanguagePrefs::RegisterProfilePrefs(registry); + login_detection::prefs::RegisterProfilePrefs(registry); + lookalikes::RegisterProfilePrefs(registry); diff --git a/chromium_edits/132.0.6811.2/chrome/browser/shell_integration_mac.mm.patch b/chromium_edits/132.0.6811.2/chrome/browser/shell_integration_mac.mm.patch new file mode 100644 index 00000000..220e2546 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/browser/shell_integration_mac.mm.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm +index c6bb768979453..c0d0abb9c78f3 100644 +--- a/chrome/browser/shell_integration_mac.mm ++++ b/chrome/browser/shell_integration_mac.mm +@@ -79,6 +79,8 @@ bool SetAsDefaultBrowser() { + if (LSSetDefaultHandlerForURLScheme(CFSTR("https"), identifier) != noErr) { + return false; + } ++ LSSetDefaultHandlerForURLScheme(CFSTR("ipfs"), identifier); ++ LSSetDefaultHandlerForURLScheme(CFSTR("ipns"), identifier); + if (LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesViewer, + identifier) != noErr) { + return false; diff --git a/chromium_edits/132.0.6811.2/chrome/common/chrome_content_client.cc.patch b/chromium_edits/132.0.6811.2/chrome/common/chrome_content_client.cc.patch new file mode 100644 index 00000000..4eab52e0 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/common/chrome_content_client.cc.patch @@ -0,0 +1,17 @@ +diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc +index 10d6227ace408..c823662dbf5bf 100644 +--- a/chrome/common/chrome_content_client.cc ++++ b/chrome/common/chrome_content_client.cc +@@ -314,6 +314,12 @@ void ChromeContentClient::AddAdditionalSchemes(Schemes* schemes) { + #if BUILDFLAG(IS_ANDROID) + schemes->local_schemes.push_back(url::kContentScheme); + #endif ++ for ( const char* ip_s : {"ipfs", "ipns"} ) { ++ schemes->standard_schemes.push_back(ip_s); ++ schemes->cors_enabled_schemes.push_back(ip_s); ++ schemes->secure_schemes.push_back(ip_s); ++ schemes->csp_bypassing_schemes.push_back(ip_s); ++ } + } + + std::u16string ChromeContentClient::GetLocalizedString(int message_id) { diff --git a/chromium_edits/132.0.6811.2/chrome/installer/linux/common/desktop.template.patch b/chromium_edits/132.0.6811.2/chrome/installer/linux/common/desktop.template.patch new file mode 100644 index 00000000..dcd9460b --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/installer/linux/common/desktop.template.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/installer/linux/common/desktop.template b/chrome/installer/linux/common/desktop.template +index 2eb13ee1aba46..9af65726bde89 100644 +--- a/chrome/installer/linux/common/desktop.template ++++ b/chrome/installer/linux/common/desktop.template +@@ -111,7 +111,7 @@ Terminal=false + Icon=@@PACKAGE@@ + Type=Application + Categories=Network;WebBrowser; +-MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https; ++MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ipfs;x-scheme-handler/ipns; + Actions=new-window;new-private-window; + + [Desktop Action new-window] diff --git a/chromium_edits/132.0.6811.2/chrome/installer/util/shell_util.cc.patch b/chromium_edits/132.0.6811.2/chrome/installer/util/shell_util.cc.patch new file mode 100644 index 00000000..fccdad80 --- /dev/null +++ b/chromium_edits/132.0.6811.2/chrome/installer/util/shell_util.cc.patch @@ -0,0 +1,20 @@ +diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc +index c087d1c02bca4..382a36b9cd800 100644 +--- a/chrome/installer/util/shell_util.cc ++++ b/chrome/installer/util/shell_util.cc +@@ -1545,11 +1545,12 @@ const wchar_t* ShellUtil::kDefaultFileAssociations[] = { + const wchar_t* ShellUtil::kPotentialFileAssociations[] = { + L".htm", L".html", L".mhtml", L".pdf", L".shtml", + L".svg", L".xht", L".xhtml", L".webp", nullptr}; +-const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"http", L"https", +- nullptr}; ++const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = { ++ L"http", L"https", L"ipfs", L"ipns", nullptr}; + const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = { + L"http", L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", +- L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", nullptr}; ++ L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", L"ipfs", ++ L"ipns", nullptr}; + const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; + const wchar_t* ShellUtil::kRegApplication = L"\\Application"; + const wchar_t* ShellUtil::kRegAppUserModelId = L"AppUserModelId"; diff --git a/chromium_edits/132.0.6811.2/components/cbor/reader.cc.patch b/chromium_edits/132.0.6811.2/components/cbor/reader.cc.patch new file mode 100644 index 00000000..de3d0b36 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/reader.cc.patch @@ -0,0 +1,44 @@ +diff --git a/components/cbor/reader.cc b/components/cbor/reader.cc +index 24d852e45f2ba..4dfec34caabd7 100644 +--- a/components/cbor/reader.cc ++++ b/components/cbor/reader.cc +@@ -22,7 +22,7 @@ + namespace cbor { + + namespace constants { +-const char kUnsupportedMajorType[] = "Unsupported major type."; ++const char kUnsupportedMajorType[] = "Unsupported major type operation."; + } + + namespace { +@@ -156,7 +156,11 @@ std::optional Reader::DecodeCompleteDataItem(const Config& config, + case Value::Type::FLOAT_VALUE: + // Floating point values also go here since they are also type 7. + return DecodeToSimpleValueOrFloat(*header, config); +- case Value::Type::TAG: // We explicitly don't support TAG. ++ case Value::Type::TAG: ++ if (config.parse_tags) { ++ return ReadTagContent(*header, config, max_nesting_level); ++ } ++ break; + case Value::Type::NONE: + case Value::Type::INVALID_UTF8: + break; +@@ -347,6 +351,17 @@ std::optional Reader::ReadByteStringContent( + return Value(std::move(cbor_byte_string)); + } + ++std::optional Reader::ReadTagContent( ++ const Reader::DataItemHeader& header, ++ const Config& config, ++ int max_nesting_level) { ++ auto tagged_content = DecodeCompleteDataItem(config, max_nesting_level); ++ if (tagged_content.has_value()) { ++ tagged_content.value().SetTag(header.value); ++ } ++ return tagged_content; ++} ++ + std::optional Reader::ReadArrayContent( + const Reader::DataItemHeader& header, + const Config& config, diff --git a/chromium_edits/132.0.6811.2/components/cbor/reader.h.patch b/chromium_edits/132.0.6811.2/components/cbor/reader.h.patch new file mode 100644 index 00000000..2dbc0534 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/reader.h.patch @@ -0,0 +1,26 @@ +diff --git a/components/cbor/reader.h b/components/cbor/reader.h +index 5f11ba48ba494..d4c9c489da4b6 100644 +--- a/components/cbor/reader.h ++++ b/components/cbor/reader.h +@@ -131,6 +131,11 @@ class CBOR_EXPORT Reader { + // during decoding will set raise the `UNSUPPORTED_FLOATING_POINT_VALUE` + // error. + bool allow_floating_point = false; ++ ++ // If the parser encounters a TAG element, should it be parsed out and ++ // the tag value saved (true), or should the entire node and its content ++ // be discarded (false) ++ bool parse_tags = false; + }; + + Reader(const Reader&) = delete; +@@ -205,6 +210,9 @@ class CBOR_EXPORT Reader { + std::optional ReadMapContent(const DataItemHeader& header, + const Config& config, + int max_nesting_level); ++ std::optional ReadTagContent(const DataItemHeader& header, ++ const Config& config, ++ int max_nesting_level); + std::optional ReadByte(); + std::optional> ReadBytes(uint64_t num_bytes); + bool IsKeyInOrder(const Value& new_key, diff --git a/chromium_edits/132.0.6811.2/components/cbor/reader_unittest.cc.patch b/chromium_edits/132.0.6811.2/components/cbor/reader_unittest.cc.patch new file mode 100644 index 00000000..150e0c73 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/reader_unittest.cc.patch @@ -0,0 +1,47 @@ +diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc +index e5c02ceea3402..f26b8e77f6da3 100644 +--- a/components/cbor/reader_unittest.cc ++++ b/components/cbor/reader_unittest.cc +@@ -1449,5 +1449,42 @@ TEST(CBORReaderTest, AllowInvalidUTF8) { + EXPECT_FALSE(cbor); + EXPECT_EQ(Reader::DecoderError::INVALID_UTF8, error); + } ++TEST(CBORReaderTest, RejectsTagUnderDefaultConfig) { ++ static const uint8_t kTaggedCbor[] = { ++ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, ++ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, ++ 0x9d, 0xf6, 0x3a, 0x36, 0x5b ++ }; ++ Reader::Config config; ++ auto cbor = Reader::Read(kTaggedCbor, config); ++ EXPECT_FALSE(cbor.has_value()); ++} ++TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { ++ static const uint8_t kTaggedCbor[] = { ++ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, ++ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, ++ 0x9d, 0xf6, 0x3a, 0x36, 0x5b ++ }; ++ Reader::Config config; ++ config.parse_tags = true; ++ auto cbor = Reader::Read(kTaggedCbor, config); ++ EXPECT_TRUE(cbor.has_value()); ++ auto& v = cbor.value(); ++ EXPECT_TRUE(v.has_tag()); ++ EXPECT_EQ(v.GetTag(),42UL); ++ EXPECT_TRUE(v.is_bytestring()); ++ EXPECT_EQ(v.type(), Value::Type::BYTE_STRING); ++ auto& bytes = v.GetBytestring(); ++ EXPECT_EQ(bytes.size(), 37UL); ++ EXPECT_EQ(bytes.at(0), 0x00);//identity multibase (e.g. not base-encoded, bytes are themselves) ++ EXPECT_EQ(bytes.at(1), 0x01);//CID version 1 ++ EXPECT_EQ(bytes.at(2), 0x71);//codec = dag-cbor ++ EXPECT_EQ(bytes.at(3), 0x12);//multihash = 18 = sha2-256 ++ EXPECT_EQ(bytes.at(4), 0x20);//hash length = 32 bytes ++ EXPECT_EQ(bytes.at(5), 0x69);//first byte of hash digest ++ EXPECT_EQ(bytes.at(36),0x5b);//last byte of hash digest ++} + + } // namespace cbor diff --git a/chromium_edits/132.0.6811.2/components/cbor/values.cc.patch b/chromium_edits/132.0.6811.2/components/cbor/values.cc.patch new file mode 100644 index 00000000..890571d8 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/values.cc.patch @@ -0,0 +1,145 @@ +diff --git a/components/cbor/values.cc b/components/cbor/values.cc +index c43c6d8265220..337ca908c813f 100644 +--- a/components/cbor/values.cc ++++ b/components/cbor/values.cc +@@ -64,32 +64,34 @@ Value::Value(Type type) : type_(type) { + NOTREACHED_IN_MIGRATION(); + } + +-Value::Value(SimpleValue in_simple) +- : type_(Type::SIMPLE_VALUE), simple_value_(in_simple) { ++Value::Value(SimpleValue in_simple, uint64_t tag) ++ : type_(Type::SIMPLE_VALUE), simple_value_(in_simple), tag_(tag) { + CHECK(static_cast(in_simple) >= 20 && static_cast(in_simple) <= 23); + } + +-Value::Value(bool boolean_value) : type_(Type::SIMPLE_VALUE) { ++Value::Value(bool boolean_value, uint64_t tag) : type_(Type::SIMPLE_VALUE), tag_(tag) { + simple_value_ = boolean_value ? Value::SimpleValue::TRUE_VALUE + : Value::SimpleValue::FALSE_VALUE; + } + +-Value::Value(double float_value) +- : type_(Type::FLOAT_VALUE), float_value_(float_value) {} ++Value::Value(double float_value, uint64_t tag) ++ : type_(Type::FLOAT_VALUE), float_value_(float_value), tag_(tag) {} + +-Value::Value(int integer_value) +- : Value(base::checked_cast(integer_value)) {} ++Value::Value(int integer_value, uint64_t tag) ++ : Value(base::checked_cast(integer_value), tag) {} + +-Value::Value(int64_t integer_value) : integer_value_(integer_value) { ++Value::Value(int64_t integer_value, uint64_t tag) : integer_value_(integer_value), tag_(tag) { + type_ = integer_value >= 0 ? Type::UNSIGNED : Type::NEGATIVE; + } + +-Value::Value(base::span in_bytes) ++Value::Value(base::span in_bytes, uint64_t tag) + : type_(Type::BYTE_STRING), +- bytestring_value_(in_bytes.begin(), in_bytes.end()) {} ++ bytestring_value_(in_bytes.begin(), in_bytes.end()), ++ tag_(tag) ++ {} + +-Value::Value(base::span in_bytes, Type type) +- : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()) { ++Value::Value(base::span in_bytes, Type type, uint64_t tag) ++ : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()), tag_(tag) { + DCHECK(type_ == Type::BYTE_STRING || type_ == Type::INVALID_UTF8); + } + +@@ -115,7 +117,8 @@ Value::Value(std::string&& in_string, Type type) noexcept : type_(type) { + } + } + +-Value::Value(std::string_view in_string, Type type) : type_(type) { ++Value::Value(std::string_view in_string, Type type, uint64_t tag) ++: type_(type), tag_(tag) { + switch (type_) { + case Type::STRING: + new (&string_value_) std::string(); +@@ -131,16 +134,18 @@ Value::Value(std::string_view in_string, Type type) : type_(type) { + } + } + +-Value::Value(const ArrayValue& in_array) : type_(Type::ARRAY), array_value_() { ++Value::Value(const ArrayValue& in_array, uint64_t tag) ++: type_(Type::ARRAY), array_value_(), tag_(tag) { + array_value_.reserve(in_array.size()); + for (const auto& val : in_array) + array_value_.emplace_back(val.Clone()); + } + +-Value::Value(ArrayValue&& in_array) noexcept +- : type_(Type::ARRAY), array_value_(std::move(in_array)) {} ++Value::Value(ArrayValue&& in_array, uint64_t tag) noexcept ++ : type_(Type::ARRAY), array_value_(std::move(in_array)), tag_(tag) {} + +-Value::Value(const MapValue& in_map) : type_(Type::MAP), map_value_() { ++Value::Value(const MapValue& in_map, uint64_t tag) ++: type_(Type::MAP), map_value_(), tag_(tag) { + map_value_.reserve(in_map.size()); + for (const auto& it : in_map) + map_value_.emplace_hint(map_value_.end(), it.first.Clone(), +@@ -166,31 +171,36 @@ Value Value::Clone() const { + case Type::NONE: + return Value(); + case Type::INVALID_UTF8: +- return Value(bytestring_value_, Type::INVALID_UTF8); ++ return Value(bytestring_value_, Type::INVALID_UTF8, tag_); + case Type::UNSIGNED: + case Type::NEGATIVE: +- return Value(integer_value_); ++ return Value(integer_value_, tag_); + case Type::BYTE_STRING: +- return Value(bytestring_value_); ++ return Value(bytestring_value_, tag_); + case Type::STRING: +- return Value(string_value_); ++ return Value(string_value_, Type::STRING, tag_); + case Type::ARRAY: +- return Value(array_value_); ++ return Value(array_value_, tag_); + case Type::MAP: +- return Value(map_value_); ++ return Value(map_value_, tag_); + case Type::TAG: + NOTREACHED_IN_MIGRATION() << constants::kUnsupportedMajorType; + return Value(); + case Type::SIMPLE_VALUE: +- return Value(simple_value_); ++ return Value(simple_value_, tag_); + case Type::FLOAT_VALUE: +- return Value(float_value_); ++ return Value(float_value_, tag_); + } + + NOTREACHED_IN_MIGRATION(); + return Value(); + } + ++Value& Value::SetTag(uint64_t tag) noexcept { ++ tag_ = tag; ++ return *this; ++} ++ + Value::SimpleValue Value::GetSimpleValue() const { + CHECK(is_simple()); + return simple_value_; +@@ -256,9 +266,14 @@ const Value::BinaryValue& Value::GetInvalidUTF8() const { + return bytestring_value_; + } + ++uint64_t Value::GetTag() const { ++ CHECK(has_tag()); ++ return tag_; ++} ++ + void Value::InternalMoveConstructFrom(Value&& that) { + type_ = that.type_; +- ++ tag_ = that.tag_; + switch (type_) { + case Type::UNSIGNED: + case Type::NEGATIVE: diff --git a/chromium_edits/132.0.6811.2/components/cbor/values.h.patch b/chromium_edits/132.0.6811.2/components/cbor/values.h.patch new file mode 100644 index 00000000..5556e8c5 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/values.h.patch @@ -0,0 +1,79 @@ +diff --git a/components/cbor/values.h b/components/cbor/values.h +index d55369f1a71bf..7dabb368c51d6 100644 +--- a/components/cbor/values.h ++++ b/components/cbor/values.h +@@ -125,28 +125,29 @@ class CBOR_EXPORT Value { + + explicit Value(Type type); + +- explicit Value(SimpleValue in_simple); +- explicit Value(bool boolean_value); +- explicit Value(double in_float); ++ explicit Value(SimpleValue in_simple, uint64_t tag = NO_TAG); ++ explicit Value(bool boolean_value, uint64_t tag = NO_TAG); ++ explicit Value(double in_float, uint64_t tag = NO_TAG); + +- explicit Value(int integer_value); +- explicit Value(int64_t integer_value); ++ explicit Value(int integer_value, uint64_t tag = NO_TAG); ++ explicit Value(int64_t integer_value, uint64_t tag = NO_TAG); + explicit Value(uint64_t integer_value) = delete; + +- explicit Value(base::span in_bytes); ++ explicit Value(base::span in_bytes, uint64_t tag = NO_TAG); + explicit Value(BinaryValue&& in_bytes) noexcept; + + explicit Value(const char* in_string, Type type = Type::STRING); + explicit Value(std::string&& in_string, Type type = Type::STRING) noexcept; +- explicit Value(std::string_view in_string, Type type = Type::STRING); ++ explicit Value(std::string_view in_string, Type type = Type::STRING, uint64_t tag = NO_TAG); + +- explicit Value(const ArrayValue& in_array); +- explicit Value(ArrayValue&& in_array) noexcept; ++ explicit Value(const ArrayValue& in_array, uint64_t tag = NO_TAG); ++ explicit Value(ArrayValue&& in_array, uint64_t tag = NO_TAG) noexcept; + +- explicit Value(const MapValue& in_map); ++ explicit Value(const MapValue& in_map, uint64_t tag = NO_TAG); + explicit Value(MapValue&& in_map) noexcept; + + Value& operator=(Value&& that) noexcept; ++ Value& SetTag(uint64_t) noexcept; + + Value(const Value&) = delete; + Value& operator=(const Value&) = delete; +@@ -177,6 +178,7 @@ class CBOR_EXPORT Value { + bool is_string() const { return type() == Type::STRING; } + bool is_array() const { return type() == Type::ARRAY; } + bool is_map() const { return type() == Type::MAP; } ++ bool has_tag() const { return tag_ != NO_TAG; } + + // These will all fatally assert if the type doesn't match. + SimpleValue GetSimpleValue() const; +@@ -192,12 +194,13 @@ class CBOR_EXPORT Value { + const ArrayValue& GetArray() const; + const MapValue& GetMap() const; + const BinaryValue& GetInvalidUTF8() const; ++ uint64_t GetTag() const; + + private: + friend class Reader; + // This constructor allows INVALID_UTF8 values to be created, which only + // |Reader| and InvalidUTF8StringValueForTesting() may do. +- Value(base::span in_bytes, Type type); ++ Value(base::span in_bytes, Type type, uint64_t tag = NO_TAG); + + Type type_; + +@@ -211,6 +214,11 @@ class CBOR_EXPORT Value { + MapValue map_value_; + }; + ++ //This value specified as Invalid, ++ // used here to represent absence of TAG ++ constexpr static uint64_t NO_TAG = 0xFFFF; ++ uint64_t tag_ = NO_TAG; ++ + void InternalMoveConstructFrom(Value&& that); + void InternalCleanup(); + }; diff --git a/chromium_edits/132.0.6811.2/components/cbor/writer.cc.patch b/chromium_edits/132.0.6811.2/components/cbor/writer.cc.patch new file mode 100644 index 00000000..1950e174 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/writer.cc.patch @@ -0,0 +1,14 @@ +diff --git a/components/cbor/writer.cc b/components/cbor/writer.cc +index c4bfcfb602949..b92885a30971c 100644 +--- a/components/cbor/writer.cc ++++ b/components/cbor/writer.cc +@@ -47,6 +47,9 @@ bool Writer::EncodeCBOR(const Value& node, + if (max_nesting_level < 0) + return false; + ++ if (node.has_tag()) { ++ StartItem(Value::Type::TAG, node.GetTag()); ++ } + switch (node.type()) { + case Value::Type::NONE: { + StartItem(Value::Type::BYTE_STRING, 0); diff --git a/chromium_edits/132.0.6811.2/components/cbor/writer_unittest.cc.patch b/chromium_edits/132.0.6811.2/components/cbor/writer_unittest.cc.patch new file mode 100644 index 00000000..1acf5f7f --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/cbor/writer_unittest.cc.patch @@ -0,0 +1,36 @@ +diff --git a/components/cbor/writer_unittest.cc b/components/cbor/writer_unittest.cc +index ee11e7cb86712..b8942f1829a37 100644 +--- a/components/cbor/writer_unittest.cc ++++ b/components/cbor/writer_unittest.cc +@@ -523,4 +523,31 @@ TEST(CBORWriterTest, OverlyNestedCBOR) { + EXPECT_FALSE(Writer::Write(Value(map), 4).has_value()); + } + ++TEST(CBORWriterTest, CanWriteTag) { ++ std::array content{ ++ 0x00, 0x01, 0x71, 0x12, 0x20, ++ 0x69, 0xea, 0x07, 0x40, 0xf9, ++ 0x80, 0x7a, 0x28, 0xf4, 0xd9, ++ 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, ++ 0x07, 0x2c, 0x90, 0x26, 0x6a, ++ 0xb3, 0xe7, 0x9d, 0xf6, 0x3a, ++ 0x36, 0x5b ++ }; ++ Value to_write(content); ++ to_write.SetTag(42); ++ auto result = Writer::Write(to_write); ++ EXPECT_TRUE(result.has_value()); ++ auto& bytes = result.value(); ++ EXPECT_EQ(bytes.size(), 41UL); ++ EXPECT_EQ(bytes.at(0), 0xd8); ++ EXPECT_EQ(bytes.at(1), 0x2a); ++ EXPECT_EQ(bytes.at(2), 0x58); ++ EXPECT_EQ(bytes.at(3), 0x25); ++ for (auto i = 0UL; i < content.size(); ++i) { ++ ASSERT_LT(i + 4UL, bytes.size()); ++ ASSERT_EQ(content.at(i), bytes.at(i+4UL)); ++ } ++} ++ + } // namespace cbor diff --git a/chromium_edits/132.0.6811.2/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch b/chromium_edits/132.0.6811.2/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch new file mode 100644 index 00000000..ee376ce1 --- /dev/null +++ b/chromium_edits/132.0.6811.2/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch @@ -0,0 +1,13 @@ +diff --git a/components/open_from_clipboard/clipboard_recent_content_generic.cc b/components/open_from_clipboard/clipboard_recent_content_generic.cc +index 3683fadcc0914..440d4be132e5c 100644 +--- a/components/open_from_clipboard/clipboard_recent_content_generic.cc ++++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc +@@ -20,7 +20,7 @@ + namespace { + // Schemes appropriate for suggestion by ClipboardRecentContent. + const char* kAuthorizedSchemes[] = { +- url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, ++ url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, "ipfs", "ipns" + // TODO(mpearson): add support for chrome:// URLs. Right now the scheme + // for that lives in content and is accessible via + // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme diff --git a/chromium_edits/132.0.6811.2/net/dns/dns_config_service_linux.cc.patch b/chromium_edits/132.0.6811.2/net/dns/dns_config_service_linux.cc.patch new file mode 100644 index 00000000..fd7227a5 --- /dev/null +++ b/chromium_edits/132.0.6811.2/net/dns/dns_config_service_linux.cc.patch @@ -0,0 +1,18 @@ +diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc +index 7aaf9fa5b0b78..5a9f5b5a70dd9 100644 +--- a/net/dns/dns_config_service_linux.cc ++++ b/net/dns/dns_config_service_linux.cc +@@ -276,11 +276,11 @@ bool IsNsswitchConfigCompatible( + // Ignore any entries after `kDns` because Chrome will fallback to the + // system resolver if a result was not found in DNS. + return true; +- ++ case NsswitchReader::Service::kResolve: ++ break; + case NsswitchReader::Service::kMdns: + case NsswitchReader::Service::kMdns4: + case NsswitchReader::Service::kMdns6: +- case NsswitchReader::Service::kResolve: + case NsswitchReader::Service::kNis: + RecordIncompatibleNsswitchReason( + IncompatibleNsswitchReason::kIncompatibleService, diff --git a/chromium_edits/132.0.6811.2/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch b/chromium_edits/132.0.6811.2/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch new file mode 100644 index 00000000..663fe49e --- /dev/null +++ b/chromium_edits/132.0.6811.2/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch @@ -0,0 +1,15 @@ +diff --git a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc +index e1bc209c337c5..6fbac29fcddfd 100644 +--- a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc ++++ b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc +@@ -68,8 +68,8 @@ class URLSchemesRegistry final { + // is considered secure. Additional checks are performed to ensure that + // other http pages are filtered out. + service_worker_schemes({"http", "https"}), +- fetch_api_schemes({"http", "https"}), +- allowed_in_referrer_schemes({"http", "https"}) { ++ fetch_api_schemes({"http", "https", "ipfs", "ipns"}), ++ allowed_in_referrer_schemes({"http", "https", "ipfs", "ipns"}) { + for (auto& scheme : url::GetCorsEnabledSchemes()) + cors_enabled_schemes.insert(scheme.c_str()); + for (auto& scheme : url::GetCSPBypassingSchemes()) { diff --git a/chromium_edits/132.0.6811.2/url/BUILD.gn.patch b/chromium_edits/132.0.6811.2/url/BUILD.gn.patch new file mode 100644 index 00000000..be4bfca8 --- /dev/null +++ b/chromium_edits/132.0.6811.2/url/BUILD.gn.patch @@ -0,0 +1,32 @@ +diff --git a/url/BUILD.gn b/url/BUILD.gn +index f22b73bc29f06..df36977322ec7 100644 +--- a/url/BUILD.gn ++++ b/url/BUILD.gn +@@ -5,6 +5,7 @@ + import("//build/buildflag_header.gni") + import("//testing/libfuzzer/fuzzer_test.gni") + import("//testing/test.gni") ++import("//third_party/ipfs_client/args.gni") + import("features.gni") + + import("//build/config/cronet/config.gni") +@@ -67,6 +68,7 @@ component("url") { + public_deps = [ + "//base", + "//build:robolectric_buildflags", ++ "//third_party/ipfs_client:ipfs_buildflags", + ] + + configs += [ "//build/config/compiler:wexit_time_destructors" ] +@@ -89,6 +91,11 @@ component("url") { + public_configs = [ "//third_party/jdk" ] + } + ++ if (enable_ipfs) { ++ sources += [ "url_canon_ipfs.cc" ] ++ deps += [ "//third_party/ipfs_client:ipfs_client" ] ++ } ++ + if (is_win) { + # Don't conflict with Windows' "url.dll". + output_name = "url_lib" diff --git a/chromium_edits/132.0.6811.2/url/url_canon.h.patch b/chromium_edits/132.0.6811.2/url/url_canon.h.patch new file mode 100644 index 00000000..0f667205 --- /dev/null +++ b/chromium_edits/132.0.6811.2/url/url_canon.h.patch @@ -0,0 +1,26 @@ +diff --git a/url/url_canon.h b/url/url_canon.h +index 3b84d686ba0f0..c18cb750c6de1 100644 +--- a/url/url_canon.h ++++ b/url/url_canon.h +@@ -855,6 +855,21 @@ bool CanonicalizeMailtoURL(const char16_t* spec, + CanonOutput* output, + Parsed* new_parsed); + ++COMPONENT_EXPORT(URL) ++bool CanonicalizeIpfsURL(std::string_view spec, ++ const Parsed& parsed, ++ SchemeType scheme_type, ++ CharsetConverter* query_converter, ++ CanonOutput* output, ++ Parsed* new_parsed); ++COMPONENT_EXPORT(URL) ++bool CanonicalizeIpfsURL(std::basic_string_view spec, ++ const Parsed& parsed, ++ SchemeType scheme_type, ++ CharsetConverter* query_converter, ++ CanonOutput* output, ++ Parsed* new_parsed); ++ + // Part replacer -------------------------------------------------------------- + + // Internal structure used for storing separate strings for each component. diff --git a/chromium_edits/132.0.6811.2/url/url_canon_ipfs.cc b/chromium_edits/132.0.6811.2/url/url_canon_ipfs.cc new file mode 100644 index 00000000..e40732ee --- /dev/null +++ b/chromium_edits/132.0.6811.2/url/url_canon_ipfs.cc @@ -0,0 +1,54 @@ +#include "url_canon_internal.h" + +#include +#include + +#include + +bool url::CanonicalizeIpfsURL(std::string_view spec, + const Parsed& parsed, + SchemeType scheme_type, + CharsetConverter* charset_converter, + CanonOutput* output, + Parsed* output_parsed) { + if (spec.size() < 1) { + return false; + } + if ( parsed.host.len < 1 ) { + return false; + } + auto cid_str = spec.substr( parsed.host.begin, static_cast(parsed.host.len) ); + auto cid = ipfs::Cid(cid_str); + if ( !cid.valid() ) { + cid = ipfs::id_cid::forText( std::string{cid_str} + " is not a valid CID." ); + } + auto as_str = cid.to_string(); + if ( as_str.empty() ) { + return false; + } + std::string stdurl{ spec.substr(0UL, static_cast(parsed.host.begin)) }; + stdurl.append( as_str ); + spec.remove_prefix(parsed.host.end()); + stdurl.append(spec); + auto len = static_cast(stdurl.size()); + Parsed parsed_input; + ParseStandardURL(stdurl.data(), len, &parsed_input); + return CanonicalizeStandardURL( + stdurl.data(), + parsed_input, + scheme_type, + charset_converter, + output, output_parsed + ); +} +bool url::CanonicalizeIpfsURL(std::basic_string_view spec, + const Parsed& parsed, + SchemeType scheme_type, + CharsetConverter* query_converter, + CanonOutput* output, + Parsed* new_parsed) { + RawCanonOutput<2048> as8; + ConvertUTF16ToUTF8(spec.data(), spec.size(), &as8); + return CanonicalizeIpfsURL({as8.data(), as8.length()}, parsed, scheme_type, + query_converter, output, new_parsed); +} diff --git a/chromium_edits/132.0.6811.2/url/url_util.cc.patch b/chromium_edits/132.0.6811.2/url/url_util.cc.patch new file mode 100644 index 00000000..8d22ec10 --- /dev/null +++ b/chromium_edits/132.0.6811.2/url/url_util.cc.patch @@ -0,0 +1,45 @@ +diff --git a/url/url_util.cc b/url/url_util.cc +index 67c4c5f3ce124..b268390940561 100644 +--- a/url/url_util.cc ++++ b/url/url_util.cc +@@ -76,6 +76,8 @@ struct SchemeRegistry { + std::vector referrer_schemes = { + {kHttpsScheme, SCHEME_WITH_HOST_PORT_AND_USER_INFORMATION}, + {kHttpScheme, SCHEME_WITH_HOST_PORT_AND_USER_INFORMATION}, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that do not trigger mixed content warning. +@@ -84,6 +86,8 @@ struct SchemeRegistry { + kWssScheme, + kDataScheme, + kAboutScheme, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that normal pages cannot link to or access (i.e., with the same +@@ -105,6 +109,8 @@ struct SchemeRegistry { + kHttpsScheme, + kHttpScheme, + kDataScheme, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that can be used by web to store data (local storage, etc). +@@ -308,7 +314,12 @@ bool DoCanonicalize(const CHAR* spec, + success = CanonicalizeFileSystemURL( + spec, ParseFileSystemURL(std::basic_string_view(spec, spec_len)), + charset_converter, output, output_parsed); +- ++ } else if (DoCompareSchemeComponent(spec, scheme, "ipfs")) { ++ auto spec_view = std::basic_string_view(spec, spec_len); ++ // Switch multibase away from case-sensitive ones before continuing canonicalization. ++ auto parsed_input = ParseStandardURL(spec_view); ++ success = CanonicalizeIpfsURL(spec_view, parsed_input, scheme_type, ++ charset_converter, output, output_parsed); + } else if (DoIsStandard(spec, scheme, &scheme_type)) { + // All "normal" URLs. + success = CanonicalizeStandardURL( diff --git a/chromium_edits/132.0.6834.6/chrome/browser/BUILD.gn.patch b/chromium_edits/132.0.6834.6/chrome/browser/BUILD.gn.patch new file mode 100644 index 00000000..44ee3776 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/BUILD.gn.patch @@ -0,0 +1,27 @@ +diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn +index 1a136cdeb8aea..2061b64b57f6f 100644 +--- a/chrome/browser/BUILD.gn ++++ b/chrome/browser/BUILD.gn +@@ -42,6 +42,7 @@ import("//sandbox/features.gni") + import("//services/screen_ai/buildflags/features.gni") + import("//testing/libfuzzer/fuzzer_test.gni") + import("//third_party/blink/public/public_features.gni") ++import("//third_party/ipfs_client/args.gni") + import("//third_party/protobuf/proto_library.gni") + import("//third_party/webrtc/webrtc.gni") + import("//third_party/widevine/cdm/widevine.gni") +@@ -2496,6 +2497,14 @@ static_library("browser") { + "//ui/webui", + ] + ++ if (enable_ipfs) { ++ sources += [ ++ "ipfs_extra_parts.cc", ++ "ipfs_extra_parts.h", ++ ] ++ deps += [ "//components/ipfs" ] ++ } ++ + # Platforms that have a network diagnostics dialog. All others fall through + # to the stub which is not implemented. + if (is_chromeos_ash) { diff --git a/chromium_edits/132.0.6834.6/chrome/browser/about_flags.cc.patch b/chromium_edits/132.0.6834.6/chrome/browser/about_flags.cc.patch new file mode 100644 index 00000000..74a2c692 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/about_flags.cc.patch @@ -0,0 +1,38 @@ +diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc +index d36cb1aa0d1a3..9c7f3e4adecb1 100644 +--- a/chrome/browser/about_flags.cc ++++ b/chrome/browser/about_flags.cc +@@ -231,6 +231,7 @@ + #include "third_party/blink/public/common/features_generated.h" + #include "third_party/blink/public/common/forcedark/forcedark_switches.h" + #include "third_party/blink/public/common/switches.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "ui/accessibility/accessibility_features.h" + #include "ui/accessibility/accessibility_switches.h" + #include "ui/base/ozone_buildflags.h" +@@ -332,6 +333,10 @@ + #include "extensions/common/switches.h" + #endif // BUILDFLAG(ENABLE_EXTENSIONS) + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#endif ++ + #if BUILDFLAG(ENABLE_PDF) + #include "pdf/pdf_features.h" + #endif +@@ -9661,6 +9666,14 @@ const FeatureEntry kFeatureEntries[] = { + flag_descriptions::kOmitCorsClientCertDescription, kOsAll, + FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)}, + ++#if BUILDFLAG(ENABLE_IPFS) ++ {"enable-ipfs", ++ flag_descriptions::kEnableIpfsName, ++ flag_descriptions::kEnableIpfsDescription, ++ kOsMac | kOsWin | kOsLinux,//TODO: These are the only variants currently getting built, but that is not likely to remain the case ++ FEATURE_VALUE_TYPE(ipfs::kEnableIpfs)}, ++#endif ++ + {"use-idna2008-non-transitional", + flag_descriptions::kUseIDNA2008NonTransitionalName, + flag_descriptions::kUseIDNA2008NonTransitionalDescription, kOsAll, diff --git a/chromium_edits/132.0.6834.6/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch b/chromium_edits/132.0.6834.6/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch new file mode 100644 index 00000000..2bbe24d6 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch @@ -0,0 +1,51 @@ +diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +index a4a306c760f44..35dc091513f49 100644 +--- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc ++++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +@@ -13,6 +13,7 @@ + #include "chrome/browser/profiles/profile_io_data.h" + #include "components/custom_handlers/protocol_handler_registry.h" + #include "content/public/common/url_constants.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "url/url_util.h" + + #if BUILDFLAG(IS_ANDROID) +@@ -20,6 +21,11 @@ + #include "chrome/browser/ui/android/omnibox/jni_headers/ChromeAutocompleteSchemeClassifier_jni.h" + #endif + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#endif ++ ++ + #if BUILDFLAG(IS_ANDROID) + static jlong + JNI_ChromeAutocompleteSchemeClassifier_CreateAutocompleteClassifier( +@@ -53,12 +59,20 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( + if (scheme.empty()) { + return metrics::OmniboxInputType::EMPTY; + } +- if (base::IsStringASCII(scheme) && +- (ProfileIOData::IsHandledProtocol(scheme) || +- base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || +- base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || +- base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme))) { +- return metrics::OmniboxInputType::URL; ++ if (base::IsStringASCII(scheme)) { ++ if (ProfileIOData::IsHandledProtocol(scheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme)) { ++ return metrics::OmniboxInputType::URL; ++ } ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs) && ++ (base::EqualsCaseInsensitiveASCII(scheme, "ipfs") || base::EqualsCaseInsensitiveASCII(scheme, "ipns")) ++ ) { ++ return metrics::OmniboxInputType::URL; ++ } ++#endif + } + + // Also check for schemes registered via registerProtocolHandler(), which diff --git a/chromium_edits/132.0.6834.6/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/132.0.6834.6/chrome/browser/chrome_content_browser_client.cc.patch new file mode 100644 index 00000000..328ff34c --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/chrome_content_browser_client.cc.patch @@ -0,0 +1,81 @@ +diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc +index 25b5c325f612d..254f41914236e 100644 +--- a/chrome/browser/chrome_content_browser_client.cc ++++ b/chrome/browser/chrome_content_browser_client.cc +@@ -409,6 +409,7 @@ + #include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h" + #include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h" + #include "third_party/blink/public/public_buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "third_party/widevine/cdm/buildflags.h" + #include "ui/base/clipboard/clipboard_format_type.h" + #include "ui/base/l10n/l10n_util.h" +@@ -535,6 +536,13 @@ + #include "chrome/browser/chrome_browser_main_posix.h" + #endif + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "chrome/browser/ipfs_extra_parts.h" ++#include "components/ipfs/interceptor.h" ++#include "components/ipfs/ipfs_features.h" ++#include "components/ipfs/url_loader_factory.h" ++#endif ++ + #if !BUILDFLAG(IS_ANDROID) + #include "chrome/browser/digital_credentials/digital_identity_provider_desktop.h" + #include "chrome/browser/preloading/preview/preview_navigation_throttle.h" +@@ -1876,6 +1884,11 @@ ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) { + main_parts->AddParts( + std::make_unique()); + ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ main_parts->AddParts(std::make_unique()); ++ } ++#endif + return main_parts; + } + +@@ -6573,12 +6586,29 @@ void ChromeContentBrowserClient:: + const std::optional& request_initiator_origin, + NonNetworkURLLoaderFactoryMap* factories) { + #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ +- !BUILDFLAG(IS_ANDROID) ++ !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) + content::RenderFrameHost* frame_host = + RenderFrameHost::FromID(render_process_id, render_frame_id); + WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); + #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ + // !BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(ENABLE_IPFS) ++ if (!web_contents) { ++ VLOG(2) << "No web contents, can't register url loader factory."; ++ } else if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); ++ auto* context = web_contents->GetBrowserContext(); ++ ipfs::IpfsURLLoaderFactory::Create( ++ factories, ++ context, ++ default_factory, ++ GetSystemNetworkContext(), ++ Profile::FromBrowserContext(context)->GetPrefs() ++ ); ++ } else { ++ LOG(INFO) << "IPFS disabled."; ++ } ++#endif // BUILDFLAG(ENABLE_IPFS) + + #if BUILDFLAG(IS_CHROMEOS_ASH) + if (web_contents) { +@@ -6726,6 +6756,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( + scoped_refptr navigation_response_task_runner) { + std::vector> + interceptors; ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ interceptors.push_back(std::make_unique(g_browser_process->system_network_context_manager()->GetURLLoaderFactory(), GetSystemNetworkContext())); ++ } ++#endif + #if BUILDFLAG(ENABLE_OFFLINE_PAGES) + interceptors.push_back( + std::make_unique( diff --git a/chromium_edits/132.0.6834.6/chrome/browser/flag-metadata.json.patch b/chromium_edits/132.0.6834.6/chrome/browser/flag-metadata.json.patch new file mode 100644 index 00000000..f5635d61 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/flag-metadata.json.patch @@ -0,0 +1,16 @@ +diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json +index ca4b11fb52e57..f55ece13f76a4 100644 +--- a/chrome/browser/flag-metadata.json ++++ b/chrome/browser/flag-metadata.json +@@ -3316,6 +3316,11 @@ + "owners": [ "adamta@google.com", "bling-get-set-up@google.com" ], + "expiry_milestone": 140 + }, ++ { ++ "name": "enable-ipfs", ++ "owners": [ "//components/ipfs/OWNERS" ], ++ "expiry_milestone": 150 ++ }, + { + "name": "enable-isolated-sandboxed-iframes", + "owners": [ "wjmaclean@chromium.org", "alexmos@chromium.org", "creis@chromium.org" ], diff --git a/chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.cc.patch b/chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.cc.patch new file mode 100644 index 00000000..4b6ec55f --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.cc.patch @@ -0,0 +1,16 @@ +diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc +index 9bf703cccfc84..d6cae8f0ad65a 100644 +--- a/chrome/browser/flag_descriptions.cc ++++ b/chrome/browser/flag_descriptions.cc +@@ -367,6 +367,11 @@ const char kEnableBookmarksSelectedTypeOnSigninForTestingDescription[] = + "sync-enable-bookmarks-in-transport-mode. Enables the bookmarks " + "UserSelectableType upon sign-in"; + ++#if BUILDFLAG(ENABLE_IPFS) ++extern const char kEnableIpfsName[] = "Enable IPFS"; ++extern const char kEnableIpfsDescription[] = "Enable ipfs:// and ipns:// URLs"; ++#endif ++ + const char kPreloadingOnPerformancePageName[] = + "Preloading Settings on Performance Page"; + const char kPreloadingOnPerformancePageDescription[] = diff --git a/chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.h.patch b/chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.h.patch new file mode 100644 index 00000000..d1878a01 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/flag_descriptions.h.patch @@ -0,0 +1,24 @@ +diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h +index 94aeeae2bb425..508a7e811587d 100644 +--- a/chrome/browser/flag_descriptions.h ++++ b/chrome/browser/flag_descriptions.h +@@ -25,6 +25,7 @@ + #include "printing/buildflags/buildflags.h" + #include "skia/buildflags.h" + #include "third_party/blink/public/common/buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + + // This file declares strings used in chrome://flags. These messages are not + // translated, because instead of end-users they target Chromium developers and +@@ -223,6 +224,11 @@ extern const char kEnableBenchmarkingChoiceMatchFieldTrialTestingConfig[]; + extern const char kEnableBookmarksSelectedTypeOnSigninForTestingName[]; + extern const char kEnableBookmarksSelectedTypeOnSigninForTestingDescription[]; + ++#if BUILDFLAG(ENABLE_IPFS) ++extern const char kEnableIpfsName[]; ++extern const char kEnableIpfsDescription[]; ++#endif ++ + extern const char kFontationsFontBackendName[]; + extern const char kFontationsFontBackendDescription[]; + diff --git a/chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.cc b/chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.cc new file mode 100644 index 00000000..90d2596f --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.cc @@ -0,0 +1,10 @@ +#include "ipfs_extra_parts.h" + +#include "profiles/profile.h" + +#include + +void IpfsExtraParts::PostProfileInit(Profile* profile, bool /* is_initial_profile */ ) { + DCHECK(profile); + ipfs::InterRequestState::CreateForBrowserContext(profile, profile->GetPrefs()); +} diff --git a/chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.h b/chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.h new file mode 100644 index 00000000..2059c437 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/ipfs_extra_parts.h @@ -0,0 +1,10 @@ +#ifndef IPFS_EXTRA_PART_H_ +#define IPFS_EXTRA_PART_H_ + +#include + +class IpfsExtraParts : public ChromeBrowserMainExtraParts { + void PostProfileInit(Profile* profile, bool is_initial_profile) override; +}; + +#endif // IPFS_EXTRA_PART_H_ diff --git a/chromium_edits/132.0.6834.6/chrome/browser/prefs/BUILD.gn.patch b/chromium_edits/132.0.6834.6/chrome/browser/prefs/BUILD.gn.patch new file mode 100644 index 00000000..a867c5b9 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/prefs/BUILD.gn.patch @@ -0,0 +1,23 @@ +diff --git a/chrome/browser/prefs/BUILD.gn b/chrome/browser/prefs/BUILD.gn +index 156a2f34d89f5..7f17b564e36df 100644 +--- a/chrome/browser/prefs/BUILD.gn ++++ b/chrome/browser/prefs/BUILD.gn +@@ -7,6 +7,7 @@ import("//components/safe_browsing/buildflags.gni") + import("//components/services/on_device_translation/buildflags/features.gni") + import("//extensions/buildflags/buildflags.gni") + import("//pdf/features.gni") ++import("//third_party/ipfs_client/args.gni") + + assert(is_win || is_mac || is_linux || is_chromeos || is_android) + +@@ -126,7 +127,9 @@ source_set("impl") { + "//services/preferences/public/mojom", + "//services/preferences/tracked", + ] +- ++ if (enable_ipfs) { ++ deps += [ "//components/ipfs" ] ++ } + if (is_chromeos) { + deps += [ + "//ash", diff --git a/chromium_edits/132.0.6834.6/chrome/browser/prefs/browser_prefs.cc.patch b/chromium_edits/132.0.6834.6/chrome/browser/prefs/browser_prefs.cc.patch new file mode 100644 index 00000000..23de7d29 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/prefs/browser_prefs.cc.patch @@ -0,0 +1,36 @@ +diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc +index a6002045888c4..d7434b3851b22 100644 +--- a/chrome/browser/prefs/browser_prefs.cc ++++ b/chrome/browser/prefs/browser_prefs.cc +@@ -197,6 +197,7 @@ + #include "ppapi/buildflags/buildflags.h" + #include "printing/buildflags/buildflags.h" + #include "rlz/buildflags/buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + + #if BUILDFLAG(ENABLE_BACKGROUND_MODE) + #include "chrome/browser/background/background_mode_manager.h" +@@ -245,6 +246,11 @@ + #include "chrome/browser/pdf/pdf_pref_names.h" + #endif // BUILDFLAG(ENABLE_PDF) + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#include "components/ipfs/preferences.h" ++#endif ++ + #if BUILDFLAG(IS_ANDROID) + #include "chrome/browser/accessibility/accessibility_prefs/android/accessibility_prefs_controller.h" + #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h" +@@ -1933,6 +1939,11 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, + IncognitoModePrefs::RegisterProfilePrefs(registry); + invalidation::PerUserTopicSubscriptionManager::RegisterProfilePrefs(registry); + invalidation::InvalidatorRegistrarWithMemory::RegisterProfilePrefs(registry); ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ ipfs::RegisterPreferences(registry); ++ } ++#endif + language::LanguagePrefs::RegisterProfilePrefs(registry); + login_detection::prefs::RegisterProfilePrefs(registry); + lookalikes::RegisterProfilePrefs(registry); diff --git a/chromium_edits/132.0.6834.6/chrome/browser/shell_integration_mac.mm.patch b/chromium_edits/132.0.6834.6/chrome/browser/shell_integration_mac.mm.patch new file mode 100644 index 00000000..220e2546 --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/browser/shell_integration_mac.mm.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm +index c6bb768979453..c0d0abb9c78f3 100644 +--- a/chrome/browser/shell_integration_mac.mm ++++ b/chrome/browser/shell_integration_mac.mm +@@ -79,6 +79,8 @@ bool SetAsDefaultBrowser() { + if (LSSetDefaultHandlerForURLScheme(CFSTR("https"), identifier) != noErr) { + return false; + } ++ LSSetDefaultHandlerForURLScheme(CFSTR("ipfs"), identifier); ++ LSSetDefaultHandlerForURLScheme(CFSTR("ipns"), identifier); + if (LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesViewer, + identifier) != noErr) { + return false; diff --git a/chromium_edits/132.0.6834.6/chrome/common/chrome_content_client.cc.patch b/chromium_edits/132.0.6834.6/chrome/common/chrome_content_client.cc.patch new file mode 100644 index 00000000..40bc3abe --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/common/chrome_content_client.cc.patch @@ -0,0 +1,17 @@ +diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc +index aa28db3f8aaa3..252958825aa2a 100644 +--- a/chrome/common/chrome_content_client.cc ++++ b/chrome/common/chrome_content_client.cc +@@ -314,6 +314,12 @@ void ChromeContentClient::AddAdditionalSchemes(Schemes* schemes) { + #if BUILDFLAG(IS_ANDROID) + schemes->local_schemes.push_back(url::kContentScheme); + #endif ++ for ( const char* ip_s : {"ipfs", "ipns"} ) { ++ schemes->standard_schemes.push_back(ip_s); ++ schemes->cors_enabled_schemes.push_back(ip_s); ++ schemes->secure_schemes.push_back(ip_s); ++ schemes->csp_bypassing_schemes.push_back(ip_s); ++ } + } + + std::u16string ChromeContentClient::GetLocalizedString(int message_id) { diff --git a/chromium_edits/132.0.6834.6/chrome/installer/linux/common/desktop.template.patch b/chromium_edits/132.0.6834.6/chrome/installer/linux/common/desktop.template.patch new file mode 100644 index 00000000..dcd9460b --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/installer/linux/common/desktop.template.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/installer/linux/common/desktop.template b/chrome/installer/linux/common/desktop.template +index 2eb13ee1aba46..9af65726bde89 100644 +--- a/chrome/installer/linux/common/desktop.template ++++ b/chrome/installer/linux/common/desktop.template +@@ -111,7 +111,7 @@ Terminal=false + Icon=@@PACKAGE@@ + Type=Application + Categories=Network;WebBrowser; +-MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https; ++MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ipfs;x-scheme-handler/ipns; + Actions=new-window;new-private-window; + + [Desktop Action new-window] diff --git a/chromium_edits/132.0.6834.6/chrome/installer/util/shell_util.cc.patch b/chromium_edits/132.0.6834.6/chrome/installer/util/shell_util.cc.patch new file mode 100644 index 00000000..38f9123c --- /dev/null +++ b/chromium_edits/132.0.6834.6/chrome/installer/util/shell_util.cc.patch @@ -0,0 +1,20 @@ +diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc +index 0f9ca6c1674c2..2e5c8f11b28d8 100644 +--- a/chrome/installer/util/shell_util.cc ++++ b/chrome/installer/util/shell_util.cc +@@ -1538,11 +1538,12 @@ const wchar_t* ShellUtil::kDefaultFileAssociations[] = { + const wchar_t* ShellUtil::kPotentialFileAssociations[] = { + L".htm", L".html", L".mhtml", L".pdf", L".shtml", + L".svg", L".xht", L".xhtml", L".webp", nullptr}; +-const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"http", L"https", +- nullptr}; ++const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = { ++ L"http", L"https", L"ipfs", L"ipns", nullptr}; + const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = { + L"http", L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", +- L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", nullptr}; ++ L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", L"ipfs", ++ L"ipns", nullptr}; + const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; + const wchar_t* ShellUtil::kRegApplication = L"\\Application"; + const wchar_t* ShellUtil::kRegAppUserModelId = L"AppUserModelId"; diff --git a/chromium_edits/132.0.6834.6/components/cbor/reader.cc.patch b/chromium_edits/132.0.6834.6/components/cbor/reader.cc.patch new file mode 100644 index 00000000..de3d0b36 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/reader.cc.patch @@ -0,0 +1,44 @@ +diff --git a/components/cbor/reader.cc b/components/cbor/reader.cc +index 24d852e45f2ba..4dfec34caabd7 100644 +--- a/components/cbor/reader.cc ++++ b/components/cbor/reader.cc +@@ -22,7 +22,7 @@ + namespace cbor { + + namespace constants { +-const char kUnsupportedMajorType[] = "Unsupported major type."; ++const char kUnsupportedMajorType[] = "Unsupported major type operation."; + } + + namespace { +@@ -156,7 +156,11 @@ std::optional Reader::DecodeCompleteDataItem(const Config& config, + case Value::Type::FLOAT_VALUE: + // Floating point values also go here since they are also type 7. + return DecodeToSimpleValueOrFloat(*header, config); +- case Value::Type::TAG: // We explicitly don't support TAG. ++ case Value::Type::TAG: ++ if (config.parse_tags) { ++ return ReadTagContent(*header, config, max_nesting_level); ++ } ++ break; + case Value::Type::NONE: + case Value::Type::INVALID_UTF8: + break; +@@ -347,6 +351,17 @@ std::optional Reader::ReadByteStringContent( + return Value(std::move(cbor_byte_string)); + } + ++std::optional Reader::ReadTagContent( ++ const Reader::DataItemHeader& header, ++ const Config& config, ++ int max_nesting_level) { ++ auto tagged_content = DecodeCompleteDataItem(config, max_nesting_level); ++ if (tagged_content.has_value()) { ++ tagged_content.value().SetTag(header.value); ++ } ++ return tagged_content; ++} ++ + std::optional Reader::ReadArrayContent( + const Reader::DataItemHeader& header, + const Config& config, diff --git a/chromium_edits/132.0.6834.6/components/cbor/reader.h.patch b/chromium_edits/132.0.6834.6/components/cbor/reader.h.patch new file mode 100644 index 00000000..2dbc0534 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/reader.h.patch @@ -0,0 +1,26 @@ +diff --git a/components/cbor/reader.h b/components/cbor/reader.h +index 5f11ba48ba494..d4c9c489da4b6 100644 +--- a/components/cbor/reader.h ++++ b/components/cbor/reader.h +@@ -131,6 +131,11 @@ class CBOR_EXPORT Reader { + // during decoding will set raise the `UNSUPPORTED_FLOATING_POINT_VALUE` + // error. + bool allow_floating_point = false; ++ ++ // If the parser encounters a TAG element, should it be parsed out and ++ // the tag value saved (true), or should the entire node and its content ++ // be discarded (false) ++ bool parse_tags = false; + }; + + Reader(const Reader&) = delete; +@@ -205,6 +210,9 @@ class CBOR_EXPORT Reader { + std::optional ReadMapContent(const DataItemHeader& header, + const Config& config, + int max_nesting_level); ++ std::optional ReadTagContent(const DataItemHeader& header, ++ const Config& config, ++ int max_nesting_level); + std::optional ReadByte(); + std::optional> ReadBytes(uint64_t num_bytes); + bool IsKeyInOrder(const Value& new_key, diff --git a/chromium_edits/132.0.6834.6/components/cbor/reader_unittest.cc.patch b/chromium_edits/132.0.6834.6/components/cbor/reader_unittest.cc.patch new file mode 100644 index 00000000..150e0c73 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/reader_unittest.cc.patch @@ -0,0 +1,47 @@ +diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc +index e5c02ceea3402..f26b8e77f6da3 100644 +--- a/components/cbor/reader_unittest.cc ++++ b/components/cbor/reader_unittest.cc +@@ -1449,5 +1449,42 @@ TEST(CBORReaderTest, AllowInvalidUTF8) { + EXPECT_FALSE(cbor); + EXPECT_EQ(Reader::DecoderError::INVALID_UTF8, error); + } ++TEST(CBORReaderTest, RejectsTagUnderDefaultConfig) { ++ static const uint8_t kTaggedCbor[] = { ++ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, ++ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, ++ 0x9d, 0xf6, 0x3a, 0x36, 0x5b ++ }; ++ Reader::Config config; ++ auto cbor = Reader::Read(kTaggedCbor, config); ++ EXPECT_FALSE(cbor.has_value()); ++} ++TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { ++ static const uint8_t kTaggedCbor[] = { ++ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, ++ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, ++ 0x9d, 0xf6, 0x3a, 0x36, 0x5b ++ }; ++ Reader::Config config; ++ config.parse_tags = true; ++ auto cbor = Reader::Read(kTaggedCbor, config); ++ EXPECT_TRUE(cbor.has_value()); ++ auto& v = cbor.value(); ++ EXPECT_TRUE(v.has_tag()); ++ EXPECT_EQ(v.GetTag(),42UL); ++ EXPECT_TRUE(v.is_bytestring()); ++ EXPECT_EQ(v.type(), Value::Type::BYTE_STRING); ++ auto& bytes = v.GetBytestring(); ++ EXPECT_EQ(bytes.size(), 37UL); ++ EXPECT_EQ(bytes.at(0), 0x00);//identity multibase (e.g. not base-encoded, bytes are themselves) ++ EXPECT_EQ(bytes.at(1), 0x01);//CID version 1 ++ EXPECT_EQ(bytes.at(2), 0x71);//codec = dag-cbor ++ EXPECT_EQ(bytes.at(3), 0x12);//multihash = 18 = sha2-256 ++ EXPECT_EQ(bytes.at(4), 0x20);//hash length = 32 bytes ++ EXPECT_EQ(bytes.at(5), 0x69);//first byte of hash digest ++ EXPECT_EQ(bytes.at(36),0x5b);//last byte of hash digest ++} + + } // namespace cbor diff --git a/chromium_edits/132.0.6834.6/components/cbor/values.cc.patch b/chromium_edits/132.0.6834.6/components/cbor/values.cc.patch new file mode 100644 index 00000000..890571d8 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/values.cc.patch @@ -0,0 +1,145 @@ +diff --git a/components/cbor/values.cc b/components/cbor/values.cc +index c43c6d8265220..337ca908c813f 100644 +--- a/components/cbor/values.cc ++++ b/components/cbor/values.cc +@@ -64,32 +64,34 @@ Value::Value(Type type) : type_(type) { + NOTREACHED_IN_MIGRATION(); + } + +-Value::Value(SimpleValue in_simple) +- : type_(Type::SIMPLE_VALUE), simple_value_(in_simple) { ++Value::Value(SimpleValue in_simple, uint64_t tag) ++ : type_(Type::SIMPLE_VALUE), simple_value_(in_simple), tag_(tag) { + CHECK(static_cast(in_simple) >= 20 && static_cast(in_simple) <= 23); + } + +-Value::Value(bool boolean_value) : type_(Type::SIMPLE_VALUE) { ++Value::Value(bool boolean_value, uint64_t tag) : type_(Type::SIMPLE_VALUE), tag_(tag) { + simple_value_ = boolean_value ? Value::SimpleValue::TRUE_VALUE + : Value::SimpleValue::FALSE_VALUE; + } + +-Value::Value(double float_value) +- : type_(Type::FLOAT_VALUE), float_value_(float_value) {} ++Value::Value(double float_value, uint64_t tag) ++ : type_(Type::FLOAT_VALUE), float_value_(float_value), tag_(tag) {} + +-Value::Value(int integer_value) +- : Value(base::checked_cast(integer_value)) {} ++Value::Value(int integer_value, uint64_t tag) ++ : Value(base::checked_cast(integer_value), tag) {} + +-Value::Value(int64_t integer_value) : integer_value_(integer_value) { ++Value::Value(int64_t integer_value, uint64_t tag) : integer_value_(integer_value), tag_(tag) { + type_ = integer_value >= 0 ? Type::UNSIGNED : Type::NEGATIVE; + } + +-Value::Value(base::span in_bytes) ++Value::Value(base::span in_bytes, uint64_t tag) + : type_(Type::BYTE_STRING), +- bytestring_value_(in_bytes.begin(), in_bytes.end()) {} ++ bytestring_value_(in_bytes.begin(), in_bytes.end()), ++ tag_(tag) ++ {} + +-Value::Value(base::span in_bytes, Type type) +- : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()) { ++Value::Value(base::span in_bytes, Type type, uint64_t tag) ++ : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()), tag_(tag) { + DCHECK(type_ == Type::BYTE_STRING || type_ == Type::INVALID_UTF8); + } + +@@ -115,7 +117,8 @@ Value::Value(std::string&& in_string, Type type) noexcept : type_(type) { + } + } + +-Value::Value(std::string_view in_string, Type type) : type_(type) { ++Value::Value(std::string_view in_string, Type type, uint64_t tag) ++: type_(type), tag_(tag) { + switch (type_) { + case Type::STRING: + new (&string_value_) std::string(); +@@ -131,16 +134,18 @@ Value::Value(std::string_view in_string, Type type) : type_(type) { + } + } + +-Value::Value(const ArrayValue& in_array) : type_(Type::ARRAY), array_value_() { ++Value::Value(const ArrayValue& in_array, uint64_t tag) ++: type_(Type::ARRAY), array_value_(), tag_(tag) { + array_value_.reserve(in_array.size()); + for (const auto& val : in_array) + array_value_.emplace_back(val.Clone()); + } + +-Value::Value(ArrayValue&& in_array) noexcept +- : type_(Type::ARRAY), array_value_(std::move(in_array)) {} ++Value::Value(ArrayValue&& in_array, uint64_t tag) noexcept ++ : type_(Type::ARRAY), array_value_(std::move(in_array)), tag_(tag) {} + +-Value::Value(const MapValue& in_map) : type_(Type::MAP), map_value_() { ++Value::Value(const MapValue& in_map, uint64_t tag) ++: type_(Type::MAP), map_value_(), tag_(tag) { + map_value_.reserve(in_map.size()); + for (const auto& it : in_map) + map_value_.emplace_hint(map_value_.end(), it.first.Clone(), +@@ -166,31 +171,36 @@ Value Value::Clone() const { + case Type::NONE: + return Value(); + case Type::INVALID_UTF8: +- return Value(bytestring_value_, Type::INVALID_UTF8); ++ return Value(bytestring_value_, Type::INVALID_UTF8, tag_); + case Type::UNSIGNED: + case Type::NEGATIVE: +- return Value(integer_value_); ++ return Value(integer_value_, tag_); + case Type::BYTE_STRING: +- return Value(bytestring_value_); ++ return Value(bytestring_value_, tag_); + case Type::STRING: +- return Value(string_value_); ++ return Value(string_value_, Type::STRING, tag_); + case Type::ARRAY: +- return Value(array_value_); ++ return Value(array_value_, tag_); + case Type::MAP: +- return Value(map_value_); ++ return Value(map_value_, tag_); + case Type::TAG: + NOTREACHED_IN_MIGRATION() << constants::kUnsupportedMajorType; + return Value(); + case Type::SIMPLE_VALUE: +- return Value(simple_value_); ++ return Value(simple_value_, tag_); + case Type::FLOAT_VALUE: +- return Value(float_value_); ++ return Value(float_value_, tag_); + } + + NOTREACHED_IN_MIGRATION(); + return Value(); + } + ++Value& Value::SetTag(uint64_t tag) noexcept { ++ tag_ = tag; ++ return *this; ++} ++ + Value::SimpleValue Value::GetSimpleValue() const { + CHECK(is_simple()); + return simple_value_; +@@ -256,9 +266,14 @@ const Value::BinaryValue& Value::GetInvalidUTF8() const { + return bytestring_value_; + } + ++uint64_t Value::GetTag() const { ++ CHECK(has_tag()); ++ return tag_; ++} ++ + void Value::InternalMoveConstructFrom(Value&& that) { + type_ = that.type_; +- ++ tag_ = that.tag_; + switch (type_) { + case Type::UNSIGNED: + case Type::NEGATIVE: diff --git a/chromium_edits/132.0.6834.6/components/cbor/values.h.patch b/chromium_edits/132.0.6834.6/components/cbor/values.h.patch new file mode 100644 index 00000000..5556e8c5 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/values.h.patch @@ -0,0 +1,79 @@ +diff --git a/components/cbor/values.h b/components/cbor/values.h +index d55369f1a71bf..7dabb368c51d6 100644 +--- a/components/cbor/values.h ++++ b/components/cbor/values.h +@@ -125,28 +125,29 @@ class CBOR_EXPORT Value { + + explicit Value(Type type); + +- explicit Value(SimpleValue in_simple); +- explicit Value(bool boolean_value); +- explicit Value(double in_float); ++ explicit Value(SimpleValue in_simple, uint64_t tag = NO_TAG); ++ explicit Value(bool boolean_value, uint64_t tag = NO_TAG); ++ explicit Value(double in_float, uint64_t tag = NO_TAG); + +- explicit Value(int integer_value); +- explicit Value(int64_t integer_value); ++ explicit Value(int integer_value, uint64_t tag = NO_TAG); ++ explicit Value(int64_t integer_value, uint64_t tag = NO_TAG); + explicit Value(uint64_t integer_value) = delete; + +- explicit Value(base::span in_bytes); ++ explicit Value(base::span in_bytes, uint64_t tag = NO_TAG); + explicit Value(BinaryValue&& in_bytes) noexcept; + + explicit Value(const char* in_string, Type type = Type::STRING); + explicit Value(std::string&& in_string, Type type = Type::STRING) noexcept; +- explicit Value(std::string_view in_string, Type type = Type::STRING); ++ explicit Value(std::string_view in_string, Type type = Type::STRING, uint64_t tag = NO_TAG); + +- explicit Value(const ArrayValue& in_array); +- explicit Value(ArrayValue&& in_array) noexcept; ++ explicit Value(const ArrayValue& in_array, uint64_t tag = NO_TAG); ++ explicit Value(ArrayValue&& in_array, uint64_t tag = NO_TAG) noexcept; + +- explicit Value(const MapValue& in_map); ++ explicit Value(const MapValue& in_map, uint64_t tag = NO_TAG); + explicit Value(MapValue&& in_map) noexcept; + + Value& operator=(Value&& that) noexcept; ++ Value& SetTag(uint64_t) noexcept; + + Value(const Value&) = delete; + Value& operator=(const Value&) = delete; +@@ -177,6 +178,7 @@ class CBOR_EXPORT Value { + bool is_string() const { return type() == Type::STRING; } + bool is_array() const { return type() == Type::ARRAY; } + bool is_map() const { return type() == Type::MAP; } ++ bool has_tag() const { return tag_ != NO_TAG; } + + // These will all fatally assert if the type doesn't match. + SimpleValue GetSimpleValue() const; +@@ -192,12 +194,13 @@ class CBOR_EXPORT Value { + const ArrayValue& GetArray() const; + const MapValue& GetMap() const; + const BinaryValue& GetInvalidUTF8() const; ++ uint64_t GetTag() const; + + private: + friend class Reader; + // This constructor allows INVALID_UTF8 values to be created, which only + // |Reader| and InvalidUTF8StringValueForTesting() may do. +- Value(base::span in_bytes, Type type); ++ Value(base::span in_bytes, Type type, uint64_t tag = NO_TAG); + + Type type_; + +@@ -211,6 +214,11 @@ class CBOR_EXPORT Value { + MapValue map_value_; + }; + ++ //This value specified as Invalid, ++ // used here to represent absence of TAG ++ constexpr static uint64_t NO_TAG = 0xFFFF; ++ uint64_t tag_ = NO_TAG; ++ + void InternalMoveConstructFrom(Value&& that); + void InternalCleanup(); + }; diff --git a/chromium_edits/132.0.6834.6/components/cbor/writer.cc.patch b/chromium_edits/132.0.6834.6/components/cbor/writer.cc.patch new file mode 100644 index 00000000..1950e174 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/writer.cc.patch @@ -0,0 +1,14 @@ +diff --git a/components/cbor/writer.cc b/components/cbor/writer.cc +index c4bfcfb602949..b92885a30971c 100644 +--- a/components/cbor/writer.cc ++++ b/components/cbor/writer.cc +@@ -47,6 +47,9 @@ bool Writer::EncodeCBOR(const Value& node, + if (max_nesting_level < 0) + return false; + ++ if (node.has_tag()) { ++ StartItem(Value::Type::TAG, node.GetTag()); ++ } + switch (node.type()) { + case Value::Type::NONE: { + StartItem(Value::Type::BYTE_STRING, 0); diff --git a/chromium_edits/132.0.6834.6/components/cbor/writer_unittest.cc.patch b/chromium_edits/132.0.6834.6/components/cbor/writer_unittest.cc.patch new file mode 100644 index 00000000..1acf5f7f --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/cbor/writer_unittest.cc.patch @@ -0,0 +1,36 @@ +diff --git a/components/cbor/writer_unittest.cc b/components/cbor/writer_unittest.cc +index ee11e7cb86712..b8942f1829a37 100644 +--- a/components/cbor/writer_unittest.cc ++++ b/components/cbor/writer_unittest.cc +@@ -523,4 +523,31 @@ TEST(CBORWriterTest, OverlyNestedCBOR) { + EXPECT_FALSE(Writer::Write(Value(map), 4).has_value()); + } + ++TEST(CBORWriterTest, CanWriteTag) { ++ std::array content{ ++ 0x00, 0x01, 0x71, 0x12, 0x20, ++ 0x69, 0xea, 0x07, 0x40, 0xf9, ++ 0x80, 0x7a, 0x28, 0xf4, 0xd9, ++ 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, ++ 0x07, 0x2c, 0x90, 0x26, 0x6a, ++ 0xb3, 0xe7, 0x9d, 0xf6, 0x3a, ++ 0x36, 0x5b ++ }; ++ Value to_write(content); ++ to_write.SetTag(42); ++ auto result = Writer::Write(to_write); ++ EXPECT_TRUE(result.has_value()); ++ auto& bytes = result.value(); ++ EXPECT_EQ(bytes.size(), 41UL); ++ EXPECT_EQ(bytes.at(0), 0xd8); ++ EXPECT_EQ(bytes.at(1), 0x2a); ++ EXPECT_EQ(bytes.at(2), 0x58); ++ EXPECT_EQ(bytes.at(3), 0x25); ++ for (auto i = 0UL; i < content.size(); ++i) { ++ ASSERT_LT(i + 4UL, bytes.size()); ++ ASSERT_EQ(content.at(i), bytes.at(i+4UL)); ++ } ++} ++ + } // namespace cbor diff --git a/chromium_edits/132.0.6834.6/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch b/chromium_edits/132.0.6834.6/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch new file mode 100644 index 00000000..ee376ce1 --- /dev/null +++ b/chromium_edits/132.0.6834.6/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch @@ -0,0 +1,13 @@ +diff --git a/components/open_from_clipboard/clipboard_recent_content_generic.cc b/components/open_from_clipboard/clipboard_recent_content_generic.cc +index 3683fadcc0914..440d4be132e5c 100644 +--- a/components/open_from_clipboard/clipboard_recent_content_generic.cc ++++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc +@@ -20,7 +20,7 @@ + namespace { + // Schemes appropriate for suggestion by ClipboardRecentContent. + const char* kAuthorizedSchemes[] = { +- url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, ++ url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, "ipfs", "ipns" + // TODO(mpearson): add support for chrome:// URLs. Right now the scheme + // for that lives in content and is accessible via + // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme diff --git a/chromium_edits/132.0.6834.6/net/dns/dns_config_service_linux.cc.patch b/chromium_edits/132.0.6834.6/net/dns/dns_config_service_linux.cc.patch new file mode 100644 index 00000000..fd7227a5 --- /dev/null +++ b/chromium_edits/132.0.6834.6/net/dns/dns_config_service_linux.cc.patch @@ -0,0 +1,18 @@ +diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc +index 7aaf9fa5b0b78..5a9f5b5a70dd9 100644 +--- a/net/dns/dns_config_service_linux.cc ++++ b/net/dns/dns_config_service_linux.cc +@@ -276,11 +276,11 @@ bool IsNsswitchConfigCompatible( + // Ignore any entries after `kDns` because Chrome will fallback to the + // system resolver if a result was not found in DNS. + return true; +- ++ case NsswitchReader::Service::kResolve: ++ break; + case NsswitchReader::Service::kMdns: + case NsswitchReader::Service::kMdns4: + case NsswitchReader::Service::kMdns6: +- case NsswitchReader::Service::kResolve: + case NsswitchReader::Service::kNis: + RecordIncompatibleNsswitchReason( + IncompatibleNsswitchReason::kIncompatibleService, diff --git a/chromium_edits/132.0.6834.6/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch b/chromium_edits/132.0.6834.6/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch new file mode 100644 index 00000000..663fe49e --- /dev/null +++ b/chromium_edits/132.0.6834.6/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch @@ -0,0 +1,15 @@ +diff --git a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc +index e1bc209c337c5..6fbac29fcddfd 100644 +--- a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc ++++ b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc +@@ -68,8 +68,8 @@ class URLSchemesRegistry final { + // is considered secure. Additional checks are performed to ensure that + // other http pages are filtered out. + service_worker_schemes({"http", "https"}), +- fetch_api_schemes({"http", "https"}), +- allowed_in_referrer_schemes({"http", "https"}) { ++ fetch_api_schemes({"http", "https", "ipfs", "ipns"}), ++ allowed_in_referrer_schemes({"http", "https", "ipfs", "ipns"}) { + for (auto& scheme : url::GetCorsEnabledSchemes()) + cors_enabled_schemes.insert(scheme.c_str()); + for (auto& scheme : url::GetCSPBypassingSchemes()) { diff --git a/chromium_edits/132.0.6834.6/url/BUILD.gn.patch b/chromium_edits/132.0.6834.6/url/BUILD.gn.patch new file mode 100644 index 00000000..be4bfca8 --- /dev/null +++ b/chromium_edits/132.0.6834.6/url/BUILD.gn.patch @@ -0,0 +1,32 @@ +diff --git a/url/BUILD.gn b/url/BUILD.gn +index f22b73bc29f06..df36977322ec7 100644 +--- a/url/BUILD.gn ++++ b/url/BUILD.gn +@@ -5,6 +5,7 @@ + import("//build/buildflag_header.gni") + import("//testing/libfuzzer/fuzzer_test.gni") + import("//testing/test.gni") ++import("//third_party/ipfs_client/args.gni") + import("features.gni") + + import("//build/config/cronet/config.gni") +@@ -67,6 +68,7 @@ component("url") { + public_deps = [ + "//base", + "//build:robolectric_buildflags", ++ "//third_party/ipfs_client:ipfs_buildflags", + ] + + configs += [ "//build/config/compiler:wexit_time_destructors" ] +@@ -89,6 +91,11 @@ component("url") { + public_configs = [ "//third_party/jdk" ] + } + ++ if (enable_ipfs) { ++ sources += [ "url_canon_ipfs.cc" ] ++ deps += [ "//third_party/ipfs_client:ipfs_client" ] ++ } ++ + if (is_win) { + # Don't conflict with Windows' "url.dll". + output_name = "url_lib" diff --git a/chromium_edits/132.0.6834.6/url/url_canon.h.patch b/chromium_edits/132.0.6834.6/url/url_canon.h.patch new file mode 100644 index 00000000..0f667205 --- /dev/null +++ b/chromium_edits/132.0.6834.6/url/url_canon.h.patch @@ -0,0 +1,26 @@ +diff --git a/url/url_canon.h b/url/url_canon.h +index 3b84d686ba0f0..c18cb750c6de1 100644 +--- a/url/url_canon.h ++++ b/url/url_canon.h +@@ -855,6 +855,21 @@ bool CanonicalizeMailtoURL(const char16_t* spec, + CanonOutput* output, + Parsed* new_parsed); + ++COMPONENT_EXPORT(URL) ++bool CanonicalizeIpfsURL(std::string_view spec, ++ const Parsed& parsed, ++ SchemeType scheme_type, ++ CharsetConverter* query_converter, ++ CanonOutput* output, ++ Parsed* new_parsed); ++COMPONENT_EXPORT(URL) ++bool CanonicalizeIpfsURL(std::basic_string_view spec, ++ const Parsed& parsed, ++ SchemeType scheme_type, ++ CharsetConverter* query_converter, ++ CanonOutput* output, ++ Parsed* new_parsed); ++ + // Part replacer -------------------------------------------------------------- + + // Internal structure used for storing separate strings for each component. diff --git a/chromium_edits/132.0.6834.6/url/url_canon_ipfs.cc b/chromium_edits/132.0.6834.6/url/url_canon_ipfs.cc new file mode 100644 index 00000000..e40732ee --- /dev/null +++ b/chromium_edits/132.0.6834.6/url/url_canon_ipfs.cc @@ -0,0 +1,54 @@ +#include "url_canon_internal.h" + +#include +#include + +#include + +bool url::CanonicalizeIpfsURL(std::string_view spec, + const Parsed& parsed, + SchemeType scheme_type, + CharsetConverter* charset_converter, + CanonOutput* output, + Parsed* output_parsed) { + if (spec.size() < 1) { + return false; + } + if ( parsed.host.len < 1 ) { + return false; + } + auto cid_str = spec.substr( parsed.host.begin, static_cast(parsed.host.len) ); + auto cid = ipfs::Cid(cid_str); + if ( !cid.valid() ) { + cid = ipfs::id_cid::forText( std::string{cid_str} + " is not a valid CID." ); + } + auto as_str = cid.to_string(); + if ( as_str.empty() ) { + return false; + } + std::string stdurl{ spec.substr(0UL, static_cast(parsed.host.begin)) }; + stdurl.append( as_str ); + spec.remove_prefix(parsed.host.end()); + stdurl.append(spec); + auto len = static_cast(stdurl.size()); + Parsed parsed_input; + ParseStandardURL(stdurl.data(), len, &parsed_input); + return CanonicalizeStandardURL( + stdurl.data(), + parsed_input, + scheme_type, + charset_converter, + output, output_parsed + ); +} +bool url::CanonicalizeIpfsURL(std::basic_string_view spec, + const Parsed& parsed, + SchemeType scheme_type, + CharsetConverter* query_converter, + CanonOutput* output, + Parsed* new_parsed) { + RawCanonOutput<2048> as8; + ConvertUTF16ToUTF8(spec.data(), spec.size(), &as8); + return CanonicalizeIpfsURL({as8.data(), as8.length()}, parsed, scheme_type, + query_converter, output, new_parsed); +} diff --git a/chromium_edits/132.0.6834.6/url/url_util.cc.patch b/chromium_edits/132.0.6834.6/url/url_util.cc.patch new file mode 100644 index 00000000..8d22ec10 --- /dev/null +++ b/chromium_edits/132.0.6834.6/url/url_util.cc.patch @@ -0,0 +1,45 @@ +diff --git a/url/url_util.cc b/url/url_util.cc +index 67c4c5f3ce124..b268390940561 100644 +--- a/url/url_util.cc ++++ b/url/url_util.cc +@@ -76,6 +76,8 @@ struct SchemeRegistry { + std::vector referrer_schemes = { + {kHttpsScheme, SCHEME_WITH_HOST_PORT_AND_USER_INFORMATION}, + {kHttpScheme, SCHEME_WITH_HOST_PORT_AND_USER_INFORMATION}, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that do not trigger mixed content warning. +@@ -84,6 +86,8 @@ struct SchemeRegistry { + kWssScheme, + kDataScheme, + kAboutScheme, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that normal pages cannot link to or access (i.e., with the same +@@ -105,6 +109,8 @@ struct SchemeRegistry { + kHttpsScheme, + kHttpScheme, + kDataScheme, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that can be used by web to store data (local storage, etc). +@@ -308,7 +314,12 @@ bool DoCanonicalize(const CHAR* spec, + success = CanonicalizeFileSystemURL( + spec, ParseFileSystemURL(std::basic_string_view(spec, spec_len)), + charset_converter, output, output_parsed); +- ++ } else if (DoCompareSchemeComponent(spec, scheme, "ipfs")) { ++ auto spec_view = std::basic_string_view(spec, spec_len); ++ // Switch multibase away from case-sensitive ones before continuing canonicalization. ++ auto parsed_input = ParseStandardURL(spec_view); ++ success = CanonicalizeIpfsURL(spec_view, parsed_input, scheme_type, ++ charset_converter, output, output_parsed); + } else if (DoIsStandard(spec, scheme, &scheme_type)) { + // All "normal" URLs. + success = CanonicalizeStandardURL( diff --git a/chromium_edits/133.0.6835.3/chrome/browser/BUILD.gn.patch b/chromium_edits/133.0.6835.3/chrome/browser/BUILD.gn.patch new file mode 100644 index 00000000..ea7987d5 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/BUILD.gn.patch @@ -0,0 +1,27 @@ +diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn +index fdfa082c1cfae..8a212006c6ca7 100644 +--- a/chrome/browser/BUILD.gn ++++ b/chrome/browser/BUILD.gn +@@ -42,6 +42,7 @@ import("//sandbox/features.gni") + import("//services/screen_ai/buildflags/features.gni") + import("//testing/libfuzzer/fuzzer_test.gni") + import("//third_party/blink/public/public_features.gni") ++import("//third_party/ipfs_client/args.gni") + import("//third_party/protobuf/proto_library.gni") + import("//third_party/webrtc/webrtc.gni") + import("//third_party/widevine/cdm/widevine.gni") +@@ -2496,6 +2497,14 @@ static_library("browser") { + "//ui/webui", + ] + ++ if (enable_ipfs) { ++ sources += [ ++ "ipfs_extra_parts.cc", ++ "ipfs_extra_parts.h", ++ ] ++ deps += [ "//components/ipfs" ] ++ } ++ + # Platforms that have a network diagnostics dialog. All others fall through + # to the stub which is not implemented. + if (is_chromeos_ash) { diff --git a/chromium_edits/133.0.6835.3/chrome/browser/about_flags.cc.patch b/chromium_edits/133.0.6835.3/chrome/browser/about_flags.cc.patch new file mode 100644 index 00000000..cd188806 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/about_flags.cc.patch @@ -0,0 +1,38 @@ +diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc +index c1e77252730c7..8659a01be9d50 100644 +--- a/chrome/browser/about_flags.cc ++++ b/chrome/browser/about_flags.cc +@@ -231,6 +231,7 @@ + #include "third_party/blink/public/common/features_generated.h" + #include "third_party/blink/public/common/forcedark/forcedark_switches.h" + #include "third_party/blink/public/common/switches.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "ui/accessibility/accessibility_features.h" + #include "ui/accessibility/accessibility_switches.h" + #include "ui/base/ozone_buildflags.h" +@@ -336,6 +337,10 @@ + #include "extensions/common/switches.h" + #endif // BUILDFLAG(ENABLE_EXTENSIONS) + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#endif ++ + #if BUILDFLAG(ENABLE_PDF) + #include "pdf/pdf_features.h" + #endif +@@ -9664,6 +9669,14 @@ const FeatureEntry kFeatureEntries[] = { + flag_descriptions::kOmitCorsClientCertDescription, kOsAll, + FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)}, + ++#if BUILDFLAG(ENABLE_IPFS) ++ {"enable-ipfs", ++ flag_descriptions::kEnableIpfsName, ++ flag_descriptions::kEnableIpfsDescription, ++ kOsMac | kOsWin | kOsLinux,//TODO: These are the only variants currently getting built, but that is not likely to remain the case ++ FEATURE_VALUE_TYPE(ipfs::kEnableIpfs)}, ++#endif ++ + {"use-idna2008-non-transitional", + flag_descriptions::kUseIDNA2008NonTransitionalName, + flag_descriptions::kUseIDNA2008NonTransitionalDescription, kOsAll, diff --git a/chromium_edits/133.0.6835.3/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch b/chromium_edits/133.0.6835.3/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch new file mode 100644 index 00000000..2bbe24d6 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch @@ -0,0 +1,51 @@ +diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +index a4a306c760f44..35dc091513f49 100644 +--- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc ++++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +@@ -13,6 +13,7 @@ + #include "chrome/browser/profiles/profile_io_data.h" + #include "components/custom_handlers/protocol_handler_registry.h" + #include "content/public/common/url_constants.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "url/url_util.h" + + #if BUILDFLAG(IS_ANDROID) +@@ -20,6 +21,11 @@ + #include "chrome/browser/ui/android/omnibox/jni_headers/ChromeAutocompleteSchemeClassifier_jni.h" + #endif + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#endif ++ ++ + #if BUILDFLAG(IS_ANDROID) + static jlong + JNI_ChromeAutocompleteSchemeClassifier_CreateAutocompleteClassifier( +@@ -53,12 +59,20 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( + if (scheme.empty()) { + return metrics::OmniboxInputType::EMPTY; + } +- if (base::IsStringASCII(scheme) && +- (ProfileIOData::IsHandledProtocol(scheme) || +- base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || +- base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || +- base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme))) { +- return metrics::OmniboxInputType::URL; ++ if (base::IsStringASCII(scheme)) { ++ if (ProfileIOData::IsHandledProtocol(scheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || ++ base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme)) { ++ return metrics::OmniboxInputType::URL; ++ } ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs) && ++ (base::EqualsCaseInsensitiveASCII(scheme, "ipfs") || base::EqualsCaseInsensitiveASCII(scheme, "ipns")) ++ ) { ++ return metrics::OmniboxInputType::URL; ++ } ++#endif + } + + // Also check for schemes registered via registerProtocolHandler(), which diff --git a/chromium_edits/133.0.6835.3/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/133.0.6835.3/chrome/browser/chrome_content_browser_client.cc.patch new file mode 100644 index 00000000..328ff34c --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/chrome_content_browser_client.cc.patch @@ -0,0 +1,81 @@ +diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc +index 25b5c325f612d..254f41914236e 100644 +--- a/chrome/browser/chrome_content_browser_client.cc ++++ b/chrome/browser/chrome_content_browser_client.cc +@@ -409,6 +409,7 @@ + #include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h" + #include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h" + #include "third_party/blink/public/public_buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + #include "third_party/widevine/cdm/buildflags.h" + #include "ui/base/clipboard/clipboard_format_type.h" + #include "ui/base/l10n/l10n_util.h" +@@ -535,6 +536,13 @@ + #include "chrome/browser/chrome_browser_main_posix.h" + #endif + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "chrome/browser/ipfs_extra_parts.h" ++#include "components/ipfs/interceptor.h" ++#include "components/ipfs/ipfs_features.h" ++#include "components/ipfs/url_loader_factory.h" ++#endif ++ + #if !BUILDFLAG(IS_ANDROID) + #include "chrome/browser/digital_credentials/digital_identity_provider_desktop.h" + #include "chrome/browser/preloading/preview/preview_navigation_throttle.h" +@@ -1876,6 +1884,11 @@ ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) { + main_parts->AddParts( + std::make_unique()); + ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ main_parts->AddParts(std::make_unique()); ++ } ++#endif + return main_parts; + } + +@@ -6573,12 +6586,29 @@ void ChromeContentBrowserClient:: + const std::optional& request_initiator_origin, + NonNetworkURLLoaderFactoryMap* factories) { + #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ +- !BUILDFLAG(IS_ANDROID) ++ !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) + content::RenderFrameHost* frame_host = + RenderFrameHost::FromID(render_process_id, render_frame_id); + WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); + #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ + // !BUILDFLAG(IS_ANDROID) ++#if BUILDFLAG(ENABLE_IPFS) ++ if (!web_contents) { ++ VLOG(2) << "No web contents, can't register url loader factory."; ++ } else if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); ++ auto* context = web_contents->GetBrowserContext(); ++ ipfs::IpfsURLLoaderFactory::Create( ++ factories, ++ context, ++ default_factory, ++ GetSystemNetworkContext(), ++ Profile::FromBrowserContext(context)->GetPrefs() ++ ); ++ } else { ++ LOG(INFO) << "IPFS disabled."; ++ } ++#endif // BUILDFLAG(ENABLE_IPFS) + + #if BUILDFLAG(IS_CHROMEOS_ASH) + if (web_contents) { +@@ -6726,6 +6756,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( + scoped_refptr navigation_response_task_runner) { + std::vector> + interceptors; ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ interceptors.push_back(std::make_unique(g_browser_process->system_network_context_manager()->GetURLLoaderFactory(), GetSystemNetworkContext())); ++ } ++#endif + #if BUILDFLAG(ENABLE_OFFLINE_PAGES) + interceptors.push_back( + std::make_unique( diff --git a/chromium_edits/133.0.6835.3/chrome/browser/flag-metadata.json.patch b/chromium_edits/133.0.6835.3/chrome/browser/flag-metadata.json.patch new file mode 100644 index 00000000..2b834624 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/flag-metadata.json.patch @@ -0,0 +1,16 @@ +diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json +index bed4f0058c0b7..6e5015a2a2a20 100644 +--- a/chrome/browser/flag-metadata.json ++++ b/chrome/browser/flag-metadata.json +@@ -3293,6 +3293,11 @@ + "owners": [ "adamta@google.com", "bling-get-set-up@google.com" ], + "expiry_milestone": 140 + }, ++ { ++ "name": "enable-ipfs", ++ "owners": [ "//components/ipfs/OWNERS" ], ++ "expiry_milestone": 150 ++ }, + { + "name": "enable-isolated-sandboxed-iframes", + "owners": [ "wjmaclean@chromium.org", "alexmos@chromium.org", "creis@chromium.org" ], diff --git a/chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.cc.patch b/chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.cc.patch new file mode 100644 index 00000000..be7363bb --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.cc.patch @@ -0,0 +1,16 @@ +diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc +index 72bc44487e033..eccec4effa2d9 100644 +--- a/chrome/browser/flag_descriptions.cc ++++ b/chrome/browser/flag_descriptions.cc +@@ -376,6 +376,11 @@ const char kEnableBookmarksSelectedTypeOnSigninForTestingDescription[] = + "sync-enable-bookmarks-in-transport-mode. Enables the bookmarks " + "UserSelectableType upon sign-in"; + ++#if BUILDFLAG(ENABLE_IPFS) ++extern const char kEnableIpfsName[] = "Enable IPFS"; ++extern const char kEnableIpfsDescription[] = "Enable ipfs:// and ipns:// URLs"; ++#endif ++ + const char kPreloadingOnPerformancePageName[] = + "Preloading Settings on Performance Page"; + const char kPreloadingOnPerformancePageDescription[] = diff --git a/chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.h.patch b/chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.h.patch new file mode 100644 index 00000000..a0f05f9f --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/flag_descriptions.h.patch @@ -0,0 +1,24 @@ +diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h +index 130a09c4eb439..782a8b731e03d 100644 +--- a/chrome/browser/flag_descriptions.h ++++ b/chrome/browser/flag_descriptions.h +@@ -25,6 +25,7 @@ + #include "printing/buildflags/buildflags.h" + #include "skia/buildflags.h" + #include "third_party/blink/public/common/buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + + // This file declares strings used in chrome://flags. These messages are not + // translated, because instead of end-users they target Chromium developers and +@@ -228,6 +229,11 @@ extern const char kEnableBenchmarkingChoiceMatchFieldTrialTestingConfig[]; + extern const char kEnableBookmarksSelectedTypeOnSigninForTestingName[]; + extern const char kEnableBookmarksSelectedTypeOnSigninForTestingDescription[]; + ++#if BUILDFLAG(ENABLE_IPFS) ++extern const char kEnableIpfsName[]; ++extern const char kEnableIpfsDescription[]; ++#endif ++ + extern const char kFontationsFontBackendName[]; + extern const char kFontationsFontBackendDescription[]; + diff --git a/chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.cc b/chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.cc new file mode 100644 index 00000000..90d2596f --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.cc @@ -0,0 +1,10 @@ +#include "ipfs_extra_parts.h" + +#include "profiles/profile.h" + +#include + +void IpfsExtraParts::PostProfileInit(Profile* profile, bool /* is_initial_profile */ ) { + DCHECK(profile); + ipfs::InterRequestState::CreateForBrowserContext(profile, profile->GetPrefs()); +} diff --git a/chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.h b/chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.h new file mode 100644 index 00000000..2059c437 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/ipfs_extra_parts.h @@ -0,0 +1,10 @@ +#ifndef IPFS_EXTRA_PART_H_ +#define IPFS_EXTRA_PART_H_ + +#include + +class IpfsExtraParts : public ChromeBrowserMainExtraParts { + void PostProfileInit(Profile* profile, bool is_initial_profile) override; +}; + +#endif // IPFS_EXTRA_PART_H_ diff --git a/chromium_edits/133.0.6835.3/chrome/browser/prefs/BUILD.gn.patch b/chromium_edits/133.0.6835.3/chrome/browser/prefs/BUILD.gn.patch new file mode 100644 index 00000000..a867c5b9 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/prefs/BUILD.gn.patch @@ -0,0 +1,23 @@ +diff --git a/chrome/browser/prefs/BUILD.gn b/chrome/browser/prefs/BUILD.gn +index 156a2f34d89f5..7f17b564e36df 100644 +--- a/chrome/browser/prefs/BUILD.gn ++++ b/chrome/browser/prefs/BUILD.gn +@@ -7,6 +7,7 @@ import("//components/safe_browsing/buildflags.gni") + import("//components/services/on_device_translation/buildflags/features.gni") + import("//extensions/buildflags/buildflags.gni") + import("//pdf/features.gni") ++import("//third_party/ipfs_client/args.gni") + + assert(is_win || is_mac || is_linux || is_chromeos || is_android) + +@@ -126,7 +127,9 @@ source_set("impl") { + "//services/preferences/public/mojom", + "//services/preferences/tracked", + ] +- ++ if (enable_ipfs) { ++ deps += [ "//components/ipfs" ] ++ } + if (is_chromeos) { + deps += [ + "//ash", diff --git a/chromium_edits/133.0.6835.3/chrome/browser/prefs/browser_prefs.cc.patch b/chromium_edits/133.0.6835.3/chrome/browser/prefs/browser_prefs.cc.patch new file mode 100644 index 00000000..23de7d29 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/prefs/browser_prefs.cc.patch @@ -0,0 +1,36 @@ +diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc +index a6002045888c4..d7434b3851b22 100644 +--- a/chrome/browser/prefs/browser_prefs.cc ++++ b/chrome/browser/prefs/browser_prefs.cc +@@ -197,6 +197,7 @@ + #include "ppapi/buildflags/buildflags.h" + #include "printing/buildflags/buildflags.h" + #include "rlz/buildflags/buildflags.h" ++#include "third_party/ipfs_client/ipfs_buildflags.h" + + #if BUILDFLAG(ENABLE_BACKGROUND_MODE) + #include "chrome/browser/background/background_mode_manager.h" +@@ -245,6 +246,11 @@ + #include "chrome/browser/pdf/pdf_pref_names.h" + #endif // BUILDFLAG(ENABLE_PDF) + ++#if BUILDFLAG(ENABLE_IPFS) ++#include "components/ipfs/ipfs_features.h" ++#include "components/ipfs/preferences.h" ++#endif ++ + #if BUILDFLAG(IS_ANDROID) + #include "chrome/browser/accessibility/accessibility_prefs/android/accessibility_prefs_controller.h" + #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h" +@@ -1933,6 +1939,11 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, + IncognitoModePrefs::RegisterProfilePrefs(registry); + invalidation::PerUserTopicSubscriptionManager::RegisterProfilePrefs(registry); + invalidation::InvalidatorRegistrarWithMemory::RegisterProfilePrefs(registry); ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ ipfs::RegisterPreferences(registry); ++ } ++#endif + language::LanguagePrefs::RegisterProfilePrefs(registry); + login_detection::prefs::RegisterProfilePrefs(registry); + lookalikes::RegisterProfilePrefs(registry); diff --git a/chromium_edits/133.0.6835.3/chrome/browser/shell_integration_mac.mm.patch b/chromium_edits/133.0.6835.3/chrome/browser/shell_integration_mac.mm.patch new file mode 100644 index 00000000..220e2546 --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/browser/shell_integration_mac.mm.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm +index c6bb768979453..c0d0abb9c78f3 100644 +--- a/chrome/browser/shell_integration_mac.mm ++++ b/chrome/browser/shell_integration_mac.mm +@@ -79,6 +79,8 @@ bool SetAsDefaultBrowser() { + if (LSSetDefaultHandlerForURLScheme(CFSTR("https"), identifier) != noErr) { + return false; + } ++ LSSetDefaultHandlerForURLScheme(CFSTR("ipfs"), identifier); ++ LSSetDefaultHandlerForURLScheme(CFSTR("ipns"), identifier); + if (LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesViewer, + identifier) != noErr) { + return false; diff --git a/chromium_edits/133.0.6835.3/chrome/common/chrome_content_client.cc.patch b/chromium_edits/133.0.6835.3/chrome/common/chrome_content_client.cc.patch new file mode 100644 index 00000000..40bc3abe --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/common/chrome_content_client.cc.patch @@ -0,0 +1,17 @@ +diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc +index aa28db3f8aaa3..252958825aa2a 100644 +--- a/chrome/common/chrome_content_client.cc ++++ b/chrome/common/chrome_content_client.cc +@@ -314,6 +314,12 @@ void ChromeContentClient::AddAdditionalSchemes(Schemes* schemes) { + #if BUILDFLAG(IS_ANDROID) + schemes->local_schemes.push_back(url::kContentScheme); + #endif ++ for ( const char* ip_s : {"ipfs", "ipns"} ) { ++ schemes->standard_schemes.push_back(ip_s); ++ schemes->cors_enabled_schemes.push_back(ip_s); ++ schemes->secure_schemes.push_back(ip_s); ++ schemes->csp_bypassing_schemes.push_back(ip_s); ++ } + } + + std::u16string ChromeContentClient::GetLocalizedString(int message_id) { diff --git a/chromium_edits/133.0.6835.3/chrome/installer/linux/common/desktop.template.patch b/chromium_edits/133.0.6835.3/chrome/installer/linux/common/desktop.template.patch new file mode 100644 index 00000000..dcd9460b --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/installer/linux/common/desktop.template.patch @@ -0,0 +1,13 @@ +diff --git a/chrome/installer/linux/common/desktop.template b/chrome/installer/linux/common/desktop.template +index 2eb13ee1aba46..9af65726bde89 100644 +--- a/chrome/installer/linux/common/desktop.template ++++ b/chrome/installer/linux/common/desktop.template +@@ -111,7 +111,7 @@ Terminal=false + Icon=@@PACKAGE@@ + Type=Application + Categories=Network;WebBrowser; +-MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https; ++MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ipfs;x-scheme-handler/ipns; + Actions=new-window;new-private-window; + + [Desktop Action new-window] diff --git a/chromium_edits/133.0.6835.3/chrome/installer/util/shell_util.cc.patch b/chromium_edits/133.0.6835.3/chrome/installer/util/shell_util.cc.patch new file mode 100644 index 00000000..38f9123c --- /dev/null +++ b/chromium_edits/133.0.6835.3/chrome/installer/util/shell_util.cc.patch @@ -0,0 +1,20 @@ +diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc +index 0f9ca6c1674c2..2e5c8f11b28d8 100644 +--- a/chrome/installer/util/shell_util.cc ++++ b/chrome/installer/util/shell_util.cc +@@ -1538,11 +1538,12 @@ const wchar_t* ShellUtil::kDefaultFileAssociations[] = { + const wchar_t* ShellUtil::kPotentialFileAssociations[] = { + L".htm", L".html", L".mhtml", L".pdf", L".shtml", + L".svg", L".xht", L".xhtml", L".webp", nullptr}; +-const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"http", L"https", +- nullptr}; ++const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = { ++ L"http", L"https", L"ipfs", L"ipns", nullptr}; + const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = { + L"http", L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", +- L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", nullptr}; ++ L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", L"ipfs", ++ L"ipns", nullptr}; + const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; + const wchar_t* ShellUtil::kRegApplication = L"\\Application"; + const wchar_t* ShellUtil::kRegAppUserModelId = L"AppUserModelId"; diff --git a/chromium_edits/133.0.6835.3/components/cbor/reader.cc.patch b/chromium_edits/133.0.6835.3/components/cbor/reader.cc.patch new file mode 100644 index 00000000..de3d0b36 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/reader.cc.patch @@ -0,0 +1,44 @@ +diff --git a/components/cbor/reader.cc b/components/cbor/reader.cc +index 24d852e45f2ba..4dfec34caabd7 100644 +--- a/components/cbor/reader.cc ++++ b/components/cbor/reader.cc +@@ -22,7 +22,7 @@ + namespace cbor { + + namespace constants { +-const char kUnsupportedMajorType[] = "Unsupported major type."; ++const char kUnsupportedMajorType[] = "Unsupported major type operation."; + } + + namespace { +@@ -156,7 +156,11 @@ std::optional Reader::DecodeCompleteDataItem(const Config& config, + case Value::Type::FLOAT_VALUE: + // Floating point values also go here since they are also type 7. + return DecodeToSimpleValueOrFloat(*header, config); +- case Value::Type::TAG: // We explicitly don't support TAG. ++ case Value::Type::TAG: ++ if (config.parse_tags) { ++ return ReadTagContent(*header, config, max_nesting_level); ++ } ++ break; + case Value::Type::NONE: + case Value::Type::INVALID_UTF8: + break; +@@ -347,6 +351,17 @@ std::optional Reader::ReadByteStringContent( + return Value(std::move(cbor_byte_string)); + } + ++std::optional Reader::ReadTagContent( ++ const Reader::DataItemHeader& header, ++ const Config& config, ++ int max_nesting_level) { ++ auto tagged_content = DecodeCompleteDataItem(config, max_nesting_level); ++ if (tagged_content.has_value()) { ++ tagged_content.value().SetTag(header.value); ++ } ++ return tagged_content; ++} ++ + std::optional Reader::ReadArrayContent( + const Reader::DataItemHeader& header, + const Config& config, diff --git a/chromium_edits/133.0.6835.3/components/cbor/reader.h.patch b/chromium_edits/133.0.6835.3/components/cbor/reader.h.patch new file mode 100644 index 00000000..2dbc0534 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/reader.h.patch @@ -0,0 +1,26 @@ +diff --git a/components/cbor/reader.h b/components/cbor/reader.h +index 5f11ba48ba494..d4c9c489da4b6 100644 +--- a/components/cbor/reader.h ++++ b/components/cbor/reader.h +@@ -131,6 +131,11 @@ class CBOR_EXPORT Reader { + // during decoding will set raise the `UNSUPPORTED_FLOATING_POINT_VALUE` + // error. + bool allow_floating_point = false; ++ ++ // If the parser encounters a TAG element, should it be parsed out and ++ // the tag value saved (true), or should the entire node and its content ++ // be discarded (false) ++ bool parse_tags = false; + }; + + Reader(const Reader&) = delete; +@@ -205,6 +210,9 @@ class CBOR_EXPORT Reader { + std::optional ReadMapContent(const DataItemHeader& header, + const Config& config, + int max_nesting_level); ++ std::optional ReadTagContent(const DataItemHeader& header, ++ const Config& config, ++ int max_nesting_level); + std::optional ReadByte(); + std::optional> ReadBytes(uint64_t num_bytes); + bool IsKeyInOrder(const Value& new_key, diff --git a/chromium_edits/133.0.6835.3/components/cbor/reader_unittest.cc.patch b/chromium_edits/133.0.6835.3/components/cbor/reader_unittest.cc.patch new file mode 100644 index 00000000..150e0c73 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/reader_unittest.cc.patch @@ -0,0 +1,47 @@ +diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc +index e5c02ceea3402..f26b8e77f6da3 100644 +--- a/components/cbor/reader_unittest.cc ++++ b/components/cbor/reader_unittest.cc +@@ -1449,5 +1449,42 @@ TEST(CBORReaderTest, AllowInvalidUTF8) { + EXPECT_FALSE(cbor); + EXPECT_EQ(Reader::DecoderError::INVALID_UTF8, error); + } ++TEST(CBORReaderTest, RejectsTagUnderDefaultConfig) { ++ static const uint8_t kTaggedCbor[] = { ++ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, ++ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, ++ 0x9d, 0xf6, 0x3a, 0x36, 0x5b ++ }; ++ Reader::Config config; ++ auto cbor = Reader::Read(kTaggedCbor, config); ++ EXPECT_FALSE(cbor.has_value()); ++} ++TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { ++ static const uint8_t kTaggedCbor[] = { ++ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, ++ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, ++ 0x9d, 0xf6, 0x3a, 0x36, 0x5b ++ }; ++ Reader::Config config; ++ config.parse_tags = true; ++ auto cbor = Reader::Read(kTaggedCbor, config); ++ EXPECT_TRUE(cbor.has_value()); ++ auto& v = cbor.value(); ++ EXPECT_TRUE(v.has_tag()); ++ EXPECT_EQ(v.GetTag(),42UL); ++ EXPECT_TRUE(v.is_bytestring()); ++ EXPECT_EQ(v.type(), Value::Type::BYTE_STRING); ++ auto& bytes = v.GetBytestring(); ++ EXPECT_EQ(bytes.size(), 37UL); ++ EXPECT_EQ(bytes.at(0), 0x00);//identity multibase (e.g. not base-encoded, bytes are themselves) ++ EXPECT_EQ(bytes.at(1), 0x01);//CID version 1 ++ EXPECT_EQ(bytes.at(2), 0x71);//codec = dag-cbor ++ EXPECT_EQ(bytes.at(3), 0x12);//multihash = 18 = sha2-256 ++ EXPECT_EQ(bytes.at(4), 0x20);//hash length = 32 bytes ++ EXPECT_EQ(bytes.at(5), 0x69);//first byte of hash digest ++ EXPECT_EQ(bytes.at(36),0x5b);//last byte of hash digest ++} + + } // namespace cbor diff --git a/chromium_edits/133.0.6835.3/components/cbor/values.cc.patch b/chromium_edits/133.0.6835.3/components/cbor/values.cc.patch new file mode 100644 index 00000000..890571d8 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/values.cc.patch @@ -0,0 +1,145 @@ +diff --git a/components/cbor/values.cc b/components/cbor/values.cc +index c43c6d8265220..337ca908c813f 100644 +--- a/components/cbor/values.cc ++++ b/components/cbor/values.cc +@@ -64,32 +64,34 @@ Value::Value(Type type) : type_(type) { + NOTREACHED_IN_MIGRATION(); + } + +-Value::Value(SimpleValue in_simple) +- : type_(Type::SIMPLE_VALUE), simple_value_(in_simple) { ++Value::Value(SimpleValue in_simple, uint64_t tag) ++ : type_(Type::SIMPLE_VALUE), simple_value_(in_simple), tag_(tag) { + CHECK(static_cast(in_simple) >= 20 && static_cast(in_simple) <= 23); + } + +-Value::Value(bool boolean_value) : type_(Type::SIMPLE_VALUE) { ++Value::Value(bool boolean_value, uint64_t tag) : type_(Type::SIMPLE_VALUE), tag_(tag) { + simple_value_ = boolean_value ? Value::SimpleValue::TRUE_VALUE + : Value::SimpleValue::FALSE_VALUE; + } + +-Value::Value(double float_value) +- : type_(Type::FLOAT_VALUE), float_value_(float_value) {} ++Value::Value(double float_value, uint64_t tag) ++ : type_(Type::FLOAT_VALUE), float_value_(float_value), tag_(tag) {} + +-Value::Value(int integer_value) +- : Value(base::checked_cast(integer_value)) {} ++Value::Value(int integer_value, uint64_t tag) ++ : Value(base::checked_cast(integer_value), tag) {} + +-Value::Value(int64_t integer_value) : integer_value_(integer_value) { ++Value::Value(int64_t integer_value, uint64_t tag) : integer_value_(integer_value), tag_(tag) { + type_ = integer_value >= 0 ? Type::UNSIGNED : Type::NEGATIVE; + } + +-Value::Value(base::span in_bytes) ++Value::Value(base::span in_bytes, uint64_t tag) + : type_(Type::BYTE_STRING), +- bytestring_value_(in_bytes.begin(), in_bytes.end()) {} ++ bytestring_value_(in_bytes.begin(), in_bytes.end()), ++ tag_(tag) ++ {} + +-Value::Value(base::span in_bytes, Type type) +- : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()) { ++Value::Value(base::span in_bytes, Type type, uint64_t tag) ++ : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()), tag_(tag) { + DCHECK(type_ == Type::BYTE_STRING || type_ == Type::INVALID_UTF8); + } + +@@ -115,7 +117,8 @@ Value::Value(std::string&& in_string, Type type) noexcept : type_(type) { + } + } + +-Value::Value(std::string_view in_string, Type type) : type_(type) { ++Value::Value(std::string_view in_string, Type type, uint64_t tag) ++: type_(type), tag_(tag) { + switch (type_) { + case Type::STRING: + new (&string_value_) std::string(); +@@ -131,16 +134,18 @@ Value::Value(std::string_view in_string, Type type) : type_(type) { + } + } + +-Value::Value(const ArrayValue& in_array) : type_(Type::ARRAY), array_value_() { ++Value::Value(const ArrayValue& in_array, uint64_t tag) ++: type_(Type::ARRAY), array_value_(), tag_(tag) { + array_value_.reserve(in_array.size()); + for (const auto& val : in_array) + array_value_.emplace_back(val.Clone()); + } + +-Value::Value(ArrayValue&& in_array) noexcept +- : type_(Type::ARRAY), array_value_(std::move(in_array)) {} ++Value::Value(ArrayValue&& in_array, uint64_t tag) noexcept ++ : type_(Type::ARRAY), array_value_(std::move(in_array)), tag_(tag) {} + +-Value::Value(const MapValue& in_map) : type_(Type::MAP), map_value_() { ++Value::Value(const MapValue& in_map, uint64_t tag) ++: type_(Type::MAP), map_value_(), tag_(tag) { + map_value_.reserve(in_map.size()); + for (const auto& it : in_map) + map_value_.emplace_hint(map_value_.end(), it.first.Clone(), +@@ -166,31 +171,36 @@ Value Value::Clone() const { + case Type::NONE: + return Value(); + case Type::INVALID_UTF8: +- return Value(bytestring_value_, Type::INVALID_UTF8); ++ return Value(bytestring_value_, Type::INVALID_UTF8, tag_); + case Type::UNSIGNED: + case Type::NEGATIVE: +- return Value(integer_value_); ++ return Value(integer_value_, tag_); + case Type::BYTE_STRING: +- return Value(bytestring_value_); ++ return Value(bytestring_value_, tag_); + case Type::STRING: +- return Value(string_value_); ++ return Value(string_value_, Type::STRING, tag_); + case Type::ARRAY: +- return Value(array_value_); ++ return Value(array_value_, tag_); + case Type::MAP: +- return Value(map_value_); ++ return Value(map_value_, tag_); + case Type::TAG: + NOTREACHED_IN_MIGRATION() << constants::kUnsupportedMajorType; + return Value(); + case Type::SIMPLE_VALUE: +- return Value(simple_value_); ++ return Value(simple_value_, tag_); + case Type::FLOAT_VALUE: +- return Value(float_value_); ++ return Value(float_value_, tag_); + } + + NOTREACHED_IN_MIGRATION(); + return Value(); + } + ++Value& Value::SetTag(uint64_t tag) noexcept { ++ tag_ = tag; ++ return *this; ++} ++ + Value::SimpleValue Value::GetSimpleValue() const { + CHECK(is_simple()); + return simple_value_; +@@ -256,9 +266,14 @@ const Value::BinaryValue& Value::GetInvalidUTF8() const { + return bytestring_value_; + } + ++uint64_t Value::GetTag() const { ++ CHECK(has_tag()); ++ return tag_; ++} ++ + void Value::InternalMoveConstructFrom(Value&& that) { + type_ = that.type_; +- ++ tag_ = that.tag_; + switch (type_) { + case Type::UNSIGNED: + case Type::NEGATIVE: diff --git a/chromium_edits/133.0.6835.3/components/cbor/values.h.patch b/chromium_edits/133.0.6835.3/components/cbor/values.h.patch new file mode 100644 index 00000000..5556e8c5 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/values.h.patch @@ -0,0 +1,79 @@ +diff --git a/components/cbor/values.h b/components/cbor/values.h +index d55369f1a71bf..7dabb368c51d6 100644 +--- a/components/cbor/values.h ++++ b/components/cbor/values.h +@@ -125,28 +125,29 @@ class CBOR_EXPORT Value { + + explicit Value(Type type); + +- explicit Value(SimpleValue in_simple); +- explicit Value(bool boolean_value); +- explicit Value(double in_float); ++ explicit Value(SimpleValue in_simple, uint64_t tag = NO_TAG); ++ explicit Value(bool boolean_value, uint64_t tag = NO_TAG); ++ explicit Value(double in_float, uint64_t tag = NO_TAG); + +- explicit Value(int integer_value); +- explicit Value(int64_t integer_value); ++ explicit Value(int integer_value, uint64_t tag = NO_TAG); ++ explicit Value(int64_t integer_value, uint64_t tag = NO_TAG); + explicit Value(uint64_t integer_value) = delete; + +- explicit Value(base::span in_bytes); ++ explicit Value(base::span in_bytes, uint64_t tag = NO_TAG); + explicit Value(BinaryValue&& in_bytes) noexcept; + + explicit Value(const char* in_string, Type type = Type::STRING); + explicit Value(std::string&& in_string, Type type = Type::STRING) noexcept; +- explicit Value(std::string_view in_string, Type type = Type::STRING); ++ explicit Value(std::string_view in_string, Type type = Type::STRING, uint64_t tag = NO_TAG); + +- explicit Value(const ArrayValue& in_array); +- explicit Value(ArrayValue&& in_array) noexcept; ++ explicit Value(const ArrayValue& in_array, uint64_t tag = NO_TAG); ++ explicit Value(ArrayValue&& in_array, uint64_t tag = NO_TAG) noexcept; + +- explicit Value(const MapValue& in_map); ++ explicit Value(const MapValue& in_map, uint64_t tag = NO_TAG); + explicit Value(MapValue&& in_map) noexcept; + + Value& operator=(Value&& that) noexcept; ++ Value& SetTag(uint64_t) noexcept; + + Value(const Value&) = delete; + Value& operator=(const Value&) = delete; +@@ -177,6 +178,7 @@ class CBOR_EXPORT Value { + bool is_string() const { return type() == Type::STRING; } + bool is_array() const { return type() == Type::ARRAY; } + bool is_map() const { return type() == Type::MAP; } ++ bool has_tag() const { return tag_ != NO_TAG; } + + // These will all fatally assert if the type doesn't match. + SimpleValue GetSimpleValue() const; +@@ -192,12 +194,13 @@ class CBOR_EXPORT Value { + const ArrayValue& GetArray() const; + const MapValue& GetMap() const; + const BinaryValue& GetInvalidUTF8() const; ++ uint64_t GetTag() const; + + private: + friend class Reader; + // This constructor allows INVALID_UTF8 values to be created, which only + // |Reader| and InvalidUTF8StringValueForTesting() may do. +- Value(base::span in_bytes, Type type); ++ Value(base::span in_bytes, Type type, uint64_t tag = NO_TAG); + + Type type_; + +@@ -211,6 +214,11 @@ class CBOR_EXPORT Value { + MapValue map_value_; + }; + ++ //This value specified as Invalid, ++ // used here to represent absence of TAG ++ constexpr static uint64_t NO_TAG = 0xFFFF; ++ uint64_t tag_ = NO_TAG; ++ + void InternalMoveConstructFrom(Value&& that); + void InternalCleanup(); + }; diff --git a/chromium_edits/133.0.6835.3/components/cbor/writer.cc.patch b/chromium_edits/133.0.6835.3/components/cbor/writer.cc.patch new file mode 100644 index 00000000..1950e174 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/writer.cc.patch @@ -0,0 +1,14 @@ +diff --git a/components/cbor/writer.cc b/components/cbor/writer.cc +index c4bfcfb602949..b92885a30971c 100644 +--- a/components/cbor/writer.cc ++++ b/components/cbor/writer.cc +@@ -47,6 +47,9 @@ bool Writer::EncodeCBOR(const Value& node, + if (max_nesting_level < 0) + return false; + ++ if (node.has_tag()) { ++ StartItem(Value::Type::TAG, node.GetTag()); ++ } + switch (node.type()) { + case Value::Type::NONE: { + StartItem(Value::Type::BYTE_STRING, 0); diff --git a/chromium_edits/133.0.6835.3/components/cbor/writer_unittest.cc.patch b/chromium_edits/133.0.6835.3/components/cbor/writer_unittest.cc.patch new file mode 100644 index 00000000..1acf5f7f --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/cbor/writer_unittest.cc.patch @@ -0,0 +1,36 @@ +diff --git a/components/cbor/writer_unittest.cc b/components/cbor/writer_unittest.cc +index ee11e7cb86712..b8942f1829a37 100644 +--- a/components/cbor/writer_unittest.cc ++++ b/components/cbor/writer_unittest.cc +@@ -523,4 +523,31 @@ TEST(CBORWriterTest, OverlyNestedCBOR) { + EXPECT_FALSE(Writer::Write(Value(map), 4).has_value()); + } + ++TEST(CBORWriterTest, CanWriteTag) { ++ std::array content{ ++ 0x00, 0x01, 0x71, 0x12, 0x20, ++ 0x69, 0xea, 0x07, 0x40, 0xf9, ++ 0x80, 0x7a, 0x28, 0xf4, 0xd9, ++ 0x32, 0xc6, 0x2e, 0x7c, 0x1c, ++ 0x83, 0xbe, 0x05, 0x5e, 0x55, ++ 0x07, 0x2c, 0x90, 0x26, 0x6a, ++ 0xb3, 0xe7, 0x9d, 0xf6, 0x3a, ++ 0x36, 0x5b ++ }; ++ Value to_write(content); ++ to_write.SetTag(42); ++ auto result = Writer::Write(to_write); ++ EXPECT_TRUE(result.has_value()); ++ auto& bytes = result.value(); ++ EXPECT_EQ(bytes.size(), 41UL); ++ EXPECT_EQ(bytes.at(0), 0xd8); ++ EXPECT_EQ(bytes.at(1), 0x2a); ++ EXPECT_EQ(bytes.at(2), 0x58); ++ EXPECT_EQ(bytes.at(3), 0x25); ++ for (auto i = 0UL; i < content.size(); ++i) { ++ ASSERT_LT(i + 4UL, bytes.size()); ++ ASSERT_EQ(content.at(i), bytes.at(i+4UL)); ++ } ++} ++ + } // namespace cbor diff --git a/chromium_edits/133.0.6835.3/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch b/chromium_edits/133.0.6835.3/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch new file mode 100644 index 00000000..ee376ce1 --- /dev/null +++ b/chromium_edits/133.0.6835.3/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch @@ -0,0 +1,13 @@ +diff --git a/components/open_from_clipboard/clipboard_recent_content_generic.cc b/components/open_from_clipboard/clipboard_recent_content_generic.cc +index 3683fadcc0914..440d4be132e5c 100644 +--- a/components/open_from_clipboard/clipboard_recent_content_generic.cc ++++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc +@@ -20,7 +20,7 @@ + namespace { + // Schemes appropriate for suggestion by ClipboardRecentContent. + const char* kAuthorizedSchemes[] = { +- url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, ++ url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, "ipfs", "ipns" + // TODO(mpearson): add support for chrome:// URLs. Right now the scheme + // for that lives in content and is accessible via + // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme diff --git a/chromium_edits/133.0.6835.3/net/dns/dns_config_service_linux.cc.patch b/chromium_edits/133.0.6835.3/net/dns/dns_config_service_linux.cc.patch new file mode 100644 index 00000000..fd7227a5 --- /dev/null +++ b/chromium_edits/133.0.6835.3/net/dns/dns_config_service_linux.cc.patch @@ -0,0 +1,18 @@ +diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc +index 7aaf9fa5b0b78..5a9f5b5a70dd9 100644 +--- a/net/dns/dns_config_service_linux.cc ++++ b/net/dns/dns_config_service_linux.cc +@@ -276,11 +276,11 @@ bool IsNsswitchConfigCompatible( + // Ignore any entries after `kDns` because Chrome will fallback to the + // system resolver if a result was not found in DNS. + return true; +- ++ case NsswitchReader::Service::kResolve: ++ break; + case NsswitchReader::Service::kMdns: + case NsswitchReader::Service::kMdns4: + case NsswitchReader::Service::kMdns6: +- case NsswitchReader::Service::kResolve: + case NsswitchReader::Service::kNis: + RecordIncompatibleNsswitchReason( + IncompatibleNsswitchReason::kIncompatibleService, diff --git a/chromium_edits/133.0.6835.3/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch b/chromium_edits/133.0.6835.3/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch new file mode 100644 index 00000000..663fe49e --- /dev/null +++ b/chromium_edits/133.0.6835.3/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch @@ -0,0 +1,15 @@ +diff --git a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc +index e1bc209c337c5..6fbac29fcddfd 100644 +--- a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc ++++ b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc +@@ -68,8 +68,8 @@ class URLSchemesRegistry final { + // is considered secure. Additional checks are performed to ensure that + // other http pages are filtered out. + service_worker_schemes({"http", "https"}), +- fetch_api_schemes({"http", "https"}), +- allowed_in_referrer_schemes({"http", "https"}) { ++ fetch_api_schemes({"http", "https", "ipfs", "ipns"}), ++ allowed_in_referrer_schemes({"http", "https", "ipfs", "ipns"}) { + for (auto& scheme : url::GetCorsEnabledSchemes()) + cors_enabled_schemes.insert(scheme.c_str()); + for (auto& scheme : url::GetCSPBypassingSchemes()) { diff --git a/chromium_edits/133.0.6835.3/url/BUILD.gn.patch b/chromium_edits/133.0.6835.3/url/BUILD.gn.patch new file mode 100644 index 00000000..be4bfca8 --- /dev/null +++ b/chromium_edits/133.0.6835.3/url/BUILD.gn.patch @@ -0,0 +1,32 @@ +diff --git a/url/BUILD.gn b/url/BUILD.gn +index f22b73bc29f06..df36977322ec7 100644 +--- a/url/BUILD.gn ++++ b/url/BUILD.gn +@@ -5,6 +5,7 @@ + import("//build/buildflag_header.gni") + import("//testing/libfuzzer/fuzzer_test.gni") + import("//testing/test.gni") ++import("//third_party/ipfs_client/args.gni") + import("features.gni") + + import("//build/config/cronet/config.gni") +@@ -67,6 +68,7 @@ component("url") { + public_deps = [ + "//base", + "//build:robolectric_buildflags", ++ "//third_party/ipfs_client:ipfs_buildflags", + ] + + configs += [ "//build/config/compiler:wexit_time_destructors" ] +@@ -89,6 +91,11 @@ component("url") { + public_configs = [ "//third_party/jdk" ] + } + ++ if (enable_ipfs) { ++ sources += [ "url_canon_ipfs.cc" ] ++ deps += [ "//third_party/ipfs_client:ipfs_client" ] ++ } ++ + if (is_win) { + # Don't conflict with Windows' "url.dll". + output_name = "url_lib" diff --git a/chromium_edits/133.0.6835.3/url/url_canon.h.patch b/chromium_edits/133.0.6835.3/url/url_canon.h.patch new file mode 100644 index 00000000..dbe10d9e --- /dev/null +++ b/chromium_edits/133.0.6835.3/url/url_canon.h.patch @@ -0,0 +1,26 @@ +diff --git a/url/url_canon.h b/url/url_canon.h +index 99e5ef40de5fd..a08834f62c3cc 100644 +--- a/url/url_canon.h ++++ b/url/url_canon.h +@@ -854,6 +854,21 @@ bool CanonicalizeMailtoURL(const char16_t* spec, + CanonOutput* output, + Parsed* new_parsed); + ++COMPONENT_EXPORT(URL) ++bool CanonicalizeIpfsURL(std::string_view spec, ++ const Parsed& parsed, ++ SchemeType scheme_type, ++ CharsetConverter* query_converter, ++ CanonOutput* output, ++ Parsed* new_parsed); ++COMPONENT_EXPORT(URL) ++bool CanonicalizeIpfsURL(std::basic_string_view spec, ++ const Parsed& parsed, ++ SchemeType scheme_type, ++ CharsetConverter* query_converter, ++ CanonOutput* output, ++ Parsed* new_parsed); ++ + // Part replacer -------------------------------------------------------------- + + // Internal structure used for storing separate strings for each component. diff --git a/chromium_edits/133.0.6835.3/url/url_canon_ipfs.cc b/chromium_edits/133.0.6835.3/url/url_canon_ipfs.cc new file mode 100644 index 00000000..e40732ee --- /dev/null +++ b/chromium_edits/133.0.6835.3/url/url_canon_ipfs.cc @@ -0,0 +1,54 @@ +#include "url_canon_internal.h" + +#include +#include + +#include + +bool url::CanonicalizeIpfsURL(std::string_view spec, + const Parsed& parsed, + SchemeType scheme_type, + CharsetConverter* charset_converter, + CanonOutput* output, + Parsed* output_parsed) { + if (spec.size() < 1) { + return false; + } + if ( parsed.host.len < 1 ) { + return false; + } + auto cid_str = spec.substr( parsed.host.begin, static_cast(parsed.host.len) ); + auto cid = ipfs::Cid(cid_str); + if ( !cid.valid() ) { + cid = ipfs::id_cid::forText( std::string{cid_str} + " is not a valid CID." ); + } + auto as_str = cid.to_string(); + if ( as_str.empty() ) { + return false; + } + std::string stdurl{ spec.substr(0UL, static_cast(parsed.host.begin)) }; + stdurl.append( as_str ); + spec.remove_prefix(parsed.host.end()); + stdurl.append(spec); + auto len = static_cast(stdurl.size()); + Parsed parsed_input; + ParseStandardURL(stdurl.data(), len, &parsed_input); + return CanonicalizeStandardURL( + stdurl.data(), + parsed_input, + scheme_type, + charset_converter, + output, output_parsed + ); +} +bool url::CanonicalizeIpfsURL(std::basic_string_view spec, + const Parsed& parsed, + SchemeType scheme_type, + CharsetConverter* query_converter, + CanonOutput* output, + Parsed* new_parsed) { + RawCanonOutput<2048> as8; + ConvertUTF16ToUTF8(spec.data(), spec.size(), &as8); + return CanonicalizeIpfsURL({as8.data(), as8.length()}, parsed, scheme_type, + query_converter, output, new_parsed); +} diff --git a/chromium_edits/133.0.6835.3/url/url_util.cc.patch b/chromium_edits/133.0.6835.3/url/url_util.cc.patch new file mode 100644 index 00000000..8d22ec10 --- /dev/null +++ b/chromium_edits/133.0.6835.3/url/url_util.cc.patch @@ -0,0 +1,45 @@ +diff --git a/url/url_util.cc b/url/url_util.cc +index 67c4c5f3ce124..b268390940561 100644 +--- a/url/url_util.cc ++++ b/url/url_util.cc +@@ -76,6 +76,8 @@ struct SchemeRegistry { + std::vector referrer_schemes = { + {kHttpsScheme, SCHEME_WITH_HOST_PORT_AND_USER_INFORMATION}, + {kHttpScheme, SCHEME_WITH_HOST_PORT_AND_USER_INFORMATION}, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that do not trigger mixed content warning. +@@ -84,6 +86,8 @@ struct SchemeRegistry { + kWssScheme, + kDataScheme, + kAboutScheme, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that normal pages cannot link to or access (i.e., with the same +@@ -105,6 +109,8 @@ struct SchemeRegistry { + kHttpsScheme, + kHttpScheme, + kDataScheme, ++ {"ipfs", SCHEME_WITH_HOST}, ++ {"ipns", SCHEME_WITH_HOST}, + }; + + // Schemes that can be used by web to store data (local storage, etc). +@@ -308,7 +314,12 @@ bool DoCanonicalize(const CHAR* spec, + success = CanonicalizeFileSystemURL( + spec, ParseFileSystemURL(std::basic_string_view(spec, spec_len)), + charset_converter, output, output_parsed); +- ++ } else if (DoCompareSchemeComponent(spec, scheme, "ipfs")) { ++ auto spec_view = std::basic_string_view(spec, spec_len); ++ // Switch multibase away from case-sensitive ones before continuing canonicalization. ++ auto parsed_input = ParseStandardURL(spec_view); ++ success = CanonicalizeIpfsURL(spec_view, parsed_input, scheme_type, ++ charset_converter, output, output_parsed); + } else if (DoIsStandard(spec, scheme, &scheme_type)) { + // All "normal" URLs. + success = CanonicalizeStandardURL( diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 0aa527e8..369a8405 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -302,8 +302,8 @@ function(setup_target_for_coverage_lcov) ${GENHTML_PATH} ${GENHTML_EXTRA_ARGS} ${Coverage_GENHTML_ARGS} - --rc genhtml_hi_limit=90 - --rc genhtml_med_limit=75 + --rc genhtml_hi_limit=90.9 + --rc genhtml_med_limit=74 --prefix "${BASEDIR}" --ignore-errors unused -o ${Coverage_NAME} diff --git a/cmake/patch.py b/cmake/patch.py index 31f58001..49903429 100755 --- a/cmake/patch.py +++ b/cmake/patch.py @@ -23,13 +23,13 @@ try: import requests -except Exception as ex: +except ModuleNotFoundError as ex: check_call([executable, "-m", "pip", "install", "requests"]) import requests verbose('Installed requests because of', ex) -VERSION_CLOSE_ENOUGH = 30120 +VERSION_CLOSE_ENOUGH = 30123 LARGE_INT = 9876543210 here = dirname(__file__) @@ -42,10 +42,10 @@ def osname() -> str: return "Windows" -def as_int(v): +def as_int(ver_str): result = 0 try: - for c in v.split("."): + for c in ver_str.split("."): result *= 10000 result += int(c) except ValueError: @@ -61,13 +61,9 @@ def closest_by_version(needle, haystack): def content_differs(ap, bp): if not isfile(ap) or not isfile(bp): return True - with open(ap) as a: - with open(bp) as b: - try: - return a.read() != b.read() - except Exception as e: - print(f"Error diffing {ap} against {bp}: {e}", file=stderr) - sys.exit(7) + with open(ap, encoding="utf-8") as a: + with open(bp, encoding="utf-8") as b: + return a.read() != b.read() class Result(Enum): @@ -125,7 +121,7 @@ def create_patch_file(self): to_path += ".rm" print("Remembering the removal of", from_path, "with", to_path) os.makedirs(to_dir, exist_ok=True) - with open(to_path, "w") as rm_f: + with open(to_path, "w", encoding='utf-8') as rm_f: rm_f.write( "//Remember to remove the corresponding file from the Chromium source tree" ) @@ -134,7 +130,7 @@ def create_patch_file(self): if diff_out: os.makedirs(to_dir, exist_ok=True) to_path += ".patch" - with open(to_path, "w") as to_f: + with open(to_path, "w", encoding='utf-8') as to_f: to_f.write(diff_out) print(to_path) self.git(["add", "url/url_canon_ipfs.cc"], Result.OrDie) @@ -168,7 +164,7 @@ def apply(self): rel = relpath(edit, edits_dir) to_path = join(self.csrc, rel) if ext == ".patch": - self.check_patch(edit, rel, to_path) + self.check_patch(edit, rel) elif ext == ".rm": if isfile(to_path): print("Remove", to_path, "due to", edit) @@ -197,7 +193,7 @@ def edit_evidence(text: str): return True return False - def check_patch(self, patch_path: str, relative: str, target_path: str): + def check_patch(self, patch_path: str, relative: str): if 0 == self.git( ["apply", "--check", "--reverse", "--verbose", patch_path], Result.ExitCodeOnly, @@ -210,7 +206,7 @@ def check_patch(self, patch_path: str, relative: str, target_path: str): if ec == 0: print("Patched", src, "with", patch_path) else: - with open(join(self.csrc, src)) as target_file: + with open(join(self.csrc, src), encoding='utf-8') as target_file: text = target_file.read() if self.edit_evidence(text): print( @@ -273,11 +269,11 @@ def recommend(self) -> str: for channel in channels: print("Considering channel", channel, file=stderr) versions = self.release_versions(channel) - for when, version in versions: - verbose(f"Found a release version: '{version}' from {ctime(when)}") - dist, cand = closest_by_version(version, avail) + for when, rel_ver in versions: + verbose(f"Found a release version: '{rel_ver}' from {ctime(when)}") + dist, cand = closest_by_version(rel_ver, avail) if dist < win_dist: - t = f"Suggesting {cand} which is {dist} close to {version} which was {channel} @ {ctime(when)}" + t = f"Suggesting {cand} which is {dist} close to {rel_ver} which was {channel} @ {ctime(when)}" print(t, file=stderr) win_dist = dist win_cand = cand @@ -318,7 +314,7 @@ def release_versions(self, channel, pfrm=None): resp = requests.get(url=chrom_url, params=parms, timeout=999) result = list(map(lambda x: (x["time"] / 1000, x["version"]), resp.json())) elec_url = "https://raw.githubusercontent.com/electron/electron/main/DEPS" - resp = requests.get(url=elec_url) + resp = requests.get(url=elec_url, timeout=999) result.sort(reverse=True) self.up_rels[key] = result return result @@ -355,20 +351,19 @@ def oldest(self): return self.most("Extended", ["Mac", "Windows"], 0) def recent_electron_branch_version(self): - with open(join(here, "recent-electron.txt")) as revf: + with open(join(here, "recent-electron.txt"), encoding="utf-8") as revf: return int(revf.read()) def set_recent_electron_branch_version(self, v): - with open(join(here, "recent-electron.txt"), "w") as revf: + with open(join(here, "recent-electron.txt"), "w", encoding="utf-8") as revf: revf.write(str(v)) call([self.gbin, "add", join("cmake", "recent-electron.txt")]) def electron_version(self, branch="main"): if f"electron-{branch}" in self.up_rels: return self.up_rels[f"electron-{branch}"] - resp = requests.get( - f"https://raw.githubusercontent.com/electron/electron/{branch}/DEPS" - ) + u = f"https://raw.githubusercontent.com/electron/electron/{branch}/DEPS" + resp = requests.get(u, timeout=999) toks = resp.text.split("'") i = toks.index("chromium_version") + 2 self.up_rels[f"electron-{branch}"] = toks[i] @@ -384,7 +379,6 @@ def electron_versions(self): rebv = ev except ValueError as e: verbose("Couldn't get next, possibly-nonexistent, electron version's chromium version.", e, type(e)) - pass result = {} for i in range(-2, 1): ev = i + rebv @@ -437,7 +431,7 @@ def out_of_date(self, p): file_path = join(dir_path, "components/cbor/reader_unittest.cc.patch") if not isfile(file_path): return True - with open(file_path) as f: + with open(file_path, encoding="utf-8") as f: lines = list(map(lambda x: x.strip(), f.readlines())) if ( "+ absl::optional cbor = Reader::Read(kTaggedCbor, config);" @@ -449,7 +443,7 @@ def out_of_date(self, p): if not isfile(file_path): verbose('No patching of', file_path) return True - with open(file_path) as f: + with open(file_path, encoding="utf-8") as f: lines = list(map(lambda x: x.strip(), f.readlines())) if not any(map(lambda x: 'x-scheme-handler/ipfs' in x, lines)): verbose(p, "No ipfs scheme in Linux installer", file_path) @@ -457,7 +451,7 @@ def out_of_date(self, p): file_path = f"{self.pdir}/{p}.patch" if not isfile(file_path): return False - with open(file_path) as f: + with open(file_path, encoding="utf-8") as f: lines = list(map(lambda x: x.strip(), f.readlines())) if not Patcher.has_file_line( lines, @@ -476,9 +470,9 @@ def out_of_date(self, p): return False @staticmethod - def has_file_line(lines: list[str], path: str, line: str): + def has_file_line(lines: list[str], path: str, line_txt: str): fl = Patcher.file_lines(lines, path) - return (line + "\n") in fl + return (line_txt + "\n") in fl @staticmethod def file_lines(lines: list[str], path): @@ -497,10 +491,10 @@ def list_ood(self, to_check: list[str], sense: bool, both: bool = False): oldest = self.oldest() newest = self.newest() gap = newest[0] - oldest[0] + VERSION_CLOSE_ENOUGH - min = oldest[0] - gap + min_ver = oldest[0] - gap min_date = time() - 3600 * 24 * 31 * 6 verbose( - f"Oldest supportable version: {oldest} , newest was: {newest} , gap: {gap} -> {min}" + f"Oldest supportable version: {oldest} , newest was: {newest} , gap: {gap} -> {min_ver}" ) for p in to_check: d = self.date_of(p) @@ -508,8 +502,8 @@ def list_ood(self, to_check: list[str], sense: bool, both: bool = False): if self.out_of_date(p): verbose(p, "failed compatibility checks") is_ood = True - elif d < min_date and as_int(p) < min: - verbose(d, "<", min_date, "and", as_int(p), "<", min) + elif d < min_date and as_int(p) < min_ver: + verbose(d, "<", min_date, "and", as_int(p), "<", min_ver) is_ood = True else: is_ood = False @@ -541,8 +535,8 @@ def list_ood(self, to_check: list[str], sense: bool, both: bool = False): for chan in ["Dev", "Beta", "Stable", "Extended"]: for osn in ["Linux", "Mac", "Windows"]: rels = per.release_versions(chan, osn) - for (n,v) in zip(['Cur', 'Prv', 'Old'], rels): - print(f"{v[1]:15} {n} {chan:9}{os:7}") + for (step_desc,verinf) in zip(['Cur', 'Prv', 'Old'], rels): + print(f"{verinf[1]:15} {step_desc} {chan:9}{os:7}") for (elec_br,chrom_ver) in per.electron_versions().items(): print(f"{chrom_ver:15} Electron {elec_br}") print(f"{per.electron_version():15} Electron main") @@ -573,13 +567,13 @@ def list_ood(self, to_check: list[str], sense: bool, both: bool = False): pr = Patcher(realpath(join(dirname(__file__), "..")), "git", "Debug") PREFIX = "?? component/patches/" SUFFIX = "patch" - for line in pr.git(["status", "--porcelain"], Result.RawOutput).splitlines(): - if line.startswith(PREFIX) and line.endswith(SUFFIX): - end = len(line) - len(SUFFIX) - 1 - pch = line[len(PREFIX): end] + for output_line in pr.git(["status", "--porcelain"], Result.RawOutput).splitlines(): + if output_line.startswith(PREFIX) and output_line.endswith(SUFFIX): + end = len(output_line) - len(SUFFIX) - 1 + pch = output_line[len(PREFIX): end] if pr.out_of_date(pch): sys.exit(9) else: - pr.git(["add", line[3:]], Result.OrDie) + pr.git(["add", output_line[3:]], Result.OrDie) else: Patcher(*argv[1:4]).create_patch_file() diff --git a/cmake/pylint_thresh.py b/cmake/pylint_thresh.py index 8ee8300c..bc9be907 100644 --- a/cmake/pylint_thresh.py +++ b/cmake/pylint_thresh.py @@ -5,7 +5,7 @@ from re import sub from sys import argv -THRESHOLD = 7.7 +THRESHOLD = 7.9 def msg_out(msg): f = msg["path"] @@ -16,8 +16,9 @@ def msg_out(msg): t = msg["type"] print(f"{f}:{l}:{c}: {t}: {i} {m}") -if __name__ == "__main__": - with open(argv[1]) as f: + +def parse(warn_file: str): + with open(warn_file, encoding="utf-8") as f: o = load(f) msgs = o['messages'] for warn in list(filter(lambda x:x['type']=='warning', msgs))[0:9]: @@ -31,6 +32,9 @@ def msg_out(msg): elif score > THRESHOLD + 0.3: update = (score + THRESHOLD) / 2 print("Increasing threshold to", update) - s = open(__file__).read() + s = open(__file__, encoding="utf-8").read() s = sub(r'\n\s*THRESHOLD\s*=\s*\d*\.\d*\s*\n', f"\n\nTHRESHOLD = {update:.2}\n\n", s) - open(__file__, 'w').write(s) + open(__file__, 'w', encoding="utf-8").write(s) + +if __name__ == "__main__": + parse(argv[1]) diff --git a/cmake/release.py b/cmake/release.py index e73b9fb6..5b140fb8 100755 --- a/cmake/release.py +++ b/cmake/release.py @@ -63,9 +63,9 @@ def line_to_var(line): return ('', None) -vars = check_output(['cmake', '-L', '-N', '-B', '.'], text=True).splitlines() -vars = dict(map(line_to_var, vars)) -chromium_out = join(vars['CHROMIUM_SOURCE_TREE'], 'out', vars['CHROMIUM_PROFILE']) +cmak_vars = check_output(['cmake', '-L', '-N', '-B', '.'], text=True).splitlines() +cmak_vars = dict(map(line_to_var, cmak_vars)) +chromium_out = join(cmak_vars['CHROMIUM_SOURCE_TREE'], 'out', cmak_vars['CHROMIUM_PROFILE']) tok = environ.get('GITHUB_TOKEN') if tok: gh = GhApi() @@ -95,10 +95,7 @@ def upload(contains): for ext in artifact_extensions: if f.endswith(ext): print('Uploading', f, 'to', GITHUB_ORG, GITHUB_REPO, 'release', version) - try: - gh.upload_file(gh_rel, f) - except Exception as e: - print(' ... Error uploading ', f, ':', e) + gh.upload_file(gh_rel, f) break diff --git a/library/include/ipfs_client/crypto/hasher.h b/library/include/ipfs_client/crypto/hasher.h index d7fcf289..02aa6dd4 100644 --- a/library/include/ipfs_client/crypto/hasher.h +++ b/library/include/ipfs_client/crypto/hasher.h @@ -13,7 +13,10 @@ class Hasher { public: virtual ~Hasher() noexcept {} - virtual std::optional> hash(ByteView) = 0; + /*! @param bytes Bytes to hash + * @return The digest or nullopt if there was an error + */ + virtual std::optional> hash(ByteView bytes) = 0; }; } // namespace ipfs::crypto diff --git a/library/include/ipfs_client/crypto/signature_verifier.h b/library/include/ipfs_client/crypto/signature_verifier.h index bd6865e5..70b73cca 100644 --- a/library/include/ipfs_client/crypto/signature_verifier.h +++ b/library/include/ipfs_client/crypto/signature_verifier.h @@ -11,6 +11,8 @@ namespace ipfs::crypto { class SignatureVerifier { public: virtual ~SignatureVerifier() noexcept {} + /*! Non-owned bytes + */ using ByteView = ipfs::ByteView; virtual bool VerifySignature(ByteView signature, ByteView data, diff --git a/library/include/ipfs_client/ctx/cbor_parser.h b/library/include/ipfs_client/ctx/cbor_parser.h index 7d8ca80b..0c51abe2 100644 --- a/library/include/ipfs_client/ctx/cbor_parser.h +++ b/library/include/ipfs_client/ctx/cbor_parser.h @@ -14,7 +14,10 @@ namespace ipfs::ctx { */ class CborParser { public: - virtual std::unique_ptr Parse(ByteView) = 0; + /*! @param cbor The CBOR to parse + * @return The DOM value, or NULL if there was an error + */ + virtual std::unique_ptr Parse(ByteView cbor) = 0; virtual ~CborParser() noexcept {} }; } // namespace ipfs::ctx diff --git a/library/include/ipfs_client/ctx/dns_txt_lookup.h b/library/include/ipfs_client/ctx/dns_txt_lookup.h index 7da94ca6..fd696760 100644 --- a/library/include/ipfs_client/ctx/dns_txt_lookup.h +++ b/library/include/ipfs_client/ctx/dns_txt_lookup.h @@ -10,6 +10,8 @@ namespace ipfs::ctx { */ class DnsTxtLookup { public: + /*! Callback for if usable result was achieved + */ using DnsTextResultsCallback = std::function const&)>; using DnsTextCompleteCallback = std::function; diff --git a/library/include/ipfs_client/ctx/gateway_config.h b/library/include/ipfs_client/ctx/gateway_config.h index 66838c24..d4c09b88 100644 --- a/library/include/ipfs_client/ctx/gateway_config.h +++ b/library/include/ipfs_client/ctx/gateway_config.h @@ -13,6 +13,10 @@ namespace ipfs::ctx { class GatewayConfig { public: virtual ~GatewayConfig() noexcept {} + /*! Position-based access (indexing) + * @param index The 0-based index of the gateway in question + * @return The spec for the gateway iff index < count of gateways, nullopt otherwise + */ virtual std::optional GetGateway(std::size_t index) const = 0; virtual unsigned GetGatewayRate(std::string_view url_prefix) = 0; virtual int GetTypeAffinity(std::string_view url_prefix, diff --git a/library/include/ipfs_client/ctx/http_api.h b/library/include/ipfs_client/ctx/http_api.h index f64b18bf..7037889c 100644 --- a/library/include/ipfs_client/ctx/http_api.h +++ b/library/include/ipfs_client/ctx/http_api.h @@ -10,6 +10,8 @@ namespace ipfs::ctx { */ class HttpApi { public: + /*! Description of the request to be sent + */ using ReqDesc = ::ipfs::HttpRequestDescription; using Hdrs = std::function; using OnComplete = std::function; diff --git a/library/include/ipfs_client/ctx/json_parser.h b/library/include/ipfs_client/ctx/json_parser.h index ec3a0e3c..6dfa77a4 100644 --- a/library/include/ipfs_client/ctx/json_parser.h +++ b/library/include/ipfs_client/ctx/json_parser.h @@ -14,7 +14,10 @@ namespace ipfs::ctx { class JsonParser { public: virtual ~JsonParser() noexcept {} - virtual std::unique_ptr Parse(std::string_view) = 0; + /*! @param json The JSON text to parse + * @return The DOM object or NULL if parsing failed. + */ + virtual std::unique_ptr Parse(std::string_view json) = 0; }; } // namespace ipfs::ctx diff --git a/library/include/ipfs_client/ctx/null_cbor_parser.h b/library/include/ipfs_client/ctx/null_cbor_parser.h index 047ab5f8..c74dff4c 100644 --- a/library/include/ipfs_client/ctx/null_cbor_parser.h +++ b/library/include/ipfs_client/ctx/null_cbor_parser.h @@ -7,6 +7,8 @@ namespace ipfs::ctx { */ class NullCborParser : public CborParser { public: + /*! @return NULL, always + */ std::unique_ptr Parse(ByteView) override { return {}; } diff --git a/library/include/ipfs_client/gw/dnslink_requestor.h b/library/include/ipfs_client/gw/dnslink_requestor.h index 8f0f0c44..6b3da28b 100644 --- a/library/include/ipfs_client/gw/dnslink_requestor.h +++ b/library/include/ipfs_client/gw/dnslink_requestor.h @@ -12,7 +12,9 @@ namespace ipfs::gw { */ class DnsLinkRequestor final : public Requestor { public: - explicit DnsLinkRequestor(std::shared_ptr); + /*! @param api The Client context API + */ + explicit DnsLinkRequestor(std::shared_ptr api); HandleOutcome handle(RequestPtr) override; std::string_view name() const override; diff --git a/library/include/ipfs_client/gw/gateway_request.h b/library/include/ipfs_client/gw/gateway_request.h index 8a4cce86..dd69f69c 100644 --- a/library/include/ipfs_client/gw/gateway_request.h +++ b/library/include/ipfs_client/gw/gateway_request.h @@ -38,10 +38,13 @@ constexpr std::size_t CAR_RESPONSE_BUFFER_SIZE = 5UL * 1024UL * 1024UL; */ class GatewayRequest : public std::enable_shared_from_this { public: + /*! Type for callbacks for when bytes are received + */ using BytesReceivedHook = std::function; private: + std::optional cid_; std::shared_ptr orchestrator_; std::vector bytes_received_hooks; std::string main_param; ///< CID, IPNS name, hostname @@ -64,11 +67,12 @@ class GatewayRequest : public std::enable_shared_from_this { // TODO - encapsulate. Hopefully these public data members aren't directly accessed everywhere std::string path; ///< For CAR requests std::shared_ptr dependent; - std::optional cid; short parallel = 0; std::string affinity; std::unordered_set failures; + std::optional const& cid() const; + void cid(Cid c); std::string url_suffix() const; std::string_view accept() const; std::string_view identity_data() const; @@ -79,6 +83,9 @@ class GatewayRequest : public std::enable_shared_from_this { std::string debug_string() const; void orchestrator(std::shared_ptr const&); bool cachable() const; + + /*! @return The part of the path that functions as an origin (the second component) + */ std::string_view root_component() const; void root_component(std::string_view); diff --git a/library/include/ipfs_client/gw/inline_request_handler.h b/library/include/ipfs_client/gw/inline_request_handler.h index ed298730..32e6e226 100644 --- a/library/include/ipfs_client/gw/inline_request_handler.h +++ b/library/include/ipfs_client/gw/inline_request_handler.h @@ -10,7 +10,11 @@ namespace ipfs::gw { */ class InlineRequestHandler final : public Requestor { public: - HandleOutcome handle(RequestPtr) override; + /*! @param request The request to try handling + * @return DONE (after responding) if it was an inline request + * NOT_HANDLED otherwise + */ + HandleOutcome handle(RequestPtr request) override; std::string_view name() const override; }; } // namespace ipfs::gw diff --git a/library/include/ipfs_client/gw/requestor.h b/library/include/ipfs_client/gw/requestor.h index 7eac8db6..cf2b03f9 100644 --- a/library/include/ipfs_client/gw/requestor.h +++ b/library/include/ipfs_client/gw/requestor.h @@ -41,6 +41,9 @@ class Requestor : public std::enable_shared_from_this { public: using RequestPtr = ::ipfs::gw::RequestPtr; + /*! @return The requestor's name, for debugging. + * Typically this is 1:1 with the concrete type. + */ virtual std::string_view name() const = 0; virtual ~Requestor() noexcept {} diff --git a/library/include/ipfs_client/gw/terminating_requestor.h b/library/include/ipfs_client/gw/terminating_requestor.h index 0e6816b4..3626c742 100644 --- a/library/include/ipfs_client/gw/terminating_requestor.h +++ b/library/include/ipfs_client/gw/terminating_requestor.h @@ -9,9 +9,8 @@ namespace ipfs::gw { */ class TerminatingRequestor : public Requestor { public: - using HandleOutcome = Requestor::HandleOutcome; std::string_view name() const override; - HandleOutcome handle(RequestPtr) override; + Requestor::HandleOutcome handle(RequestPtr) override; }; } // namespace ipfs::gw diff --git a/library/include/ipfs_client/ipld/block_source.h b/library/include/ipfs_client/ipld/block_source.h index f7944593..7bfef41c 100644 --- a/library/include/ipfs_client/ipld/block_source.h +++ b/library/include/ipfs_client/ipld/block_source.h @@ -10,6 +10,8 @@ namespace ipfs::ipld { /*! Description of where a particular block was fetched from, for diagnostics */ struct BlockSource { + /*! Source of now(). Defines timestamp type. + */ using Clock = std::chrono::system_clock; /*! Categorization of sources diff --git a/library/include/ipfs_client/ipld/dag_headers.h b/library/include/ipfs_client/ipld/dag_headers.h index 1a43e242..3fb656d8 100644 --- a/library/include/ipfs_client/ipld/dag_headers.h +++ b/library/include/ipfs_client/ipld/dag_headers.h @@ -14,6 +14,9 @@ class DagHeaders { public: void Add(BlockSource const&); void Finish(); + + /*! A list of HTTP header names and values + */ using HeaderList = std::vector>; HeaderList const& headers() const { return headers_; } diff --git a/library/include/ipfs_client/ipld/dag_node.h b/library/include/ipfs_client/ipld/dag_node.h index 8b48d1c3..dbffa493 100644 --- a/library/include/ipfs_client/ipld/dag_node.h +++ b/library/include/ipfs_client/ipld/dag_node.h @@ -73,6 +73,9 @@ class DagNode : public std::enable_shared_from_this { virtual ResolveResult resolve(ResolutionState& params) = 0; protected: + /*! The child nodes of this node, possibly not yet fetched. + * @note In some cases the string is empty. For example as stem node of a UnixFS (multi-node) file. + */ std::vector> links_; std::shared_ptr api_; @@ -147,7 +150,10 @@ class DagNode : public std::enable_shared_from_this { */ virtual bool PreferOver(DagNode const& another) const; - void set_api(std::shared_ptr); + /*! Provide the Client API to be used in DAG operations + * @param api Shared pointer to API for the context being run in + */ + void set_api(std::shared_ptr api); void source(BlockSource src) { source_ = src; } }; } // namespace ipfs::ipld diff --git a/library/include/ipfs_client/ipld/link.h b/library/include/ipfs_client/ipld/link.h index 43cb7c32..90a4feb2 100644 --- a/library/include/ipfs_client/ipld/link.h +++ b/library/include/ipfs_client/ipld/link.h @@ -19,7 +19,7 @@ class Link { Ptr node; /*! Construct an unresolved IPLD link - * @param The child's CID + * @param cid The child's CID */ explicit Link(std::string cid); /*! Construct a resolved IPLD link diff --git a/library/include/ipfs_client/ipld/resolution_state.h b/library/include/ipfs_client/ipld/resolution_state.h index 80e3e7eb..b0e51dad 100644 --- a/library/include/ipfs_client/ipld/resolution_state.h +++ b/library/include/ipfs_client/ipld/resolution_state.h @@ -25,7 +25,14 @@ class ResolutionState { BlockLookup get_available_block; public: - ResolutionState(SlashDelimited path_to_resolve, ResponseSemantic, BlockLookup); + /*! Construct from starting info + * @param path_to_resolve Relative to the node resolve is being called on + * @param semantic If the resolution results in a stem, i.e. a directory-like not a file, + * would the preference be for a listing preview HTML page -OR- + * JSON that describes the links to files and CIDs to merge in with this JSON (in the case of a sharded dir) + * @param lookup Functor that returns a pointer to a node for a given CID if it's already availabe, nullptr otherwise. + */ + ResolutionState(SlashDelimited path_to_resolve, ResponseSemantic semantic, BlockLookup lookup); SlashDelimited MyPath() const; SlashDelimited PathToResolve() const; diff --git a/library/include/ipfs_client/ipns_record.h b/library/include/ipfs_client/ipns_record.h index c85efc2d..c8a4a24e 100644 --- a/library/include/ipfs_client/ipns_record.h +++ b/library/include/ipfs_client/ipns_record.h @@ -54,7 +54,9 @@ struct ValidatedIpns { std::string gateway_source; ///< Who gave us this record? ValidatedIpns(); ///< Create an invalid default object - explicit ValidatedIpns(IpnsCborEntry const&); + /*! @param entry IPNS entry known to be valid + */ + explicit ValidatedIpns(IpnsCborEntry const& entry); ValidatedIpns(ValidatedIpns&&); ValidatedIpns(ValidatedIpns const&); ValidatedIpns& operator=(ValidatedIpns const&); diff --git a/library/include/ipfs_client/multi_base.h b/library/include/ipfs_client/multi_base.h index 71308112..e741aaec 100644 --- a/library/include/ipfs_client/multi_base.h +++ b/library/include/ipfs_client/multi_base.h @@ -42,7 +42,7 @@ struct Codec { * Should match the name found in the multibase table. */ std::string_view const name; - /*! @param Struct with the above fields filled + /*! @return Struct with the above fields filled * @param code The multibase to fetch */ static Codec const* Get(Code code); diff --git a/library/include/ipfs_client/partition.h b/library/include/ipfs_client/partition.h index 8c8b284d..6d0903b8 100644 --- a/library/include/ipfs_client/partition.h +++ b/library/include/ipfs_client/partition.h @@ -17,8 +17,6 @@ class Client; */ class Partition : public std::enable_shared_from_this { public: - using GatewayAccess = - std::function)>; using MimeDetection = std::function< std::string(std::string, std::string_view, std::string const&)>; void build_response(std::shared_ptr); diff --git a/library/include/ipfs_client/pb_dag.h b/library/include/ipfs_client/pb_dag.h index 60bf2cb5..7afc2d08 100644 --- a/library/include/ipfs_client/pb_dag.h +++ b/library/include/ipfs_client/pb_dag.h @@ -38,6 +38,10 @@ class PbDag { * It's just a container of arbitrary bytes. */ PbDag(Cid const& cid, ByteView bytes); + /*! Convenience constructor + * @param cid - The CID of the block + * @param bytes - The block + */ PbDag(Cid const& cid, std::string_view bytes); PbDag(PbDag const&); diff --git a/library/include/ipfs_client/response.h b/library/include/ipfs_client/response.h index ed8e918d..ccbfe702 100644 --- a/library/include/ipfs_client/response.h +++ b/library/include/ipfs_client/response.h @@ -24,6 +24,9 @@ struct Response { static Response PLAIN_NOT_FOUND; static Response IMMUTABLY_GONE; static Response HOST_NOT_FOUND_RESPONSE; + /*! @param body HTML text (the response of the body, not the `` + * @param location The Location header + */ static Response html(std::string_view body, std::string_view location = {}); }; diff --git a/library/include/vocab/raw_ptr.h b/library/include/vocab/raw_ptr.h index 25405d3e..4d7a3327 100644 --- a/library/include/vocab/raw_ptr.h +++ b/library/include/vocab/raw_ptr.h @@ -37,6 +37,8 @@ class raw_ptr { // construct. Set it to nullptr. We have time needed to read_start a word. raw_ptr() = delete; + /*! @param p Primitive raw pointer + */ raw_ptr(T* p) : ptr_{p} {} raw_ptr(raw_ptr&&) = default; raw_ptr(raw_ptr const&) = default; diff --git a/library/include/vocab/slash_delimited.h b/library/include/vocab/slash_delimited.h index 948a8a6a..988c57d8 100644 --- a/library/include/vocab/slash_delimited.h +++ b/library/include/vocab/slash_delimited.h @@ -17,6 +17,8 @@ struct SlashDelimited { public: SlashDelimited() : remainder_{""} {} + /*! @param unowned Text to parse into /-delimited components + */ explicit SlashDelimited(std::string_view unowned); explicit operator bool() const; std::string_view pop(); diff --git a/library/src/ipfs_client/car.cc b/library/src/ipfs_client/car.cc index c1037c28..b70ac87d 100644 --- a/library/src/ipfs_client/car.cc +++ b/library/src/ipfs_client/car.cc @@ -68,11 +68,11 @@ auto Self::NextBlock() -> std::optional { data_ = {}; return std::nullopt; } - Block rv; - rv.bytes = data_.subspan(0U, len->toUInt64()); + Block blk; + blk.bytes = data_.subspan(0U, len->toUInt64()); data_ = data_.subspan(len->toUInt64()); - if (rv.cid.ReadStart(rv.bytes)) { - return rv; + if (blk.cid.ReadStart(blk.bytes)) { + return blk; } return std::nullopt; } @@ -103,6 +103,7 @@ auto ReadHeader(ByteView& bytes, ipfs::ctx::CborParser& cbor_parser) -> short { } return 0; } +// NOLINTBEGIN(readability-magic-numbers) auto read_le_u64(ByteView bytes, unsigned& off) -> std::uint64_t { auto b = bytes.subspan(off, off + 8); off += 8U; @@ -142,4 +143,7 @@ auto GetV1PayloadPos(ByteView bytes) -> std::pair return {data_offset, data_size}; } +// NOLINTEND(readability-magic-numbers) + } // namespace + diff --git a/library/src/ipfs_client/cid.cc b/library/src/ipfs_client/cid.cc index 4f67ef67..72686e42 100644 --- a/library/src/ipfs_client/cid.cc +++ b/library/src/ipfs_client/cid.cc @@ -17,6 +17,26 @@ using Self = ipfs::Cid; using VarInt = libp2p::multi::UVarint; +namespace { +constexpr auto V0_TEXT_LEN = 46U; +constexpr auto V0_HASH_LEN = 32U; +constexpr auto V0_MULTIHASH_LEN = V0_HASH_LEN + 1U + 1U;// 1 byte for hash type, 1 for hash len +constexpr auto SHA2_256 = static_cast(ipfs::HashType::SHA2_256); + +auto starts_with_v0_binary_multihash(ipfs::ByteView bytes) { + if (bytes.size() < V0_MULTIHASH_LEN) { + return false; + } + if ( bytes[0] != ipfs::Byte{SHA2_256} ) { + return false; + } + if (bytes[1] != ipfs::Byte{V0_HASH_LEN}) { + return false; + } + return true; +} +} + Self::Cid(ipfs::MultiCodec cdc, ipfs::MultiHash hsh) : codec_{cdc}, hash_{std::move(hsh)} {} @@ -24,12 +44,12 @@ Self::Cid(ipfs::ByteView bytes) { ReadStart(bytes); } -Self::Cid(std::string_view s) { - if (s.size() == 46 && s[0] == 'Q' && s[1] == 'm') { - auto bytes = mb::Codec::Get(mb::Code::BASE58_BTC)->decode(s); +Self::Cid(std::string_view str) { + if (str.size() == V0_TEXT_LEN && str[0] == 'Q' && str[1] == 'm') { + auto bytes = mb::Codec::Get(mb::Code::BASE58_BTC)->decode(str); auto view = ByteView{bytes}; ReadStart(view); - } else if (auto bytes = mb::decode(s)) { + } else if (auto bytes = mb::decode(str)) { if (bytes->size() > 4) { auto view = ByteView{bytes.value()}; ReadStart(view); @@ -38,11 +58,11 @@ Self::Cid(std::string_view s) { } auto Self::ReadStart(ByteView& bytes) -> bool { - if (bytes.size() >= 34 && bytes[0] == ipfs::Byte{0x12} && - bytes[1] == ipfs::Byte{0x20}) { + // https://github.com/multiformats/cid?tab=readme-ov-file#decoding-algorithm + if (starts_with_v0_binary_multihash(bytes)) { hash_ = MultiHash{bytes}; codec_ = hash_.valid() ? MultiCodec::DAG_PB : MultiCodec::INVALID; - bytes = bytes.subspan(34); + bytes = bytes.subspan(V0_MULTIHASH_LEN); return true; } auto version = VarInt::create(bytes); @@ -78,12 +98,12 @@ auto Self::hash_type() const -> HashType { auto Self::to_string() const -> std::string { std::vector binary; auto append_varint = [&binary](auto x) { - auto i = static_cast(x); - VarInt const v{i}; - auto b = v.toBytes(); + auto val = static_cast(x); + VarInt const var_int{val}; + auto b = var_int.toBytes(); binary.insert(binary.end(), b.begin(), b.end()); }; - append_varint(1); // CID version 1 + append_varint(1);// CID version 1 append_varint(codec()); append_varint(hash_type()); append_varint(hash().size()); diff --git a/library/src/ipfs_client/crypto/openssl_sha2_256.cc b/library/src/ipfs_client/crypto/openssl_sha2_256.cc index 04ade2b0..ed45625f 100644 --- a/library/src/ipfs_client/crypto/openssl_sha2_256.cc +++ b/library/src/ipfs_client/crypto/openssl_sha2_256.cc @@ -23,10 +23,10 @@ auto Self::hash(ipfs::ByteView data) -> std::optional> { LOG(ERROR) << "Failure injesting data into SHA256."; return {}; } - std::vector rv(SHA256_DIGEST_LENGTH, Byte{}); - auto *p = reinterpret_cast(rv.data()); + std::vector result(SHA256_DIGEST_LENGTH, Byte{}); + auto *p = reinterpret_cast(result.data()); if (1 == SHA256_Final(p, &ctx)) { - return rv; + return result; } else { LOG(ERROR) << "Error calculating sha2-256 hash."; return std::nullopt; diff --git a/library/src/ipfs_client/ctx/default_gateways.cc b/library/src/ipfs_client/ctx/default_gateways.cc index b6683fe7..4880ebdf 100644 --- a/library/src/ipfs_client/ctx/default_gateways.cc +++ b/library/src/ipfs_client/ctx/default_gateways.cc @@ -16,42 +16,42 @@ auto ctx::LoadGatewaysFromEnvironmentVariable(ipfs::ctx::GatewayConfig& cfg) -> return false; } std::istringstream user_override{ovr}; - std::string gw; + std::string gw_pfx; bool at_least_one = false; - while (user_override >> gw) { - if (gw.empty()) { + while (user_override >> gw_pfx) { + if (gw_pfx.empty()) { continue; } - if (gw.back() != '/') { - gw.push_back('/'); + if (gw_pfx.back() != '/') { + gw_pfx.push_back('/'); } - cfg.AddGateway(gw, 300U); + cfg.AddGateway(gw_pfx, cfg.RoutingApiDiscoveryDefaultRate()); at_least_one = true; } return at_least_one; } - +// NOLINTBEGIN(readability-magic-numbers) void ctx::LoadStaticGatewayList(ipfs::ctx::GatewayConfig& cfg) { auto static_list = { - std::pair{"http://127.0.0.1:8080/", 1039}, - {"https://ipfs.io/", 1009}, - {"https://dweb.link/", 946}, - {"https://trustless-gateway.link/", 942}, - {"https://hardbin.com/", 918}, - {"https://ipfs.greyh.at/", 862}, - {"https://ipfs.joaoleitao.org/", 856}, - {"https://dlunar.net/", 697}, - {"https://flk-ipfs.io/", 681}, - {"https://ipfs.cyou/", 474}, - {"https://human.mypinata.cloud/", 415}, - {"https://jcsl.hopto.org/", 369}, - {"https://delegated-ipfs.dev/", 324}, - {"https://4everland.io/", 300}, - {"https://ipfs.runfission.com/", 268}, - {"https://gateway.pinata.cloud/", 144}, - {"https://dag.w3s.link/", 138}, - {"https://flk-ipfs.xyz/", 100}, - {"https://ipfs.eth.aragon.network/", 14}, + std::pair{"http://127.0.0.1:8080/", 1044}, + {"https://ipfs.io/", 997}, + {"https://dweb.link/", 938}, + {"https://trustless-gateway.link/", 935}, + {"https://hardbin.com/", 905}, + {"https://ipfs.greyh.at/", 855}, + {"https://ipfs.joaoleitao.org/", 843}, + {"https://dlunar.net/", 684}, + {"https://flk-ipfs.io/", 669}, + {"https://ipfs.cyou/", 467}, + {"https://human.mypinata.cloud/", 409}, + {"https://jcsl.hopto.org/", 355}, + {"https://delegated-ipfs.dev/", 312}, + {"https://4everland.io/", 294}, + {"https://ipfs.runfission.com/", 256}, + {"https://gateway.pinata.cloud/", 137}, + {"https://dag.w3s.link/", 131}, + {"https://flk-ipfs.xyz/", 109}, + {"https://ipfs.eth.aragon.network/", 11}, {"https://data.filstorage.io/", 10}, {"https://storry.tv/", 9}, @@ -71,3 +71,4 @@ void ctx::LoadStaticGatewayList(ipfs::ctx::GatewayConfig& cfg) { cfg.AddGateway(gw, rt); } } +// NOLINTEND(readability-magic-numbers) diff --git a/library/src/ipfs_client/ctx/null_http_provider.cc b/library/src/ipfs_client/ctx/null_http_provider.cc index 5f7fa430..65fbcb5c 100644 --- a/library/src/ipfs_client/ctx/null_http_provider.cc +++ b/library/src/ipfs_client/ctx/null_http_provider.cc @@ -3,8 +3,12 @@ using Self = ipfs::ctx::NullHttpProvider; -auto Self::SendHttpRequest(ReqDesc, OnComplete cb) const -> Canceller { +namespace { +constexpr auto INTERNAL_SERVER_ERROR_STATUS = 500; +} + +auto Self::SendHttpRequest(ReqDesc, OnComplete callback) const -> Canceller { auto hdrs = [](auto) { return std::string{}; }; - cb(500, "No HTTP networking available.", hdrs); + callback(INTERNAL_SERVER_ERROR_STATUS, "No HTTP networking available.", hdrs); return [](){}; } diff --git a/library/src/ipfs_client/ctx/transitory_gateway_config.cc b/library/src/ipfs_client/ctx/transitory_gateway_config.cc index 9e2d9399..cc68d22f 100644 --- a/library/src/ipfs_client/ctx/transitory_gateway_config.cc +++ b/library/src/ipfs_client/ctx/transitory_gateway_config.cc @@ -14,6 +14,10 @@ using Self = ipfs::ctx::TransitoryGatewayConfig; +namespace { +constexpr auto ONE_HZ = 60U; +} + Self::TransitoryGatewayConfig() { if (!LoadGatewaysFromEnvironmentVariable(*this)) { LoadStaticGatewayList(*this); @@ -29,11 +33,11 @@ auto Self::GetGateway(std::size_t index) const -> std::optionalprefix == prefix) { - it->rate++; + auto gw_it = FindGateway(prefix); + if (gateways_.end() != gw_it && gw_it->prefix == prefix) { + gw_it->rate++; } else { - gateways_.insert(it, GatewaySpec{std::string{prefix}, at_rate}); + gateways_.insert(gw_it, GatewaySpec{std::string{prefix}, at_rate}); DCHECK( std::is_sorted(gateways_.begin(), gateways_.end(), [](auto& a, auto& b) { return a.prefix < b.prefix; })); @@ -51,7 +55,7 @@ void Self::SetGatewayRate(std::string_view prefix, unsigned int rate) { } auto Self::GetGatewayRate(std::string_view prefix) -> unsigned { auto i = FindGateway(prefix); - return gateways_.end() == i ? 60U : i->rate; + return gateways_.end() == i ? ONE_HZ : i->rate; } auto Self::FindGateway(std::string_view prefix) -> std::vector::iterator { @@ -59,7 +63,7 @@ auto Self::FindGateway(std::string_view prefix) return std::lower_bound(gateways_.begin(), gateways_.end(), prefix, cmp); } auto Self::RoutingApiDiscoveryDefaultRate() const -> unsigned { - return 60U; + return ONE_HZ; } auto Self::RoutingApiDiscoveryOfUnencryptedGateways() const -> bool { return true; diff --git a/library/src/ipfs_client/gw/block_request_splitter.cc b/library/src/ipfs_client/gw/block_request_splitter.cc index ce5f882c..d4f8c509 100644 --- a/library/src/ipfs_client/gw/block_request_splitter.cc +++ b/library/src/ipfs_client/gw/block_request_splitter.cc @@ -15,12 +15,12 @@ using Self = ipfs::gw::BlockRequestSplitter; auto Self::name() const -> std::string_view { return "BlockRequestSplitter"; } -auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { - if (r->type != GatewayRequestType::Car) { +auto Self::handle(ipfs::gw::RequestPtr req) -> HandleOutcome { + if (req->type != GatewayRequestType::Car) { return HandleOutcome::NOT_HANDLED; } { - auto br = std::make_shared(*r); + auto br = std::make_shared(*req); br->type = GatewayRequestType::Block; br->path.clear(); forward(br); @@ -29,12 +29,12 @@ auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { auto it = std::find( recent_provider_requests.begin(), recent_provider_requests.end(), - r->affinity); + req->affinity); if (recent_provider_requests.end() == it) { auto i = old_provider_request % recent_provider_requests.size(); - recent_provider_requests[i] = r->affinity; + recent_provider_requests[i] = req->affinity; ++old_provider_request; - auto pr = std::make_shared(*r); + auto pr = std::make_shared(*req); pr->type = GatewayRequestType::Providers; pr->path.clear(); pr->affinity.clear(); diff --git a/library/src/ipfs_client/gw/gateway_request.cc b/library/src/ipfs_client/gw/gateway_request.cc index 6b402c6a..5a40a168 100644 --- a/library/src/ipfs_client/gw/gateway_request.cc +++ b/library/src/ipfs_client/gw/gateway_request.cc @@ -37,19 +37,14 @@ auto Self::fromIpfsPath(ipfs::SlashDelimited ipfs_path) -> std::shared_ptr auto name_space = ipfs_path.pop(); auto r = std::make_shared(); r->main_param = ipfs_path.pop(); - Cid cid(r->main_param); - if (cid.valid()) { - r->cid = std::move(cid); - } else { - r->cid = std::nullopt; - } + r->cid(Cid{r->main_param}); if (name_space == "ipfs") { - if (!r->cid.has_value()) { + if (!r->cid().has_value()) { LOG(ERROR) << "IPFS request with invalid/unsupported CID " << r->main_param; return {}; } - if (r->cid.value().hash_type() == HashType::IDENTITY) { + if (r->cid().value().hash_type() == HashType::IDENTITY) { r->type = GatewayRequestType::Identity; } else { r->path = ipfs_path.pop_all(); @@ -137,8 +132,8 @@ auto Self::identity_data() const -> std::string_view { if (type != GatewayRequestType::Identity) { return ""; } - auto hash = cid.value().hash(); - const auto *d = reinterpret_cast(hash.data()); + auto hash = cid_.value().hash(); + char const* d = reinterpret_cast(hash.data()); return std::string_view{d, hash.size()}; } @@ -276,7 +271,7 @@ auto Self::RespondSuccessfully(std::string_view bytes, if (c.valid()) { VLOG(1) << debug_string() << " resolves to " << c.to_string(); AddDnsLink("/ipfs/" + c.to_string(), success, src); - cid = c; + cid(c); AddBlock(bytes, success, src, api, valid); } else { AddDnsLink(bytes, success, src); @@ -345,8 +340,8 @@ auto Self::Finished() const -> bool { return false; } void Self::FleshOut(ipld::BlockSource& s) const { - if (cid.has_value() && cid->valid()) { - s.cid = cid->to_string(); + if (cid().has_value() && cid()->valid()) { + s.cid = cid()->to_string(); } else { s.cid = main_param; } @@ -368,14 +363,14 @@ void Self::AddBlock(std::string_view bytes, ipld::BlockSource src, std::shared_ptr const& api, bool* valid) { - DCHECK(cid.has_value()); - if (!cid.has_value()) { + DCHECK(cid().has_value()); + if (!cid().has_value()) { LOG(ERROR) << "Your CID doesn't even have a value!"; success = false; return; } DCHECK(api); - auto node = ipld::DagNode::fromBytes(api, cid.value(), bytes); + auto node = ipld::DagNode::fromBytes(api, cid().value(), bytes); if (!node) { success = false; } else { @@ -409,9 +404,9 @@ void Self::AddBlocks(Car& car, const std::shared_ptr& api, bool& success } } auto Self::IpnsResponse(ByteView bytes, std::shared_ptr const& api, bool& success, bool* valid, ipld::BlockSource src) -> bool { - if (cid.has_value()) { + if (cid().has_value()) { DCHECK(api); - auto rec = ipfs::ValidateIpnsRecord(bytes, cid.value(), *api); + auto rec = ipfs::ValidateIpnsRecord(bytes, cid().value(), *api); if (rec.has_value()) { ValidatedIpns const validated{rec.value()}; auto node = std::make_shared(validated); @@ -430,3 +425,14 @@ auto Self::IpnsResponse(ByteView bytes, std::shared_ptr const& api, bool } return true; } + +auto Self::cid() const -> std::optional const& { + return cid_; +} +void Self::cid(Cid cid) { + if (cid.valid()) { + cid_ = cid; + } else { + cid_ = {}; + } +} diff --git a/library/src/ipfs_client/gw/gateway_request_unittest.cc b/library/src/ipfs_client/gw/gateway_request_unittest.cc index a8fe97de..5f393e64 100644 --- a/library/src/ipfs_client/gw/gateway_request_unittest.cc +++ b/library/src/ipfs_client/gw/gateway_request_unittest.cc @@ -71,8 +71,7 @@ struct GatewayRequestTest : public testing::Test { TEST_F(GatewayRequestTest, RespondsToCar) { LogRecorder lr; - t_.cid = - i::Cid{"bafybeibwfakyszctcz54dungqay7jae35agjjhokltvvtboospgo6napxy"}; + t_.cid(i::Cid{"bafybeibwfakyszctcz54dungqay7jae35agjjhokltvvtboospgo6napxy"}); t_.type = RT::Car; auto p = reinterpret_cast(a_car.data()); EXPECT_FALSE(orc->has_key( @@ -114,6 +113,8 @@ TEST_F(GatewayRequestTest, accept_param) { EXPECT_EQ(t_.accept(), ""); t_.type = RT::Zombie; EXPECT_EQ(t_.accept(), ""); + t_.type = RT::DnsLink; + EXPECT_EQ(t_.accept(), "application/vnd.ipld.raw"); } TEST_F(GatewayRequestTest, timeouts_ordinal) { EXPECT_LT(timeout(RT::Identity), timeout(RT::DnsLink)); diff --git a/library/src/ipfs_client/gw/gateway_state.cc b/library/src/ipfs_client/gw/gateway_state.cc index 3f97d8e4..7bac9aaa 100644 --- a/library/src/ipfs_client/gw/gateway_state.cc +++ b/library/src/ipfs_client/gw/gateway_state.cc @@ -21,6 +21,7 @@ Self::GatewayState(std::string_view prefix, std::shared_ptr api) last_hist_update = std::time({}); sent_counts.fill(0U); } +// NOLINTBEGIN(readability-magic-numbers) auto Self::score(GatewayRequest const& req, unsigned baseline) const -> long { auto result = static_cast(baseline); result += 7L * cfg().GetTypeAffinity(prefix_, req.type); @@ -59,7 +60,7 @@ void Self::hit(GatewayRequestType grt, GatewayRequest const& req) { config.SetTypeAffinity(prefix_, grt, std::max(typaff + 9, 1)); affinity_success[req.affinity] += 9; auto rpm = config.GetGatewayRate(prefix_); - for (auto i = 8; i != 0; --i) { + for (auto i = 12; i != 0; --i) { if (over_rate(++rpm / i)) { ++rpm; } else { @@ -69,25 +70,25 @@ void Self::hit(GatewayRequestType grt, GatewayRequest const& req) { config.SetGatewayRate(prefix_, rpm); } auto Self::miss(GatewayRequestType grt, GatewayRequest const& req) -> bool { - auto& c = cfg(); - auto aff = c.GetTypeAffinity(prefix_, grt); + auto& config = cfg(); + auto aff = config.GetTypeAffinity(prefix_, grt); if (aff > std::numeric_limits::min()) { - c.SetTypeAffinity(prefix_, grt, --aff); + config.SetTypeAffinity(prefix_, grt, --aff); } - auto rpm = c.GetGatewayRate(prefix_); + auto rpm = config.GetGatewayRate(prefix_); if (rpm == 0U) { for (auto i = 0U;; ++i) { - if (auto gw = c.GetGateway(i)) { + if (auto gw = config.GetGateway(i)) { auto& p = gw->prefix; if (p != prefix_) { - c.SetGatewayRate(p, gw->rate + 1U); + config.SetGatewayRate(p, gw->rate + 1U); } } else { break; } } } else if (!over_rate(rpm)) { - c.SetGatewayRate(prefix_, rpm - 1); + config.SetGatewayRate(prefix_, rpm - 1); } return affinity_success[req.affinity]-- >= 0; } @@ -103,6 +104,7 @@ void Self::timed_out() { } c.SetGatewayRate(prefix_, rpm); } +// NOLINTEND(readability-magic-numbers) auto Self::cfg() -> ctx::GatewayConfig& { DCHECK(api_); return api_->gw_cfg(); diff --git a/library/src/ipfs_client/gw/gateway_state.h b/library/src/ipfs_client/gw/gateway_state.h index dd64c112..4030d7a2 100644 --- a/library/src/ipfs_client/gw/gateway_state.h +++ b/library/src/ipfs_client/gw/gateway_state.h @@ -38,7 +38,11 @@ class GatewayState { ctx::GatewayConfig const& cfg() const; public: - GatewayState(std::string_view prefix, std::shared_ptr); + /*! @param prefix The URL prefix that goes in front of HTTP requests to the gateway + * e.g. https://ipfs.io/ + * @param api Access to the functionality of this client's context + */ + GatewayState(std::string_view prefix, std::shared_ptr api); long score(GatewayRequest const&, unsigned) const; bool bored() const; bool over_rate(); diff --git a/library/src/ipfs_client/gw/inline_request_handler.cc b/library/src/ipfs_client/gw/inline_request_handler.cc index d6c2961b..fa0a7f1e 100644 --- a/library/src/ipfs_client/gw/inline_request_handler.cc +++ b/library/src/ipfs_client/gw/inline_request_handler.cc @@ -14,8 +14,8 @@ using Self = ipfs::gw::InlineRequestHandler; auto Self::name() const -> std::string_view { return "InlineRequestHandler"; } -auto Self::handle(RequestPtr reqp) -> HandleOutcome { - GatewayRequest& req = *reqp; +auto Self::handle(RequestPtr request) -> HandleOutcome { + GatewayRequest& req = *request; if (req.type != GatewayRequestType::Identity) { return HandleOutcome::NOT_HANDLED; } diff --git a/library/src/ipfs_client/gw/inline_request_handler_unittest.cc b/library/src/ipfs_client/gw/inline_request_handler_unittest.cc index 43813dba..c8599d03 100644 --- a/library/src/ipfs_client/gw/inline_request_handler_unittest.cc +++ b/library/src/ipfs_client/gw/inline_request_handler_unittest.cc @@ -27,7 +27,7 @@ TEST(InlineRequestHanlder, bluesky) { r->type = RT::Identity; r->orchestrator(orc); i::MultiHash h(i::HashType::IDENTITY, i::as_bytes("abc"sv)); - r->cid = Cid(i::MultiCodec::RAW, h); + r->cid({i::MultiCodec::RAW, h}); auto res = t.handle(r); EXPECT_EQ(static_cast(res), 'D'); } diff --git a/library/src/ipfs_client/gw/multi_gateway_requestor.h b/library/src/ipfs_client/gw/multi_gateway_requestor.h index f3b9397b..6d6eb274 100644 --- a/library/src/ipfs_client/gw/multi_gateway_requestor.h +++ b/library/src/ipfs_client/gw/multi_gateway_requestor.h @@ -31,6 +31,8 @@ class MultiGatewayRequestor : public Requestor { void Next(); public: + /*! @return "multi-gateway requestor" + */ std::string_view name() const override; HandleOutcome handle(RequestPtr) override; }; diff --git a/library/src/ipfs_client/gw/providers_response.cc b/library/src/ipfs_client/gw/providers_response.cc index 35a3d362..f436ef4d 100644 --- a/library/src/ipfs_client/gw/providers_response.cc +++ b/library/src/ipfs_client/gw/providers_response.cc @@ -75,8 +75,8 @@ auto ParseProvider(ipfs::DagJsonValue const& provider, ipfs::Client& api) -> boo LOG(WARNING) << "Gateway with no addrs"; return false; } - bool rv = false; - auto handle_addr = [&api, &rv](ipfs::DagJsonValue const& addr) { + bool res = false; + auto handle_addr = [&api, &res](ipfs::DagJsonValue const& addr) { if (auto s = addr.get_if_string()) { auto& c = api.gw_cfg(); auto http = c.RoutingApiDiscoveryOfUnencryptedGateways(); @@ -84,7 +84,7 @@ auto ParseProvider(ipfs::DagJsonValue const& provider, ipfs::Client& api) -> boo auto gw_pre = MultiaddrToGatewayPrefix(sd, http); if (static_cast(!gw_pre.empty()) != 0U) { c.AddGateway(gw_pre, c.RoutingApiDiscoveryDefaultRate()); - rv = true; + res = true; } } else { LOG(ERROR) << ".Providers[x].Addrs[x] is not a string"; @@ -96,7 +96,7 @@ auto ParseProvider(ipfs::DagJsonValue const& provider, ipfs::Client& api) -> boo LOG(WARNING) << ".Providers[x].Addrs is not a list"; handle_addr(*addrs); } - return rv; + return res; } } // namespace diff --git a/library/src/ipfs_client/ipfs_request.cc b/library/src/ipfs_client/ipfs_request.cc index 7807ac76..6208cae9 100644 --- a/library/src/ipfs_client/ipfs_request.cc +++ b/library/src/ipfs_client/ipfs_request.cc @@ -11,8 +11,8 @@ using Self = ipfs::IpfsRequest; -Self::IpfsRequest(std::string path_p, Finisher f) - : path_{std::move(path_p)}, callback_{std::move(f)}, semantic_{ResponseSemantic::Http} {} +Self::IpfsRequest(std::string path_p, Finisher fin) + : path_{std::move(path_p)}, callback_{std::move(fin)}, semantic_{ResponseSemantic::Http} {} Self::~IpfsRequest() noexcept { for (auto& cleanup : cleanups_) { diff --git a/library/src/ipfs_client/ipld/block_source.cc b/library/src/ipfs_client/ipld/block_source.cc index f9e2b753..30c1cd22 100644 --- a/library/src/ipfs_client/ipld/block_source.cc +++ b/library/src/ipfs_client/ipld/block_source.cc @@ -8,27 +8,14 @@ using Self = ipfs::ipld::BlockSource; - -/* -namespace { -#ifdef __cpp_lib_constexpr_string -constexpr auto a = - Self::Category{"a", ipfs::gw::GatewayRequestType::Block, true}; -constexpr auto b = - Self::Category{"a", ipfs::gw::GatewayRequestType::Identity, true}; -static_assert(a < b); -#endif -} // namespace -*/ - auto Self::Serialize() const -> std::string { std::ostringstream result; result << name(cat.request_type) << ' ' << cat.cached << ' ' << cid << ' ' << Clock::to_time_t(fetched_at) << ' ' << cat.gateway_url; return result.str(); } -void Self::Deserialize(std::string_view sv) { - std::istringstream iss{std::string{sv}}; +void Self::Deserialize(std::string_view from_string_view) { + std::istringstream iss{std::string{from_string_view}}; std::string s; std::time_t t; iss >> s >> cat.cached >> cid >> t; diff --git a/library/src/ipfs_client/ipld/chunk.cc b/library/src/ipfs_client/ipld/chunk.cc index f2985024..6aef88c1 100644 --- a/library/src/ipfs_client/ipld/chunk.cc +++ b/library/src/ipfs_client/ipld/chunk.cc @@ -14,15 +14,13 @@ constexpr std::uint16_t cSuccess = 200U; using Chunk = ipfs::ipld::Chunk; -Chunk::Chunk(std::string data) : data_{std::move(data)} {} +Chunk::Chunk(std::string bytes) : data_{std::move(bytes)} {} Chunk::~Chunk() noexcept = default; auto Chunk::resolve(ResolutionState& params) -> ResolveResult { if (params.IsFinalComponent()) { return Response{"", cSuccess, data_, params.MyPath().to_string(), {}}; } else { - VLOG(2) << "Can't resolve a path (" << params.MyPath() - << ") inside of a file chunk!"; return ProvenAbsent{}; } } diff --git a/library/src/ipfs_client/ipld/chunk.h b/library/src/ipfs_client/ipld/chunk.h index cb5a12c1..af173be6 100644 --- a/library/src/ipfs_client/ipld/chunk.h +++ b/library/src/ipfs_client/ipld/chunk.h @@ -16,7 +16,10 @@ class Chunk : public DagNode { ResolveResult resolve(ResolutionState&) override; public: - explicit Chunk(std::string); + /*! Construct + * @param bytes The blob itself + */ + explicit Chunk(std::string bytes); ~Chunk() noexcept override; }; } // namespace ipfs::ipld diff --git a/library/src/ipfs_client/ipld/dag_cbor_node.h b/library/src/ipfs_client/ipld/dag_cbor_node.h index d2547682..3a8630f2 100644 --- a/library/src/ipfs_client/ipld/dag_cbor_node.h +++ b/library/src/ipfs_client/ipld/dag_cbor_node.h @@ -12,6 +12,8 @@ class DagCborNode final : public DagNode { ResolveResult resolve(ResolutionState&) override; public: + /*! The dict or document being represented + */ using Data = DagCborValue; explicit DagCborNode(std::unique_ptr); ~DagCborNode() noexcept override; diff --git a/library/src/ipfs_client/ipld/dag_headers.cc b/library/src/ipfs_client/ipld/dag_headers.cc index 129e1eb2..b0e78b75 100644 --- a/library/src/ipfs_client/ipld/dag_headers.cc +++ b/library/src/ipfs_client/ipld/dag_headers.cc @@ -13,8 +13,8 @@ using ReqTyp = ipfs::gw::GatewayRequestType; namespace c = std::chrono; namespace { -auto describe(ReqTyp t) -> std::string_view { - switch (t) { +auto describe(ReqTyp typ) -> std::string_view { + switch (typ) { case ReqTyp::DnsLink: return "Resolving a DNSLink via DNS TXT record"; case ReqTyp::Ipns: diff --git a/library/src/ipfs_client/ipld/directory_shard.h b/library/src/ipfs_client/ipld/directory_shard.h index d7c897c7..37b0e859 100644 --- a/library/src/ipfs_client/ipld/directory_shard.h +++ b/library/src/ipfs_client/ipld/directory_shard.h @@ -4,6 +4,8 @@ #include namespace ipfs::ipld { +/*! A node in a sharded (HAMT) directory + */ class DirShard : public DagNode { std::uint64_t const fanout_; @@ -21,6 +23,7 @@ class DirShard : public DagNode { public: /*! Construct with a known fanout + * @param fanout The number of buckets */ explicit DirShard(std::uint64_t fanout = 256UL); ~DirShard() noexcept override; diff --git a/library/src/ipfs_client/ipld/link.cc b/library/src/ipfs_client/ipld/link.cc index b645cc12..8c3595e8 100644 --- a/library/src/ipfs_client/ipld/link.cc +++ b/library/src/ipfs_client/ipld/link.cc @@ -7,4 +7,7 @@ using Self = ipfs::ipld::Link; Self::Link(std::string cid_s) : cid{std::move(cid_s)} {} -Self::Link(std::string s, std::shared_ptr n) : cid{std::move(s)}, node{std::move(n)} {} +Self::Link(std::string cid, std::shared_ptr node) +: cid{std::move(cid)} +, node{std::move(node)} +{} diff --git a/library/src/ipfs_client/ipld/root.h b/library/src/ipfs_client/ipld/root.h index 7d8e2930..3cb604be 100644 --- a/library/src/ipfs_client/ipld/root.h +++ b/library/src/ipfs_client/ipld/root.h @@ -7,6 +7,9 @@ #include namespace ipfs::ipld { +/*! Since some operations will behave differently if a given node is being treated as + * a DAG root, this proxy wraps around a node to give it those properties + */ class Root : public DagNode { std::optional redirects_; @@ -16,7 +19,10 @@ class Root : public DagNode { bool expired() const override; public: - explicit Root(std::shared_ptr); + /*! Construct + * @param node The actual node being treated as a DAG root + */ + explicit Root(std::shared_ptr node); ~Root() noexcept override; }; } // namespace ipfs::ipld diff --git a/library/src/ipfs_client/ipld/symlink.h b/library/src/ipfs_client/ipld/symlink.h index 8d21a3aa..296e07b2 100644 --- a/library/src/ipfs_client/ipld/symlink.h +++ b/library/src/ipfs_client/ipld/symlink.h @@ -12,6 +12,12 @@ class Symlink : public DagNode { bool is_absolute() const; public: + /*! Construct from the text of the target + * @target Either a path relative to this node's, + * OR /an/absolute/path which is relative to the DAG root + * @note If it points outside the DAG it'll be considered broken. + * This can be achieved by simply using too many ../../.. + */ explicit Symlink(std::string target); ~Symlink() noexcept override; }; diff --git a/library/src/ipfs_client/ipns_names.cc b/library/src/ipfs_client/ipns_names.cc index 82667851..245f64b0 100644 --- a/library/src/ipfs_client/ipns_names.cc +++ b/library/src/ipfs_client/ipns_names.cc @@ -9,17 +9,18 @@ #include "ipfs_client/ipns_record.h" #include "log_macros.h" +using namespace std::literals; using Self = ipfs::IpnsNames; void Self::NoSuchName(std::string const& name) { names_[name]; // If it already exists, leave it. } -void Self::AssignName(std::string const& name, ValidatedIpns entry) { - auto& res = entry.value; +void Self::AssignName(std::string const& name, ValidatedIpns rec) { + auto& res = rec.value; if ((static_cast(!res.empty()) != 0U) && res.front() == '/') { res.erase(0, 1); } - auto endofcid = res.find_first_of("/?#", 6); + auto endofcid = res.find_first_of("/?#", "/ipns/"sv.size()); using namespace libp2p::multi; auto cid_str = res.substr(5, endofcid); LOG(INFO) << "IPNS points to CID " << cid_str; @@ -33,19 +34,19 @@ void Self::AssignName(std::string const& name, ValidatedIpns entry) { desensitized.append(extra); } LOG(INFO) << name << " now resolves to (desensitized)" << desensitized; - entry.value = desensitized; + rec.value = desensitized; } else { LOG(INFO) << name << " now resolves to (extra level)" << res; } - auto it = names_.find(name); - if (it == names_.end()) { - names_.emplace(name, std::move(entry)); - } else if (it->second.sequence < entry.sequence) { + auto nam_it = names_.find(name); + if (nam_it == names_.end()) { + names_.emplace(name, std::move(rec)); + } else if (nam_it->second.sequence < rec.sequence) { LOG(INFO) << "Updating IPNS record for " << name << " from sequence " - << it->second.sequence << " where it pointed to " - << it->second.value << " to sequence " << entry.sequence - << " where it points to " << entry.value; - it->second = std::move(entry); + << nam_it->second.sequence << " where it pointed to " + << nam_it->second.value << " to sequence " << rec.sequence + << " where it points to " << rec.value; + nam_it->second = std::move(rec); } else { LOG(INFO) << "Discarding redundant IPNS record for " << name; } diff --git a/library/src/ipfs_client/pb_dag.cc b/library/src/ipfs_client/pb_dag.cc index 282545e0..7dff6cda 100644 --- a/library/src/ipfs_client/pb_dag.cc +++ b/library/src/ipfs_client/pb_dag.cc @@ -37,15 +37,15 @@ auto get_bytes(std::string const& already_string) -> std::string { } auto get_bytes(std::istream& strm) -> std::string { - return std::string(std::istreambuf_iterator(strm), {}); + return {std::istreambuf_iterator(strm), {}}; } auto parse(ipfs::pb_dag::PBNode& n, std::istream& strm) -> bool { return n.ParseFromIstream(&strm); } -auto parse(ipfs::pb_dag::PBNode& n, std::string const& s) -> bool { - return n.ParseFromString(s); +auto parse(ipfs::pb_dag::PBNode& n, std::string const& str) -> bool { + return n.ParseFromString(str); } template diff --git a/library/src/ipfs_client/redirects.cc b/library/src/ipfs_client/redirects.cc index a380d4c0..37e52708 100644 --- a/library/src/ipfs_client/redirects.cc +++ b/library/src/ipfs_client/redirects.cc @@ -22,6 +22,7 @@ constexpr std::size_t MAX_SIZE = 64UL * 1024UL * 1024UL; // Not including \n which terminates lines constexpr std::string_view WHITESPACE = " \t\f\r\v\n"; +constexpr int MIN_SUPPORTED_STATUS = 200; // https://specs.ipfs.tech/http-gateways/web-redirects-file/#status constexpr int DEFAULT_STATUS = 301; // https://specs.ipfs.tech/http-gateways/web-redirects-file/#error-handling @@ -89,7 +90,7 @@ auto r::Directive::error() const -> std::string { if (to_.starts_with("ERROR: ")) { return to_; } - if (status_ < 200 || status_ > 451) { + if (status_ < MIN_SUPPORTED_STATUS || status_ > 451) { return "UNSUPPORTED STATUS " + std::to_string(status_); } if (components_.empty()) { @@ -201,18 +202,17 @@ auto r::File::parse_line(std::string_view line, int line_number) -> bool { namespace { -auto parse_status(std::string_view line, - std::size_t col) -> std::pair { +auto parse_status(std::string_view line, std::size_t col) -> std::pair { if (col >= line.size()) { return {DEFAULT_STATUS, ""}; } - auto b = line.find_first_not_of(WHITESPACE, col); - if (b >= line.size()) { + auto blank = line.find_first_not_of(WHITESPACE, col); + if (blank >= line.size()) { VLOG(2) << " No status specified (line ended in whitespace), using default."; return {DEFAULT_STATUS, ""}; } - auto status_str = line.substr(b); + auto status_str = line.substr(blank); if (status_str.size() < 3) { return {PARSE_ERROR_STATUS, " Not enough characters for a valid status string: [" + diff --git a/library/src/ipfs_client/redirects.h b/library/src/ipfs_client/redirects.h index ebb70e65..266cbf43 100644 --- a/library/src/ipfs_client/redirects.h +++ b/library/src/ipfs_client/redirects.h @@ -17,7 +17,11 @@ class Directive { int const status_; public: - Directive(std::string_view, std::string_view, int); + /*! @param from path/glob to match against + * @param to partial path to replace from with + * @param status HTTP status to use in successful response that hit this rule + */ + Directive(std::string_view from, std::string_view to, int status); std::uint16_t rewrite(std::string&) const; std::string error() const; bool valid() const { return error().empty(); } diff --git a/test_data/blocks/QmaMWB1zup8nMqK7MZ3z8p585DK2ymfhFtbDQnx2BSAhWC b/test_data/blocks/QmaMWB1zup8nMqK7MZ3z8p585DK2ymfhFtbDQnx2BSAhWC deleted file mode 100644 index 226fedd9..00000000 --- a/test_data/blocks/QmaMWB1zup8nMqK7MZ3z8p585DK2ymfhFtbDQnx2BSAhWC +++ /dev/null @@ -1,2 +0,0 @@ - -˜Vi4 Vi5 Vi6 Vi7 Vi8 Vi9 Vj0 Vj1 Vj2 Vj3 Vj4 Vj5 Vj6 Vj7 Vj8 Vj9 Vk0 Vk1 Vk2 Vk3 Vk4 Vk5 Vk6 Vk7 Vk8 Vk9 Vl0 Vl1 Vl2 Vl3 Vl4 Vl5 Vl6 Vl7 Vl8 Vl9  \ No newline at end of file diff --git a/test_data/blocks/QmaiKQaPhbXLCa7EA5nbRrjVt3XpZJKpWegqGFnbYucX98 b/test_data/blocks/QmaiKQaPhbXLCa7EA5nbRrjVt3XpZJKpWegqGFnbYucX98 deleted file mode 100644 index d0cd8172..00000000 --- a/test_data/blocks/QmaiKQaPhbXLCa7EA5nbRrjVt3XpZJKpWegqGFnbYucX98 +++ /dev/null @@ -1,2 +0,0 @@ - -˜Ew0 Ew1 Ew2 Ew3 Ew4 Ew5 Ew6 Ew7 Ew8 Ew9 Ex0 Ex1 Ex2 Ex3 Ex4 Ex5 Ex6 Ex7 Ex8 Ex9 Ey0 Ey1 Ey2 Ey3 Ey4 Ey5 Ey6 Ey7 Ey8 Ey9 Ez0 Ez1 Ez2 Ez3 Ez4 Ez5  \ No newline at end of file diff --git a/test_data/blocks/bafkreifckuj4pyhw5kuaumzx5ymaqg46f3ij4afpquy4r553evbhmqbh44 b/test_data/blocks/bafkreifckuj4pyhw5kuaumzx5ymaqg46f3ij4afpquy4r553evbhmqbh44 deleted file mode 100644 index 4f0734cb..00000000 --- a/test_data/blocks/bafkreifckuj4pyhw5kuaumzx5ymaqg46f3ij4afpquy4r553evbhmqbh44 +++ /dev/null @@ -1 +0,0 @@ -U \ No newline at end of file