summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-08-30 13:35:05 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-08-30 13:35:05 +0200
commit35ad04d1188ac2f618f252bd6edaeb523e0245bc (patch)
tree8e9ebf30b7e71d06a973bcc12281de9e50795a25
parent7eaebdb1ce52d602363735d3e9f7f19616bd7f46 (diff)
parent4c9299843d144bffb8229c7c2a18701842b95f00 (diff)
downloadmullvadvpn-35ad04d1188ac2f618f252bd6edaeb523e0245bc.tar.xz
mullvadvpn-35ad04d1188ac2f618f252bd6edaeb523e0245bc.zip
Merge branch 'add-backup-logs-in-report'
-rw-r--r--ios/CHANGELOG.md10
-rw-r--r--ios/MullvadVPN/ConsolidatedApplicationLog.swift53
-rw-r--r--ios/MullvadVPN/ProblemReportViewController.swift2
3 files changed, 44 insertions, 21 deletions
diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md
index 692ebe43bc..66e4d818e7 100644
--- a/ios/CHANGELOG.md
+++ b/ios/CHANGELOG.md
@@ -23,8 +23,16 @@ Line wrap the file at 100 chars. Th
## [Unreleased]
+### Changed
+- Attach log backup from previous application run to problem report.
+
+### Fixed
+- Drop leading replacement characters (`\u{FFFD}`) when decoding UTF-8 from a part of log file.
+
+## [2021.3] - 2021-08-10
### Added
-- Show a reminder to add more credits 3 days before account expiry via system notification and in-app message.
+- Show a reminder to add more credits 3 days before account expiry via system notification and
+ in-app message.
- Add submit button next to account input field on login screen.
### Fixed
diff --git a/ios/MullvadVPN/ConsolidatedApplicationLog.swift b/ios/MullvadVPN/ConsolidatedApplicationLog.swift
index 1b868caf01..05c0a61b31 100644
--- a/ios/MullvadVPN/ConsolidatedApplicationLog.swift
+++ b/ios/MullvadVPN/ConsolidatedApplicationLog.swift
@@ -57,27 +57,18 @@ class ConsolidatedApplicationLog: TextOutputStreamable {
}
}
- func addLogFile(fileURL: URL) {
- guard fileURL.isFileURL else {
- addError(message: fileURL.absoluteString, error: Error.invalidLogFileURL(fileURL))
- return
- }
-
- let path = fileURL.path
- let redactedPath = redact(string: path)
-
- switch Self.readFileLossy(path: path, maxBytes: kLogMaxReadBytes) {
- case .success(let lossyString):
- let redactedString = redact(string: lossyString)
- logs.append(LogAttachment(label: redactedPath, content: redactedString))
-
- case .failure(let error):
- addError(message: redactedPath, error: error)
+ func addLogFile(fileURL: URL, includeLogBackup: Bool) {
+ addSingleLogFile(fileURL)
+ if includeLogBackup {
+ let oldLogFileURL = fileURL.deletingPathExtension().appendingPathExtension("old.log")
+ addSingleLogFile(oldLogFileURL)
}
}
- func addLogFiles(fileURLs: [URL]) {
- fileURLs.forEach(self.addLogFile)
+ func addLogFiles(fileURLs: [URL], includeLogBackups: Bool) {
+ for fileURL in fileURLs {
+ addLogFile(fileURL: fileURL, includeBackupLog: includeLogBackups)
+ }
}
func addError<ErrorType: ChainedError>(message: String, error: ErrorType) {
@@ -108,6 +99,25 @@ class ConsolidatedApplicationLog: TextOutputStreamable {
}
}
+ private func addSingleLogFile(_ fileURL: URL) {
+ guard fileURL.isFileURL else {
+ addError(message: fileURL.absoluteString, error: Error.invalidLogFileURL(fileURL))
+ return
+ }
+
+ let path = fileURL.path
+ let redactedPath = redact(string: path)
+
+ switch Self.readFileLossy(path: path, maxBytes: kLogMaxReadBytes) {
+ case .success(let lossyString):
+ let redactedString = redact(string: lossyString)
+ logs.append(LogAttachment(label: redactedPath, content: redactedString))
+
+ case .failure(let error):
+ addError(message: redactedPath, error: error)
+ }
+ }
+
private static func makeMetadata() -> Metadata {
let osVersion = ProcessInfo.processInfo.operatingSystemVersion
let osVersionString = "iOS \(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)"
@@ -132,7 +142,12 @@ class ConsolidatedApplicationLog: TextOutputStreamable {
}
let data = fileHandle.readData(ofLength: Int(kLogMaxReadBytes))
- let lossyString = String(decoding: data, as: UTF8.self)
+ let replacementCharacter = Character(UTF8.decode(UTF8.encodedReplacementCharacter))
+ let lossyString = String(String(decoding: data, as: UTF8.self)
+ .drop { ch in
+ // Drop leading replacement characters produced when decoding data
+ return ch == replacementCharacter
+ })
return .success(lossyString)
}
diff --git a/ios/MullvadVPN/ProblemReportViewController.swift b/ios/MullvadVPN/ProblemReportViewController.swift
index 1535d1ec26..cd6ec4a490 100644
--- a/ios/MullvadVPN/ProblemReportViewController.swift
+++ b/ios/MullvadVPN/ProblemReportViewController.swift
@@ -25,7 +25,7 @@ class ProblemReportViewController: UIViewController, UITextFieldDelegate, Condit
redactContainerPathsForSecurityGroupIdentifiers: [securityGroupIdentifier]
)
- report.addLogFiles(fileURLs: ApplicationConfiguration.logFileURLs)
+ report.addLogFiles(fileURLs: ApplicationConfiguration.logFileURLs, includeLogBackup: true)
return report
}()