Skip to content

Commit

Permalink
Merge pull request #140 from wordpress-mobile/develop
Browse files Browse the repository at this point in the history
Brings master current with develop
  • Loading branch information
aerych authored May 30, 2018
2 parents 937c0aa + 22e375c commit 2b314bd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion WordPressShared.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressShared"
s.version = "1.0.3"
s.version = "1.0.5"
s.summary = "Shared components used in building the WordPress iOS apps and other library components."

s.description = <<-DESC
Expand Down
2 changes: 2 additions & 0 deletions WordPressShared/Core/Analytics/WPAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) {
WPAnalyticsStatSupportHelpCenterViewed,
WPAnalyticsStatSupportNewRequestViewed,
WPAnalyticsStatSupportTicketListViewed,
WPAnalyticsStatSupportNewRequestCreated,
WPAnalyticsStatSupportNewRequestFailed,
WPAnalyticsStatSupportNewRequestFileAttached,
WPAnalyticsStatSupportNewRequestFileAttachmentFailed,
WPAnalyticsStatSupportTicketUserReplied,
Expand Down
6 changes: 6 additions & 0 deletions WordPressShared/Core/Utility/RichContentFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
static let styleTags = try! NSRegularExpression(pattern: "<style[^>]*?>[\\s\\S]*?</style>", options: .caseInsensitive)
static let scriptTags = try! NSRegularExpression(pattern: "<script[^>]*?>[\\s\\S]*?</script>", options: .caseInsensitive)
static let tableTags = try! NSRegularExpression(pattern: "<table[^>]*?>[\\s\\S]*?</table>", options: .caseInsensitive)
static let gutenbergComments = try! NSRegularExpression(pattern: "<p><!-- /?wp:.+? /?--></p>[\\n]?", options: .caseInsensitive)

// Normalizaing Paragraphs
static let divTagsStart = try! NSRegularExpression(pattern: "<div[^>]*>", options: .caseInsensitive)
Expand Down Expand Up @@ -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
}

Expand Down
8 changes: 8 additions & 0 deletions WordPressShared/Core/Views/WPNoResultsView.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ - (NSAttributedString *)applyMessageStylesToAttributedString:(NSAttributedString

#pragma mark - Properties

- (void)setAccessibilityLabel:(NSString *)accessibilityLabel {
[super setAccessibilityLabel:accessibilityLabel];

// If an accessibility label is set, use it to override the displayed
// title and message.
self.isAccessibilityElement = (accessibilityLabel) ? YES : NO;
}

- (NSString *)titleText {
return _titleLabel.text;
}
Expand Down
4 changes: 2 additions & 2 deletions WordPressSharedTests/RichContentFormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class RichContentFormatterTests: XCTestCase {


func testRemoveForbiddenTags() {
let str = "<p>test</p><p>test</p>"
let styleStr = "<script>alert();</script><style>body{color:#000;}</style><p>test</p><script>alert();</script><style>body{color:#000;}</style><p>test</p><script>alert();</script><style>body{color:#000;}</style>"
let str = "<p>test</p><p>test</p><img>"
let styleStr = "<script>alert();</script><style>body{color:#000;}</style><p>test</p><script>alert();</script><style>body{color:#000;}</style><p>test</p><p><!-- wp:paragraph {\"fontSize\":\"large\"}--></p><p><!-- /wp:paragraph --></p>\n<img><p><!-- wp:self-closing-tag /--></p><script>alert();</script><style>body{color:#000;}</style>"
let sanitizedStr = RichContentFormatter.removeForbiddenTags(styleStr)
XCTAssertTrue(str == sanitizedStr, "The forbidden tags were not removed.")
}
Expand Down

0 comments on commit 2b314bd

Please sign in to comment.