@@ -73,48 +73,40 @@ internal func _NSXMLParserExternalEntityWithURL(interface: _CFXMLInterface, urlS
73
73
74
74
switch policy {
75
75
case . ResolveExternalEntitiesSameOriginOnly:
76
- if let url = parser. _url {
77
- if a == nil {
78
- a = NSURL ( string: String ( urlStr) )
76
+ guard let url = parser. _url else { break }
77
+
78
+ if a == nil {
79
+ a = NSURL ( string: String ( urlStr) )
80
+ }
81
+
82
+ guard let aUrl = a else { break }
83
+
84
+ var matches : Bool
85
+ if let aHost = aUrl. host, host = url. host {
86
+ matches = host == aHost
87
+ } else {
88
+ return nil
89
+ }
90
+
91
+ if matches {
92
+ if let aPort = aUrl. port, port = url. port {
93
+ matches = port == aPort
94
+ } else {
95
+ return nil
79
96
}
80
- if let aUrl = a {
81
- var matches : Bool
82
- if let aHost = aUrl. host {
83
- if let host = url. host {
84
- matches = host == aHost
85
- } else {
86
- matches = false
87
- }
88
- } else {
89
- matches = false
90
- }
91
- if matches {
92
- if let aPort = aUrl. port {
93
- if let port = url. port {
94
- matches = port == aPort
95
- } else {
96
- matches = false
97
- }
98
- } else {
99
- matches = false
100
- }
101
- }
102
- if matches {
103
- if let aScheme = aUrl. scheme {
104
- if let scheme = url. scheme {
105
- matches = scheme == aScheme
106
- } else {
107
- matches = false
108
- }
109
- } else {
110
- matches = false
111
- }
112
- }
113
- if !matches {
114
- return nil
115
- }
97
+ }
98
+
99
+ if matches {
100
+ if let aScheme = aUrl. scheme, scheme = url. scheme {
101
+ matches = scheme == aScheme
102
+ } else {
103
+ return nil
116
104
}
117
105
}
106
+
107
+ if !matches {
108
+ return nil
109
+ }
118
110
break
119
111
case . ResolveExternalEntitiesAlways:
120
112
break
@@ -262,18 +254,14 @@ internal func _NSXMLParserStartElementNs(ctx: _CFXMLInterface, localname: Unsafe
262
254
asAttrNamespaceNameString = " xmlns "
263
255
}
264
256
let namespaceValueString = namespaces [ idx + 1 ] == nil ? UTF8STRING ( namespaces [ idx + 1 ] ) : " "
265
- if ( reportNamespaces) {
266
- if let k = namespaceNameString {
267
- if let v = namespaceValueString {
268
- nsDict [ k] = v
269
- }
257
+ if reportNamespaces {
258
+ if let k = namespaceNameString, v = namespaceValueString {
259
+ nsDict [ k] = v
270
260
}
271
261
}
272
262
if !reportQNameURI {
273
- if let k = asAttrNamespaceNameString {
274
- if let v = namespaceValueString {
275
- attrDict [ k] = v
276
- }
263
+ if let k = asAttrNamespaceNameString, v = namespaceValueString {
264
+ attrDict [ k] = v
277
265
}
278
266
}
279
267
}
@@ -335,7 +323,7 @@ internal func _NSXMLParserEndElementNs(ctx: _CFXMLInterface , localname: UnsafeP
335
323
336
324
337
325
if let delegate = parser. delegate {
338
- if ( reportQNameURI) {
326
+ if reportQNameURI {
339
327
// When reporting namespace info, the delegate parameters are not passed in nil
340
328
delegate. parser ( parser, didEndElement: localnameString!, namespaceURI: namespaceURIString == nil ? " " : namespaceURIString, qualifiedName: qualifiedNameString == nil ? " " : qualifiedNameString)
341
329
} else {
0 commit comments