Skip to content

Commit

Permalink
Good: 116.
Browse files Browse the repository at this point in the history
0.5817
.0.patch
  • Loading branch information
John-LittleBearLabs committed Jun 13, 2023
1 parent 78c2fde commit 7e2c273
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 359 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.goutputstream-*
__pycache__
CMakeLists.txt.user
CMakeUserPresets.json

1 change: 1 addition & 0 deletions cmake/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, chromium_source_dir, git_bin, build_type):

def create_patch_file(self):
tag = self.tag_name()
self.git(['add', 'url/url_canon_ipfs.cc'])
diff = self.git(['diff', '--patch', tag])
name = tag
if self.curr_hash() != self.hash_of(tag):
Expand Down
173 changes: 0 additions & 173 deletions component/patches/114.0.5720.4.patch

This file was deleted.

71 changes: 71 additions & 0 deletions component/patches/116.0.5817.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,77 @@ index 94b44426fa33a..19f1f0789164d 100644
// Part replacer --------------------------------------------------------------

// Internal structure used for storing separate strings for each component.
diff --git a/url/url_canon_ipfs.cc b/url/url_canon_ipfs.cc
new file mode 100644
index 0000000000000..9c9ee853f5739
--- /dev/null
+++ b/url/url_canon_ipfs.cc
@@ -0,0 +1,65 @@
+#include "url_canon_internal.h"
+
+#include <libp2p/multi/content_identifier_codec.hpp>
+
+namespace m = libp2p::multi;
+using Cid = m::ContentIdentifier;
+using CidCodec = m::ContentIdentifierCodec;
+
+bool url::CanonicalizeIpfsURL(const char* spec,
+ int spec_len,
+ const Parsed& parsed,
+ SchemeType scheme_type,
+ CharsetConverter* charset_converter,
+ CanonOutput* output,
+ Parsed* output_parsed) {
+ if ( spec_len < 1 ) {
+ return false;
+ }
+ if ( parsed.host.len < 1 ) {
+ return false;
+ }
+ std::string cid_str{ spec + parsed.host.begin, static_cast<std::size_t>(parsed.host.len) };
+ auto maybe_cid = CidCodec::fromString(cid_str);
+ if ( !maybe_cid.has_value() ) {
+ return false;
+ }
+ auto cid = maybe_cid.value();
+ if ( cid.version == Cid::Version::V0 ) {
+ //TODO dcheck content_type == DAG_PB && content_address.getType() == sha256
+ cid = Cid{
+ Cid::Version::V1,
+ cid.content_type,
+ cid.content_address
+ };
+ }
+ auto as_str = CidCodec::toString(cid);
+ if ( !as_str.has_value() ) {
+ return false;
+ }
+ std::string stdurl{ spec, static_cast<std::size_t>(parsed.host.begin) };
+ stdurl.append( as_str.value() );
+ stdurl.append( spec + parsed.host.end(), spec_len - parsed.host.end() );
+ spec = stdurl.data();
+ spec_len = static_cast<int>(stdurl.size());
+ Parsed parsed_input;
+ ParseStandardURL(spec, spec_len, &parsed_input);
+ return CanonicalizeStandardURL(
+ spec, spec_len,
+ parsed_input,
+ scheme_type,
+ charset_converter,
+ output, output_parsed
+ );
+}
+bool url::CanonicalizeIpfsURL(const char16_t* spec,
+ int spec_len,
+ const Parsed& parsed,
+ SchemeType scheme_type,
+ CharsetConverter* query_converter,
+ CanonOutput* output,
+ Parsed* new_parsed) {
+ RawCanonOutput<2048> as8;
+ ConvertUTF16ToUTF8(spec, spec_len, &as8);
+ return CanonicalizeIpfsURL(as8.data(), as8.length(), parsed, scheme_type, query_converter, output, new_parsed);
+}
diff --git a/url/url_util.cc b/url/url_util.cc
index 67913eb72f785..6b638acd8edc1 100644
--- a/url/url_util.cc
Expand Down
Loading

0 comments on commit 7e2c273

Please sign in to comment.