Skip to content

Commit

Permalink
Merge pull request #192 from Hirobreak/clean
Browse files Browse the repository at this point in the history
fix email body sanitizer
  • Loading branch information
danieltigse authored Sep 12, 2018
2 parents 35cb493 + 545aaad commit 15107d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion iOS-Email-Client/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<string>2</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
5 changes: 3 additions & 2 deletions iOS-Email-Client/Libs/EventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ class EventHandler {

func getContentPreview(content: String) -> (String, String) {
do {
let allowList = try SwiftSoup.Whitelist.relaxed().addTags("style", "title", "header").addAttributes(":all", "class", "style")
let doc: Document = try SwiftSoup.parse(content)
let preview = try String(doc.text().prefix(100))
let content = try SwiftSoup.clean(content, Whitelist.basic())!
return (content, preview)
let cleanContent = try SwiftSoup.clean(content, allowList)!
return (preview, cleanContent)
} catch {
let preview = String(content.removeHtmlTags().replaceNewLineCharater(separator: " ").prefix(100))
return (preview, content)
Expand Down

0 comments on commit 15107d4

Please sign in to comment.