Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 41f5983

Browse files
authored
Merge pull request #669 from wordpress-mobile/wcios/site-discovery-bypass-app-transport-security
Site discovery: bypass app transport security when checking site existence
2 parents 3e7609d + 1687e55 commit 41f5983

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Pod::Spec.new do |s|
44
s.name = 'WordPressAuthenticator'
5-
s.version = '2.2.1-beta.4'
5+
s.version = '2.2.1-beta.5'
66

77
s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.'
88
s.description = <<-DESC

WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,22 @@ private extension SiteAddressViewController {
440440
}
441441

442442
// Checks that the site exists
443+
checkSiteExistence(url: url) { [weak self] in
444+
guard let self = self else { return }
445+
// Proceeds to check for the site's WordPress
446+
self.guessXMLRPCURL(for: self.loginFields.siteAddress)
447+
}
448+
}
449+
450+
func checkSiteExistence(url: URL, onCompletion: @escaping () -> Void) {
443451
var request = URLRequest(url: url)
444452
request.httpMethod = "HEAD"
445453
request.timeoutInterval = 10.0 // waits for 10 seconds
446454
let task = URLSession.shared.dataTask(with: request) { [weak self] _, _, error in
447455
DispatchQueue.main.async { [weak self] in
448456
guard let self = self else { return }
449457

450-
if let error = error {
458+
if let error = error, (error as NSError).code != NSURLErrorAppTransportSecurityRequiresSecureConnection {
451459
self.configureViewLoading(false)
452460

453461
if self.authenticationDelegate.shouldHandleError(error) {
@@ -460,8 +468,7 @@ private extension SiteAddressViewController {
460468
return self.displayError(message: Localization.nonExistentSiteError, moveVoiceOverFocus: true)
461469
}
462470

463-
// Proceeds to check for the site's WordPress
464-
self.guessXMLRPCURL(for: self.loginFields.siteAddress)
471+
onCompletion()
465472
}
466473
}
467474
task.resume()

0 commit comments

Comments
 (0)