File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -465,16 +465,14 @@ open class XMLParser : NSObject {
465
465
}
466
466
467
467
internal func _handleParseResult( _ parseResult: Int32 ) -> Bool {
468
- return true
469
- /*
470
- var result = true
471
- if parseResult != 0 {
472
- if parseResult != -1 {
473
- // TODO: determine if this result is a fatal error from libxml via the CF implementations
468
+ if parseResult == 0 {
469
+ return true
470
+ } else {
471
+ if _parserError == nil {
472
+ _parserError = NSError ( domain: XMLParser . errorDomain, code: Int ( parseResult) )
474
473
}
475
474
}
476
- return result
477
- */
475
+ return false
478
476
}
479
477
480
478
internal func parseData( _ data: Data ) -> Bool {
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ class TestXMLParser : XCTestCase {
65
65
( " test_withData " , test_withData) ,
66
66
( " test_withDataEncodings " , test_withDataEncodings) ,
67
67
( " test_withDataOptions " , test_withDataOptions) ,
68
+ ( " test_sr9758_abortParsing " , test_sr9758_abortParsing) ,
68
69
]
69
70
}
70
71
@@ -141,4 +142,16 @@ class TestXMLParser : XCTestCase {
141
142
XCTAssertTrue ( res)
142
143
}
143
144
145
+ func test_sr9758_abortParsing( ) {
146
+ class Delegate : NSObject , XMLParserDelegate {
147
+ func parserDidStartDocument( _ parser: XMLParser ) { parser. abortParsing ( ) }
148
+ }
149
+ let xml = TestXMLParser . xmlUnderTest ( encoding: . utf8)
150
+ let parser = XMLParser ( data: xml. data ( using: . utf8) !)
151
+ let delegate = Delegate ( )
152
+ parser. delegate = delegate
153
+ XCTAssertFalse ( parser. parse ( ) )
154
+ XCTAssertNotNil ( parser. parserError)
155
+ }
156
+
144
157
}
You can’t perform that action at this time.
0 commit comments