From c5bd54033c0cccebc55d9279692bb1deb626ab33 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 10:35:47 -0300 Subject: [PATCH 1/9] Update WordPressKit --- Podfile | 8 ++++---- Podfile.lock | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Podfile b/Podfile index 2cf910c5b27f..9065c721f87d 100644 --- a/Podfile +++ b/Podfile @@ -43,9 +43,9 @@ def wordpress_ui end def wordpress_kit - pod 'WordPressKit', '~> 5.0.0-beta.2' + #pod 'WordPressKit', '~> 5.0.0-beta.2' #pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :tag => '' - #pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => 'issue/14224-add-zendesk-plan-field' + pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => 'issue/14313_remove_post_content_sanitization' #pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => '' #pod 'WordPressKit', :path => '../WordPressKit-iOS' end @@ -207,7 +207,7 @@ target 'WordPress' do post_install do project_root = File.dirname(__FILE__) - + puts 'Patching RCTShadowView to fix nested group block - it could be removed after upgrade to 0.62' %x(patch "#{project_root}/Pods/React-Core/React/Views/RCTShadowView.m" < "#{project_root}/patches/react-native+0.61.5.patch") puts 'Patching RCTActionSheet to add possibility to disable action sheet buttons - @@ -216,7 +216,7 @@ target 'WordPress' do ## Convert the 3rd-party license acknowledgements markdown into html for use in the app require 'commonmarker' - + acknowledgements = 'Acknowledgments' markdown = File.read("#{project_root}/Pods/Target Support Files/Pods-WordPress/Pods-WordPress-acknowledgements.markdown") rendered_html = CommonMarker.render_html(markdown, :DEFAULT) diff --git a/Podfile.lock b/Podfile.lock index a10dc3dd82db..529b85508818 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -392,7 +392,7 @@ PODS: - WordPressKit (~> 5.0.0-beta.1) - WordPressShared (~> 1.9.0-beta.1) - WordPressUI (~> 1.7.0) - - WordPressKit (5.0.0-beta.2): + - WordPressKit (5.0.0-beta.1): - Alamofire (~> 4.8.0) - CocoaLumberjack (~> 3.4) - NSObject-SafeExpectations (= 0.0.4) @@ -484,7 +484,7 @@ DEPENDENCIES: - SVProgressHUD (= 2.2.5) - WordPress-Editor-iOS (~> 1.19.2) - WordPressAuthenticator (~> 1.18.0-beta.9) - - WordPressKit (~> 5.0.0-beta.2) + - WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, branch `issue/14313_remove_post_content_sanitization`) - WordPressMocks (~> 0.0.8) - WordPressShared (~> 1.9.0-beta.1) - WordPressUI (~> 1.7.0) @@ -533,7 +533,6 @@ SPEC REPOS: - WordPress-Aztec-iOS - WordPress-Editor-iOS - WordPressAuthenticator - - WordPressKit - WordPressMocks - WordPressShared - WordPressUI @@ -618,6 +617,9 @@ EXTERNAL SOURCES: RNTAztecView: :git: http://github.com/wordpress-mobile/gutenberg-mobile/ :tag: v1.30.0 + WordPressKit: + :branch: issue/14313_remove_post_content_sanitization + :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.30.0/react-native-gutenberg-bridge/third-party-podspecs/Yoga.podspec.json @@ -631,6 +633,9 @@ CHECKOUT OPTIONS: RNTAztecView: :git: http://github.com/wordpress-mobile/gutenberg-mobile/ :tag: v1.30.0 + WordPressKit: + :commit: fd3d6ca9fd62a83f2c02e28202729015897b682f + :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git SPEC CHECKSUMS: 1PasswordExtension: f97cc80ae58053c331b2b6dc8843ba7103b33794 @@ -704,7 +709,7 @@ SPEC CHECKSUMS: WordPress-Aztec-iOS: d01bf0c5e150ae6a046f06ba63b7cc2762061c0b WordPress-Editor-iOS: 5b726489e5ae07b7281a2862d69aba2d5c83f140 WordPressAuthenticator: 8567813769caf5e570d3370c907422a17c174c2b - WordPressKit: 94d62968d29761a38534e26df103fa2fe222130c + WordPressKit: 48ef1d76727cde146db44097cfb89852b171aa72 WordPressMocks: b4064b99a073117bbc304abe82df78f2fbe60992 WordPressShared: bc1a056b5d4da040e3addf4f510c0de67651ab1b WordPressUI: 1cf47a3b78154faf69caa18569ee7ece1e510fa0 @@ -720,6 +725,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: a87ab1e4badace92c75eb11dc77ede1e995b2adc ZIPFoundation: 249fa8890597086cd536bb2df5c9804d84e122b0 -PODFILE CHECKSUM: e883e836d5fe11167803b7446b3aa621e5580a02 +PODFILE CHECKSUM: 9627a7d673b5388957989c63c97707de6bc29400 COCOAPODS: 1.8.4 From 6554e65fde0ad8e20cac11d9e7afcebd3345c18a Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 10:46:31 -0300 Subject: [PATCH 2/9] If the Reader Webview feature flag is disabled, sanitize the content --- WordPress/Classes/Models/ReaderPost.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WordPress/Classes/Models/ReaderPost.m b/WordPress/Classes/Models/ReaderPost.m index c9e86a598109..1f6b166511ee 100644 --- a/WordPress/Classes/Models/ReaderPost.m +++ b/WordPress/Classes/Models/ReaderPost.m @@ -321,4 +321,13 @@ - (NSDictionary *)railcarDictionary return nil; } +- (NSString *)contentForDisplay +{ + if ([Feature enabled:FeatureFlagReaderWebview]) { + return self.content; + } else { + return [RichContentFormatter formatContentString:self.content isPrivateSite:self.isPrivate]; + } +} + @end From 99e500e1432cd5bb49fa411b0c409e7966ac2c73 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 10:53:07 -0300 Subject: [PATCH 3/9] Make contentForDisplay a lazy var so it only loads once --- .../Reader/ReaderDetailViewController.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift b/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift index cc3481d8037c..a20aed00e2c5 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift @@ -148,6 +148,10 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora } } + lazy var postContent: String? = { + return post?.contentForDisplay() + }() + open var postURL: URL? = nil fileprivate var isLoaded: Bool { @@ -801,7 +805,8 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora } fileprivate func configureRichText() { - guard let post = post else { + guard let post = post, + let contentForDisplay = postContent else { return } @@ -809,14 +814,14 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora // We'll log the error, so we know it's there, but we won't halt execution. CrashLogging.logError(error) }) - textView.content = post.contentForDisplay() + textView.content = contentForDisplay updateRichText() updateTextViewMargins() } private func updateRichText() { - guard let post = post else { + guard let contentForDisplay = postContent else { return } @@ -824,15 +829,15 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora let isDark = traitCollection.userInterfaceStyle == .dark textView.attributedText = isDark ? darkTextViewAttributedString : lightTextViewAttributedString } else { - let attrStr = WPRichContentView.formattedAttributedStringForString(post.contentForDisplay()) + let attrStr = WPRichContentView.formattedAttributedStringForString(contentForDisplay) textView.attributedText = attributedString(with: attrStr) } } private func configureAttributedString() { - if #available(iOS 13, *), let post = post { - let light = WPRichContentView.formattedAttributedString(for: post.contentForDisplay(), style: .light) - let dark = WPRichContentView.formattedAttributedString(for: post.contentForDisplay(), style: .dark) + if #available(iOS 13, *), let contentForDisplay = postContent { + let light = WPRichContentView.formattedAttributedString(for: contentForDisplay, style: .light) + let dark = WPRichContentView.formattedAttributedString(for: contentForDisplay, style: .dark) lightTextViewAttributedString = attributedString(with: light) darkTextViewAttributedString = attributedString(with: dark) } From 78279a84d73ba6e66f29271aecccab454745baf8 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 13:47:36 -0300 Subject: [PATCH 4/9] Revert "If the Reader Webview feature flag is disabled, sanitize the content" This reverts commit 6554e65fde0ad8e20cac11d9e7afcebd3345c18a. --- WordPress/Classes/Models/ReaderPost.m | 9 --------- 1 file changed, 9 deletions(-) diff --git a/WordPress/Classes/Models/ReaderPost.m b/WordPress/Classes/Models/ReaderPost.m index 1f6b166511ee..c9e86a598109 100644 --- a/WordPress/Classes/Models/ReaderPost.m +++ b/WordPress/Classes/Models/ReaderPost.m @@ -321,13 +321,4 @@ - (NSDictionary *)railcarDictionary return nil; } -- (NSString *)contentForDisplay -{ - if ([Feature enabled:FeatureFlagReaderWebview]) { - return self.content; - } else { - return [RichContentFormatter formatContentString:self.content isPrivateSite:self.isPrivate]; - } -} - @end From 799fbcaeb787f1bc0f40db4907bf24de60006d05 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 13:47:44 -0300 Subject: [PATCH 5/9] Revert "Make contentForDisplay a lazy var so it only loads once" This reverts commit 99e500e1432cd5bb49fa411b0c409e7966ac2c73. --- .../Reader/ReaderDetailViewController.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift b/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift index a20aed00e2c5..cc3481d8037c 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderDetailViewController.swift @@ -148,10 +148,6 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora } } - lazy var postContent: String? = { - return post?.contentForDisplay() - }() - open var postURL: URL? = nil fileprivate var isLoaded: Bool { @@ -805,8 +801,7 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora } fileprivate func configureRichText() { - guard let post = post, - let contentForDisplay = postContent else { + guard let post = post else { return } @@ -814,14 +809,14 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora // We'll log the error, so we know it's there, but we won't halt execution. CrashLogging.logError(error) }) - textView.content = contentForDisplay + textView.content = post.contentForDisplay() updateRichText() updateTextViewMargins() } private func updateRichText() { - guard let contentForDisplay = postContent else { + guard let post = post else { return } @@ -829,15 +824,15 @@ open class ReaderDetailViewController: UIViewController, UIViewControllerRestora let isDark = traitCollection.userInterfaceStyle == .dark textView.attributedText = isDark ? darkTextViewAttributedString : lightTextViewAttributedString } else { - let attrStr = WPRichContentView.formattedAttributedStringForString(contentForDisplay) + let attrStr = WPRichContentView.formattedAttributedStringForString(post.contentForDisplay()) textView.attributedText = attributedString(with: attrStr) } } private func configureAttributedString() { - if #available(iOS 13, *), let contentForDisplay = postContent { - let light = WPRichContentView.formattedAttributedString(for: contentForDisplay, style: .light) - let dark = WPRichContentView.formattedAttributedString(for: contentForDisplay, style: .dark) + if #available(iOS 13, *), let post = post { + let light = WPRichContentView.formattedAttributedString(for: post.contentForDisplay(), style: .light) + let dark = WPRichContentView.formattedAttributedString(for: post.contentForDisplay(), style: .dark) lightTextViewAttributedString = attributedString(with: light) darkTextViewAttributedString = attributedString(with: dark) } From 524b2de7b6908883348541cd8ce8a456220e2f9e Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 13:51:55 -0300 Subject: [PATCH 6/9] Change the post content based on the FF in the ReaderPostService --- WordPress/Classes/Services/ReaderPostService.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/WordPress/Classes/Services/ReaderPostService.m b/WordPress/Classes/Services/ReaderPostService.m index 8de9c22db52a..cd18219cb8a1 100644 --- a/WordPress/Classes/Services/ReaderPostService.m +++ b/WordPress/Classes/Services/ReaderPostService.m @@ -1227,6 +1227,12 @@ - (ReaderPost *)createOrReplaceFromRemotePost:(RemoteReaderPost *)remotePost for post.sourceAttribution = nil; } + if ([Feature enabled:FeatureFlagReaderWebview]) { + post.content = remotePost.content; + } else { + post.content = [RichContentFormatter formatContentString:remotePost.content isPrivateSite:remotePost.isBlogPrivate]; + } + // assign the topic last. post.topic = topic; From 0d64166f0ee91b53c503227ee4f3f58ce812f064 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 14:44:11 -0300 Subject: [PATCH 7/9] Remove previous content assignment --- WordPress/Classes/Services/ReaderPostService.m | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/Classes/Services/ReaderPostService.m b/WordPress/Classes/Services/ReaderPostService.m index cd18219cb8a1..7cecca48207b 100644 --- a/WordPress/Classes/Services/ReaderPostService.m +++ b/WordPress/Classes/Services/ReaderPostService.m @@ -1153,7 +1153,6 @@ - (ReaderPost *)createOrReplaceFromRemotePost:(RemoteReaderPost *)remotePost for post.blogURL = remotePost.blogURL; post.commentCount = remotePost.commentCount; post.commentsOpen = remotePost.commentsOpen; - post.content = remotePost.content; post.date_created_gmt = [DateUtils dateFromISOString:remotePost.date_created_gmt]; post.featuredImage = remotePost.featuredImage; post.feedID = remotePost.feedID; From 49bbc366cd7fce8009dc2a2f976cca9d8e405f12 Mon Sep 17 00:00:00 2001 From: Jeremy Massel Date: Mon, 15 Jun 2020 14:28:22 -0600 Subject: [PATCH 8/9] Update ZIPFoundation to 0.9.11 Release notes from https://github.com/weichsel/ZIPFoundation/releases/tag/0.9.11: ``` ### Added - Read/Write support for in-memory archives ### Updated - Fixed a memory safety issue during (de)compression - Fixed dangling pointer warnings when serializing ZIP internal structs to `Data` - Fixed missing Swift 5 language version when integrating via CocoaPods - Fixed inconsistent usage of the optional `preferredEncoding` parameter during entry addition - Improved documentation for compression settings ``` --- Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 6356e52e7b15..f3bcb00e41b5 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -421,7 +421,7 @@ PODS: - ZendeskSupportSDK (5.0.0): - ZendeskMessagingSDK (~> 3.0.0) - ZendeskSupportProvidersSDK (~> 5.0.0) - - ZIPFoundation (0.9.10) + - ZIPFoundation (0.9.11) DEPENDENCIES: - Alamofire (= 4.8.0) @@ -718,7 +718,7 @@ SPEC CHECKSUMS: ZendeskSDKConfigurationsSDK: 918241bc7ec30e0af9e1b16333d54a584ee8ab9e ZendeskSupportProvidersSDK: e183d32abac888c448469e2005c4a5a8c3ed73f0 ZendeskSupportSDK: a87ab1e4badace92c75eb11dc77ede1e995b2adc - ZIPFoundation: 249fa8890597086cd536bb2df5c9804d84e122b0 + ZIPFoundation: b1f0de4eed33e74a676f76e12559ab6b75990197 PODFILE CHECKSUM: 4ac0a37cde410deeaf1167bb9e99229f15003f27 From 0b77d5b2a9e152f5b405ed97cc72ad5d4ae4ed88 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 15 Jun 2020 18:51:10 -0300 Subject: [PATCH 9/9] Update WordPressKit --- Podfile | 2 +- Podfile.lock | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Podfile b/Podfile index faa30d7cc601..1d3fca42754d 100644 --- a/Podfile +++ b/Podfile @@ -43,7 +43,7 @@ def wordpress_ui end def wordpress_kit - pod 'WordPressKit', '4.10.0' + pod 'WordPressKit', '4.11.0-beta.1' #pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :tag => '' #pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :branch => 'issue/14313_remove_post_content_sanitization' #pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => '' diff --git a/Podfile.lock b/Podfile.lock index 7a76373cf2fd..a975a39025e6 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -392,7 +392,7 @@ PODS: - WordPressKit (~> 4.0-beta.0) - WordPressShared (~> 1.0-beta.0) - WordPressUI (~> 1.7.0) - - WordPressKit (4.10.0): + - WordPressKit (4.11.0-beta.1): - Alamofire (~> 4.8.0) - CocoaLumberjack (~> 3.4) - NSObject-SafeExpectations (= 0.0.4) @@ -484,7 +484,7 @@ DEPENDENCIES: - SVProgressHUD (= 2.2.5) - WordPress-Editor-iOS (~> 1.19.2) - WordPressAuthenticator (~> 1.18.0) - - WordPressKit (= 4.10.0) + - WordPressKit (= 4.11.0-beta.1) - WordPressMocks (~> 0.0.8) - WordPressShared (= 1.9.0) - WordPressUI (~> 1.7.1) @@ -533,6 +533,7 @@ SPEC REPOS: - WordPress-Aztec-iOS - WordPress-Editor-iOS - WordPressAuthenticator + - WordPressKit - WordPressMocks - WordPressShared - WordPressUI @@ -617,9 +618,6 @@ EXTERNAL SOURCES: RNTAztecView: :git: http://github.com/wordpress-mobile/gutenberg-mobile/ :tag: v1.30.0 - WordPressKit: - :branch: issue/14313_remove_post_content_sanitization - :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.30.0/react-native-gutenberg-bridge/third-party-podspecs/Yoga.podspec.json @@ -633,9 +631,6 @@ CHECKOUT OPTIONS: RNTAztecView: :git: http://github.com/wordpress-mobile/gutenberg-mobile/ :tag: v1.30.0 - WordPressKit: - :commit: fd3d6ca9fd62a83f2c02e28202729015897b682f - :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git SPEC CHECKSUMS: 1PasswordExtension: f97cc80ae58053c331b2b6dc8843ba7103b33794 @@ -709,7 +704,7 @@ SPEC CHECKSUMS: WordPress-Aztec-iOS: d01bf0c5e150ae6a046f06ba63b7cc2762061c0b WordPress-Editor-iOS: 5b726489e5ae07b7281a2862d69aba2d5c83f140 WordPressAuthenticator: 7c7f442088af2022f7ee5d7baa6bd73d87df9e25 - WordPressKit: 5205224c1a7b878b74149ab9eef1b5e89b1b20f8 + WordPressKit: cf04f034a376fe54a44edff62c3bd0ece5ef13a6 WordPressMocks: b4064b99a073117bbc304abe82df78f2fbe60992 WordPressShared: b887b17aa949e4b142a1421fd479de495db9a054 WordPressUI: 9da5d966b8beb091950cd96880db398d7f30e246 @@ -725,6 +720,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: a87ab1e4badace92c75eb11dc77ede1e995b2adc ZIPFoundation: 249fa8890597086cd536bb2df5c9804d84e122b0 -PODFILE CHECKSUM: 4ac0a37cde410deeaf1167bb9e99229f15003f27 +PODFILE CHECKSUM: 2f5ef99eab05bb1f77cb6da3fb59c6f6473ee2eb COCOAPODS: 1.8.4