diff --git a/WordPressShared.podspec b/WordPressShared.podspec index 93ea90a..26144a5 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.0.4" + s.version = "1.0.5" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC diff --git a/WordPressShared/Core/Utility/RichContentFormatter.swift b/WordPressShared/Core/Utility/RichContentFormatter.swift index 8e9feac..4736ccb 100644 --- a/WordPressShared/Core/Utility/RichContentFormatter.swift +++ b/WordPressShared/Core/Utility/RichContentFormatter.swift @@ -11,6 +11,7 @@ import Foundation static let styleTags = try! NSRegularExpression(pattern: "]*?>[\\s\\S]*?", options: .caseInsensitive) static let scriptTags = try! NSRegularExpression(pattern: "]*?>[\\s\\S]*?", options: .caseInsensitive) static let tableTags = try! NSRegularExpression(pattern: "]*?>[\\s\\S]*?", options: .caseInsensitive) + static let gutenbergComments = try! NSRegularExpression(pattern: "

[\\n]?", options: .caseInsensitive) // Normalizaing Paragraphs static let divTagsStart = try! NSRegularExpression(pattern: "]*>", options: .caseInsensitive) @@ -84,6 +85,11 @@ import Foundation range: NSRange(location: 0, length: content.count), withTemplate: "") + content = RegEx.gutenbergComments.stringByReplacingMatches(in: content, + options: .reportCompletion, + range: NSRange(location: 0, length: content.count), + withTemplate: "") + return content } diff --git a/WordPressSharedTests/RichContentFormatterTests.swift b/WordPressSharedTests/RichContentFormatterTests.swift index c6197d6..76273a4 100644 --- a/WordPressSharedTests/RichContentFormatterTests.swift +++ b/WordPressSharedTests/RichContentFormatterTests.swift @@ -12,8 +12,8 @@ class RichContentFormatterTests: XCTestCase { func testRemoveForbiddenTags() { - let str = "

test

test

" - let styleStr = "

test

test

" + let str = "

test

test

" + let styleStr = "

test

test

\n

" let sanitizedStr = RichContentFormatter.removeForbiddenTags(styleStr) XCTAssertTrue(str == sanitizedStr, "The forbidden tags were not removed.") }