Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve bookmarks html reader #1986

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 62 additions & 18 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,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 @@ -3034,13 +3041,6 @@
remoteGlobalIDString = AA585D7D248FD31100E9A3E2;
remoteInfo = "DuckDuckGo Privacy Browser";
};
565E46E32B2725DD0013AC2A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
proxyType = 1;
remoteGlobalIDString = AA585D7D248FD31100E9A3E2;
remoteInfo = "DuckDuckGo Privacy Browser";
};
7B4CE8DF26F02108009134B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = AA585D76248FD31100E9A3E2 /* Project object */;
Expand Down Expand Up @@ -4061,6 +4061,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 @@ -4282,6 +4284,7 @@
buildActionMask = 2147483647;
files = (
3706FE88293F661700E42796 /* OHHTTPStubs in Frameworks */,
B65CD8CF2B316E0200A595BB /* SnapshotTesting in Frameworks */,
3706FE89293F661700E42796 /* OHHTTPStubsSwift in Frameworks */,
4B81AD372B29513100706C96 /* PixelKitTestingUtilities in Frameworks */,
);
Expand All @@ -4291,6 +4294,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8D12B316E0C00A595BB /* SnapshotTesting in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -4305,6 +4309,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8CD2B316DFC00A595BB /* SnapshotTesting in Frameworks */,
B6AE39F329374AEC00C37AA4 /* OHHTTPStubs in Frameworks */,
B6AE39F529374AEC00C37AA4 /* OHHTTPStubsSwift in Frameworks */,
);
Expand Down Expand Up @@ -4413,6 +4418,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B65CD8D32B316E1700A595BB /* SnapshotTesting in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -4474,6 +4480,7 @@
buildActionMask = 2147483647;
files = (
B6DA44172616C13800DD1EC2 /* OHHTTPStubs in Frameworks */,
B65CD8CB2B316DF100A595BB /* SnapshotTesting in Frameworks */,
B6DA44192616C13800DD1EC2 /* OHHTTPStubsSwift in Frameworks */,
4B81AD352B29512B00706C96 /* PixelKitTestingUtilities in Frameworks */,
);
Expand Down Expand Up @@ -4708,6 +4715,7 @@
373A1AA6283ECC8000586521 /* HTML */ = {
isa = PBXGroup;
children = (
B65CD8D72B341FD300A595BB /* README.md */,
373A1AA7283ED1B900586521 /* BookmarkHTMLReader.swift */,
373A1AAF2842C4EA00586521 /* BookmarkHTMLImporter.swift */,
);
Expand Down Expand Up @@ -5410,6 +5418,8 @@
4B723DFE26B0003E00E14D75 /* DataImport */ = {
isa = PBXGroup;
children = (
37A803DA27FD69D300052F4C /* DataImportResources */,
B65CD8D42B316FCA00A595BB /* __Snapshots__ */,
373A1AB128451ED400586521 /* BookmarksHTMLImporterTests.swift */,
373A1AA9283ED86C00586521 /* BookmarksHTMLReaderTests.swift */,
4B3F641D27A8D3BD00E0C118 /* BrowserProfileTests.swift */,
Expand All @@ -5426,7 +5436,6 @@
4B8AC93C26B49BE600879451 /* FirefoxLoginReaderTests.swift */,
4BB99D0E26FE1A84001E4761 /* SafariBookmarksReaderTests.swift */,
4BF4951726C08395000547B8 /* ThirdPartyBrowserTests.swift */,
37A803DA27FD69D300052F4C /* DataImportResources */,
);
path = DataImport;
sourceTree = "<group>";
Expand Down Expand Up @@ -8012,6 +8021,7 @@
3706FDD6293F661700E42796 /* OHHTTPStubs */,
3706FDD8293F661700E42796 /* OHHTTPStubsSwift */,
4B81AD362B29513100706C96 /* PixelKitTestingUtilities */,
B65CD8CE2B316E0200A595BB /* SnapshotTesting */,
);
productName = DuckDuckGoTests;
productReference = 3706FE99293F661700E42796 /* Unit Tests App Store.xctest */;
Expand All @@ -8033,6 +8043,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 @@ -8074,6 +8087,7 @@
packageProductDependencies = (
B6AE39F229374AEC00C37AA4 /* OHHTTPStubs */,
B6AE39F429374AEC00C37AA4 /* OHHTTPStubsSwift */,
B65CD8CC2B316DFC00A595BB /* SnapshotTesting */,
);
productName = "Integration Tests";
productReference = 4B1AD89D25FC27E200261379 /* Integration Tests.xctest */;
Expand Down Expand Up @@ -8267,7 +8281,6 @@
buildRules = (
);
dependencies = (
565E46E42B2725DD0013AC2A /* PBXTargetDependency */,
);
name = SyncE2EUITests;
productName = DuckDuckGoSyncUITests;
Expand All @@ -8289,6 +8302,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 @@ -8410,6 +8426,7 @@
B6DA44162616C13800DD1EC2 /* OHHTTPStubs */,
B6DA44182616C13800DD1EC2 /* OHHTTPStubsSwift */,
4B81AD342B29512B00706C96 /* PixelKitTestingUtilities */,
B65CD8CA2B316DF100A595BB /* SnapshotTesting */,
);
productName = DuckDuckGoTests;
productReference = AA585D90248FD31400E9A3E2 /* Unit Tests.xctest */;
Expand Down Expand Up @@ -8511,6 +8528,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 @@ -8616,6 +8634,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 @@ -8856,6 +8875,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 @@ -12018,10 +12038,6 @@
isa = PBXTargetDependency;
productRef = B6080BA42B20AF8800B418EF /* SwiftLintPlugin */;
};
B6080BA72B20AF8B00B418EF /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = B6080BA62B20AF8B00B418EF /* SwiftLintPlugin */;
};
B6080BA92B20AF8F00B418EF /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = B6080BA82B20AF8F00B418EF /* SwiftLintPlugin */;
Expand Down Expand Up @@ -12953,6 +12969,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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this, it's a great library!

repositoryURL = "https://github.com/AliSoftware/OHHTTPStubs.git";
Expand Down Expand Up @@ -13427,11 +13451,6 @@
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = "plugin:SwiftLintPlugin";
};
B6080BA62B20AF8B00B418EF /* SwiftLintPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = "plugin:SwiftLintPlugin";
};
B6080BA82B20AF8F00B418EF /* SwiftLintPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
Expand All @@ -13442,6 +13461,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
Loading