Skip to content

SR-9758: XMLParser.parse() should return false if abortParsing() is called. #1867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 31, 2019

Conversation

YOCKOW
Copy link
Member

@YOCKOW YOCKOW commented Jan 31, 2019

As the Apple's document says, parse() should return false in there is an error or if the parsing operation is aborted.

Resolves SR-9758.

if _parserError == nil {
_parserError = NSError(domain: XMLParser.errorDomain, code: Int(parseResult))
}
result = false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not the best way, but it would be better than just return true.

@@ -465,16 +465,18 @@ open class XMLParser : NSObject {
}

internal func _handleParseResult(_ parseResult: Int32) -> Bool {
return true
/*
var result = true
if parseResult != 0 {
if parseResult != -1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be simpler to write this as :

if parseResult == 0 {
  return true
} else {
    if _parserError == nil {
         _parserError = NSError(domain: XMLParser.errorDomain, code: Int(parseResult))
    }
} 
return false

If more interpretation of parseResult is added in the future, it will reduce the extra levels of indentation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. I will rewrite it.

@spevans
Copy link
Contributor

spevans commented Jan 31, 2019

@swift-ci test

@spevans
Copy link
Contributor

spevans commented Jan 31, 2019

@swift-ci test

@parkera
Copy link
Contributor

parkera commented Jan 31, 2019

Thank you!

@spevans
Copy link
Contributor

spevans commented Jan 31, 2019

@swift-ci test

@spevans
Copy link
Contributor

spevans commented Jan 31, 2019

@swift-ci test and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants