Fix handling of extra whitespaces in .ovpn

Fixes #17
This commit is contained in:
Davide De Rosa 2018-10-27 19:44:28 +02:00
parent b7dc72a5e9
commit fa59b8b5f9
4 changed files with 20 additions and 9 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Handling of extra whitespaces in .ovpn (Mike Mayer). [#17](https://github.com/keeshux/passepartout-ios/issues/17)
## 1.0 beta 1150 (2018-10-27)
### Added

View File

@ -365,7 +365,7 @@ private extension NSRegularExpression {
return
}
let match = (string as NSString).substring(with: range)
let tokens = match.components(separatedBy: " ")
let tokens = match.components(separatedBy: " ").filter { !$0.isEmpty }
block(tokens)
}
}
@ -376,7 +376,7 @@ private extension NSRegularExpression {
return
}
let match = (string as NSString).substring(with: range)
var tokens = match.components(separatedBy: " ")
var tokens = match.components(separatedBy: " ").filter { !$0.isEmpty }
tokens.removeFirst()
block(tokens)
}

View File

@ -39,9 +39,14 @@ class FileConfigurationTests: XCTestCase {
}
func testPIA() throws {
let cfg = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")).configuration
XCTAssertEqual(cfg.sessionConfiguration.cipher, .aes128cbc)
XCTAssertEqual(cfg.sessionConfiguration.digest, .sha1)
let file = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary"))
XCTAssertEqual(file.hostname, "hungary.privateinternetaccess.com")
XCTAssertEqual(file.configuration.sessionConfiguration.cipher, .aes128cbc)
XCTAssertEqual(file.configuration.sessionConfiguration.digest, .sha1)
XCTAssertEqual(file.configuration.endpointProtocols, [
TunnelKitProvider.EndpointProtocol(.udp, 1198),
TunnelKitProvider.EndpointProtocol(.tcp, 502)
])
}
func testStripped() throws {

View File

@ -1,7 +1,7 @@
client
dev tun
remote hungary.privateinternetaccess.com 1198 udp
remote hungary.privateinternetaccess.com 502 tcp
remote hungary.privateinternetaccess.com 1198 udp
remote hungary.privateinternetaccess.com 502 tcp
resolv-retry infinite
nobind
persist-key
@ -44,8 +44,8 @@ YDQ8z9v+DMO6iwyIDRiU
-----END CERTIFICATE-----
</ca>
cipher aes-128-cbc
auth sha1
cipher aes-128-cbc
auth sha1
tls-client
remote-cert-tls server
auth-user-pass