Skip to content

Commit

Permalink
release v1.2.9 & Fix XMLParser Critical Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekTree0101 committed Jan 18, 2019
1 parent 0e522f8 commit d1369d2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Example/VEditorKit/content.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<content><h2>Welcome to VEditorKit</h2><img src=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/intro.png\" width=\"500\" height=\"500\"/><p>Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit) <a href=\"https://github.com/texturegroup/texture.\">https://github.com/texturegroup/texture.</a> VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want. </p><b>\n\n- Typing Attribute Test -</b><video width=\"500\" height=\"500\" poster=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test.png\" src=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test.mp4\" /><b>- Typing Attribute Test2 -</b><video width=\"500\" height=\"500\" poster=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test2.png\" src=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test2.mp4\" /><p><a href=\"https://medium.com/vingle-tech-blog/texture-%ED%98%84%EC%97%85-%EC%82%AC%EC%9A%A9%EA%B0%80%EC%9D%B4%EB%93%9C-98865bd6a38\">https://medium.com/vingle-tech-blog/texture-%ED%98%84%EC%97%85-%EC%82%AC%EC%9A%A9%EA%B0%80%EC%9D%B4%EB%93%9C-98865bd6a38</a></p><og-object url=\"https://medium.com/vingle-tech-blog/texture-%ED%98%84%EC%97%85-%EC%82%AC%EC%9A%A9%EA%B0%80%EC%9D%B4%EB%93%9C-98865bd6a38\" title=\"Texture, 현업 사용가이드\" description=\"안녕하세요 저는 RxSwift를 즐겨사용하며, Texture 커뮤니티에서 활동중인 Vingle iOS개발자 Geektree0101입니다.\" image=\"https://cdn-images-1.medium.com/max/1600/0*XNcfCZEJrsXenM9c.jpg\"/><blockquote>Pull requests are always welcome. Thank you!</blockquote><i>\n\n\nCopyright © 2019 @Geektree0101. All rights reserved.\n\n\n</i></content>
<content><h2>Welcome to VEditorKit</h2><img src=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/intro.png\" width=\"500\" height=\"500\"/><p>Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit) <a href=\"https://github.com/texturegroup/texture.\">https://github.com/texturegroup/texture.</a> VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want. </p><h2>- Typing Attribute Test -</h2><video width=\"500\" height=\"500\" poster=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test.png\" src=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test.mp4\" /><h2>- Typing Attribute Test2 -</h2><video width=\"500\" height=\"500\" poster=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test2.png\" src=\"https://raw.githubusercontent.com/GeekTree0101/VEditorKit/master/screenshots/test2.mp4\" /><p><a href=\"https://medium.com/vingle-tech-blog/texture-%ED%98%84%EC%97%85-%EC%82%AC%EC%9A%A9%EA%B0%80%EC%9D%B4%EB%93%9C-98865bd6a38\">https://medium.com/vingle-tech-blog/texture-%ED%98%84%EC%97%85-%EC%82%AC%EC%9A%A9%EA%B0%80%EC%9D%B4%EB%93%9C-98865bd6a38</a></p><og-object url=\"https://medium.com/vingle-tech-blog/texture-%ED%98%84%EC%97%85-%EC%82%AC%EC%9A%A9%EA%B0%80%EC%9D%B4%EB%93%9C-98865bd6a38\" title=\"Texture, 현업 사용가이드\" description=\"안녕하세요 저는 RxSwift를 즐겨사용하며, Texture 커뮤니티에서 활동중인 Vingle iOS개발자 Geektree0101입니다.\" image=\"https://cdn-images-1.medium.com/max/1600/0*XNcfCZEJrsXenM9c.jpg\"/><blockquote>Pull requests are always welcome. Thank you!</blockquote><i>\n\n\nCopyright © 2019 @Geektree0101. All rights reserved.\n\n\n</i></content>
2 changes: 1 addition & 1 deletion VEditorKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'VEditorKit'
s.version = '1.2.8'
s.version = '1.2.9'
s.summary = 'Lightweight and Powerful Editor Kit'

s.description = 'Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)'
Expand Down
15 changes: 13 additions & 2 deletions VEditorKit/Classes/VEditorParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@ public final class VEditorParser: NSObject, XMLStyler {
public func parseXML(_ xmlString: String,
onSuccess: (([VEditorContent]) -> Void)? = nil,
onError: ((Error?) -> Void)? = nil) {
let parser = VEditorContentParser(xmlString
var xmlString = xmlString
.replacingOccurrences(of: "\\n", with: "\n")
.replacingOccurrences(of: "\\", with: ""), rule: self.parserRule)
.replacingOccurrences(of: "\\", with: "")

// make newlink before block heading if needs
for blockXML in parserRule.blockStyleXMLTags {
let defaultCloseTag: String = "</\(parserRule.defaultStyleXMLTag)>"
let blockOpenTag: String = "<\(blockXML)>"
let targetPairTag: String = defaultCloseTag + blockOpenTag
xmlString = xmlString.replacingOccurrences(of: targetPairTag,
with: "\n" + targetPairTag)
}

let parser = VEditorContentParser(xmlString, rule: self.parserRule)

switch parser.parseXMLContents() {
case .success(let contents):
Expand Down
11 changes: 11 additions & 0 deletions VEditorKit/Classes/VEditorXMLBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public final class VEditorXMLBuilder {
}

xmlString = xmlString.squeezXMLString(rule)

for xml in rule.allXML {
let open = self.generateXMLTag(xml, scope: .open(nil))
let close = self.generateXMLTag(xml, scope: .close)
let emptyContent = open + close
let duplicatedPairedXMLTags = close + open
xmlString = xmlString
.replacingOccurrences(of: emptyContent, with: "")
.replacingOccurrences(of: duplicatedPairedXMLTags, with: "")
}

if xmlString.isEmpty {
return nil
} else if let packageTag = packageTag {
Expand Down

0 comments on commit d1369d2

Please sign in to comment.