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/), 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). 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) ## 1.0 beta 1150 (2018-10-27)
### Added ### Added

View File

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

View File

@ -39,9 +39,14 @@ class FileConfigurationTests: XCTestCase {
} }
func testPIA() throws { func testPIA() throws {
let cfg = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")).configuration let file = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary"))
XCTAssertEqual(cfg.sessionConfiguration.cipher, .aes128cbc) XCTAssertEqual(file.hostname, "hungary.privateinternetaccess.com")
XCTAssertEqual(cfg.sessionConfiguration.digest, .sha1) 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 { func testStripped() throws {