Skip to content

Commit

Permalink
Improve bookmarks html reader (#1986)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx authored Dec 21, 2023
1 parent 17d5a92 commit 6389927
Show file tree
Hide file tree
Showing 23 changed files with 1,678 additions and 146 deletions.
63 changes: 62 additions & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,13 @@
B65783E725F8AAFB00D8DB33 /* String+Punycode.swift in Sources */ = {isa = PBXBuildFile; fileRef = B65783E625F8AAFB00D8DB33 /* String+Punycode.swift */; };
B657841A25FA484B00D8DB33 /* NSException+Catch.m in Sources */ = {isa = PBXBuildFile; fileRef = B657841925FA484B00D8DB33 /* NSException+Catch.m */; };
B657841F25FA497600D8DB33 /* NSException+Catch.swift in Sources */ = {isa = PBXBuildFile; fileRef = B657841E25FA497600D8DB33 /* NSException+Catch.swift */; };
B65CD8CB2B316DF100A595BB /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = B65CD8CA2B316DF100A595BB /* SnapshotTesting */; };
B65CD8CD2B316DFC00A595BB /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = B65CD8CC2B316DFC00A595BB /* SnapshotTesting */; };
B65CD8CF2B316E0200A595BB /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = B65CD8CE2B316E0200A595BB /* SnapshotTesting */; };
B65CD8D12B316E0C00A595BB /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = B65CD8D02B316E0C00A595BB /* SnapshotTesting */; };
B65CD8D32B316E1700A595BB /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = B65CD8D22B316E1700A595BB /* SnapshotTesting */; };
B65CD8D52B316FCA00A595BB /* __Snapshots__ in Resources */ = {isa = PBXBuildFile; fileRef = B65CD8D42B316FCA00A595BB /* __Snapshots__ */; };
B65CD8D62B316FCA00A595BB /* __Snapshots__ in Resources */ = {isa = PBXBuildFile; fileRef = B65CD8D42B316FCA00A595BB /* __Snapshots__ */; };
B65DA5EF2A77CC3A00CBEE8D /* Bundle+NetworkProtectionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B602E81F2A1E2603006D261F /* Bundle+NetworkProtectionExtensions.swift */; };
B65DA5F02A77CC3C00CBEE8D /* Bundle+NetworkProtectionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B602E81F2A1E2603006D261F /* Bundle+NetworkProtectionExtensions.swift */; };
B65DA5F12A77D2BC00CBEE8D /* BundleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6106B9D26A565DA0013B453 /* BundleExtension.swift */; };
Expand Down Expand Up @@ -4058,6 +4065,8 @@
B657841825FA484B00D8DB33 /* NSException+Catch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSException+Catch.h"; sourceTree = "<group>"; };
B657841925FA484B00D8DB33 /* NSException+Catch.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSException+Catch.m"; sourceTree = "<group>"; };
B657841E25FA497600D8DB33 /* NSException+Catch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSException+Catch.swift"; sourceTree = "<group>"; };
B65CD8D42B316FCA00A595BB /* __Snapshots__ */ = {isa = PBXFileReference; lastKnownFileType = folder; path = __Snapshots__; sourceTree = "<group>"; };
B65CD8D72B341FD300A595BB /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
B65E6B9D26D9EC0800095F96 /* CircularProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressView.swift; sourceTree = "<group>"; };
B65E6B9F26D9F10600095F96 /* NSBezierPathExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSBezierPathExtension.swift; sourceTree = "<group>"; };
B66260DC29AC5D4300E9E3EE /* NavigationProtectionTabExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationProtectionTabExtension.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4280,6 +4289,7 @@
buildActionMask = 2147483647;
files = (
3706FE88293F661700E42796 /* OHHTTPStubs in Frameworks */,
B65CD8CF2B316E0200A595BB /* SnapshotTesting in Frameworks */,
3706FE89293F661700E42796 /* OHHTTPStubsSwift in Frameworks */,
4B81AD372B29513100706C96 /* PixelKitTestingUtilities in Frameworks */,
);
Expand All @@ -4289,6 +4299,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8D12B316E0C00A595BB /* SnapshotTesting in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -4303,6 +4314,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8CD2B316DFC00A595BB /* SnapshotTesting in Frameworks */,
B6AE39F329374AEC00C37AA4 /* OHHTTPStubs in Frameworks */,
B6AE39F529374AEC00C37AA4 /* OHHTTPStubsSwift in Frameworks */,
);
Expand Down Expand Up @@ -4413,6 +4425,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8D32B316E1700A595BB /* SnapshotTesting in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -4475,6 +4488,7 @@
buildActionMask = 2147483647;
files = (
B6DA44172616C13800DD1EC2 /* OHHTTPStubs in Frameworks */,
B65CD8CB2B316DF100A595BB /* SnapshotTesting in Frameworks */,
B6DA44192616C13800DD1EC2 /* OHHTTPStubsSwift in Frameworks */,
4B81AD352B29512B00706C96 /* PixelKitTestingUtilities in Frameworks */,
);
Expand Down Expand Up @@ -4709,6 +4723,7 @@
373A1AA6283ECC8000586521 /* HTML */ = {
isa = PBXGroup;
children = (
B65CD8D72B341FD300A595BB /* README.md */,
373A1AA7283ED1B900586521 /* BookmarkHTMLReader.swift */,
373A1AAF2842C4EA00586521 /* BookmarkHTMLImporter.swift */,
);
Expand Down Expand Up @@ -5411,6 +5426,8 @@
4B723DFE26B0003E00E14D75 /* DataImport */ = {
isa = PBXGroup;
children = (
37A803DA27FD69D300052F4C /* DataImportResources */,
B65CD8D42B316FCA00A595BB /* __Snapshots__ */,
373A1AB128451ED400586521 /* BookmarksHTMLImporterTests.swift */,
373A1AA9283ED86C00586521 /* BookmarksHTMLReaderTests.swift */,
4B3F641D27A8D3BD00E0C118 /* BrowserProfileTests.swift */,
Expand All @@ -5427,7 +5444,6 @@
4B8AC93C26B49BE600879451 /* FirefoxLoginReaderTests.swift */,
4BB99D0E26FE1A84001E4761 /* SafariBookmarksReaderTests.swift */,
4BF4951726C08395000547B8 /* ThirdPartyBrowserTests.swift */,
37A803DA27FD69D300052F4C /* DataImportResources */,
);
path = DataImport;
sourceTree = "<group>";
Expand Down Expand Up @@ -8014,6 +8030,7 @@
3706FDD6293F661700E42796 /* OHHTTPStubs */,
3706FDD8293F661700E42796 /* OHHTTPStubsSwift */,
4B81AD362B29513100706C96 /* PixelKitTestingUtilities */,
B65CD8CE2B316E0200A595BB /* SnapshotTesting */,
);
productName = DuckDuckGoTests;
productReference = 3706FE99293F661700E42796 /* Unit Tests App Store.xctest */;
Expand All @@ -8035,6 +8052,9 @@
37079A95294236FA0031BB3C /* PBXTargetDependency */,
);
name = "Integration Tests App Store";
packageProductDependencies = (
B65CD8D02B316E0C00A595BB /* SnapshotTesting */,
);
productName = "Integration Tests";
productReference = 3706FEB2293F662100E42796 /* Integration Tests App Store.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
Expand Down Expand Up @@ -8076,6 +8096,7 @@
packageProductDependencies = (
B6AE39F229374AEC00C37AA4 /* OHHTTPStubs */,
B6AE39F429374AEC00C37AA4 /* OHHTTPStubsSwift */,
B65CD8CC2B316DFC00A595BB /* SnapshotTesting */,
);
productName = "Integration Tests";
productReference = 4B1AD89D25FC27E200261379 /* Integration Tests.xctest */;
Expand Down Expand Up @@ -8292,6 +8313,9 @@
7B4CE8E026F02108009134B1 /* PBXTargetDependency */,
);
name = "UI Tests";
packageProductDependencies = (
B65CD8D22B316E1700A595BB /* SnapshotTesting */,
);
productName = "UI Tests";
productReference = 7B4CE8DA26F02108009134B1 /* UI Tests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
Expand Down Expand Up @@ -8414,6 +8438,7 @@
B6DA44162616C13800DD1EC2 /* OHHTTPStubs */,
B6DA44182616C13800DD1EC2 /* OHHTTPStubsSwift */,
4B81AD342B29512B00706C96 /* PixelKitTestingUtilities */,
B65CD8CA2B316DF100A595BB /* SnapshotTesting */,
);
productName = DuckDuckGoTests;
productReference = AA585D90248FD31400E9A3E2 /* Unit Tests.xctest */;
Expand Down Expand Up @@ -8515,6 +8540,7 @@
B6EC37F529B5DAAC001ACE79 /* XCRemoteSwiftPackageReference "swifter" */,
371D00DF29D8509400EC8598 /* XCRemoteSwiftPackageReference "OpenSSL-XCFramework" */,
4B2AAAF329E70DEA0026AFC0 /* XCRemoteSwiftPackageReference "lottie-ios" */,
B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
);
productRefGroup = AA585D7F248FD31100E9A3E2 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -8620,6 +8646,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8D62B316FCA00A595BB /* __Snapshots__ in Resources */,
3706FE8B293F661700E42796 /* empty in Resources */,
376E2D282942843D001CD31B /* privacy-reference-tests in Resources */,
3706FE8C293F661700E42796 /* atb-with-update.json in Resources */,
Expand Down Expand Up @@ -8860,6 +8887,7 @@
31E163C0293A581900963C10 /* privacy-reference-tests in Resources */,
B69B50542726CD8100758A2B /* atb-with-update.json in Resources */,
37A803DB27FD69D300052F4C /* DataImportResources in Resources */,
B65CD8D52B316FCA00A595BB /* __Snapshots__ in Resources */,
B69B50522726CD8100758A2B /* atb.json in Resources */,
4B70C00127B0793D000386ED /* DuckDuckGo-ExampleCrash.ips in Resources */,
4BCF15ED2ABB9B180083F6DF /* network-protection-messages.json in Resources */,
Expand Down Expand Up @@ -12953,6 +12981,14 @@
version = 2.5.1;
};
};
B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.15.1;
};
};
B6DA44152616C13800DD1EC2 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/AliSoftware/OHHTTPStubs.git";
Expand Down Expand Up @@ -13457,6 +13493,31 @@
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = "plugin:SwiftLintPlugin";
};
B65CD8CA2B316DF100A595BB /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
B65CD8CC2B316DFC00A595BB /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
B65CD8CE2B316E0200A595BB /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
B65CD8D02B316E0C00A595BB /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
B65CD8D22B316E1700A595BB /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = B65CD8C92B316DF100A595BB /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
B692D0DE2B209FB7003F2548 /* SwiftLintPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@
"version" : "1.3.0"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "59b663f68e69f27a87b45de48cb63264b8194605",
"version" : "1.15.1"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swifter",
"kind" : "remoteSourceControl",
Expand Down
17 changes: 4 additions & 13 deletions DuckDuckGo/DataImport/Bookmarks/Chromium/ImportedBookmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

import Foundation

struct ImportedBookmarks: Decodable {
struct ImportedBookmarks: Codable, Equatable {

struct BookmarkOrFolder: Decodable {
struct BookmarkOrFolder: Codable, Equatable {
let name: String
let type: String
let urlString: String?
let isDDGFavorite: Bool
var isDDGFavorite: Bool = false

let children: [BookmarkOrFolder]?

Expand Down Expand Up @@ -62,15 +62,6 @@ struct ImportedBookmarks: Decodable {
case children
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decode(String.self, forKey: .name)
type = try container.decode(String.self, forKey: .type)
urlString = try container.decodeIfPresent(String.self, forKey: .urlString)
children = try container.decodeIfPresent([BookmarkOrFolder].self, forKey: .children)
isDDGFavorite = false
}

init(name: String, type: String, urlString: String?, children: [BookmarkOrFolder]?, isDDGFavorite: Bool = false) {
self.name = name.trimmingWhitespace()
self.type = type
Expand All @@ -80,7 +71,7 @@ struct ImportedBookmarks: Decodable {
}
}

struct TopLevelFolders: Decodable {
struct TopLevelFolders: Codable, Equatable {
let bookmarkBar: BookmarkOrFolder
let otherBookmarks: BookmarkOrFolder

Expand Down
Loading

0 comments on commit 6389927

Please sign in to comment.