Skip to content

Commit

Permalink
Fix token not being redacted from error log (#1792)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjmarf authored Feb 22, 2025
1 parent f66f328 commit 15a6f94
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Mlem/App/Globals/Definitions/ErrorsTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ErrorsTracker {
var ret = ""

for details in errors {
ret += "\(details.when.formatted(.iso8601))\t\(details.title ?? "Error")\t\(details.errorText)\n"
ret += "\(details.when.formatted(.iso8601))\t\(details.title ?? "Error")\t\(details.errorText())\n"
}

return ret
Expand Down
4 changes: 2 additions & 2 deletions Mlem/App/Models/ErrorDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ struct ErrorDetails: Hashable {
lhs.hashValue == rhs.hashValue
}

var errorText: String {
func errorText(includingLocation: Bool = true) -> String {
var output = String(describing: error)
if let location {
if includingLocation, let location {
output += " (\(location))"
}
for account in AccountsTracker.main.userAccounts {
Expand Down
4 changes: 2 additions & 2 deletions Mlem/App/Views/Root/Tabs/Settings/ErrorLogView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ErrorLogView: View {
Spacer()

Button {
UIPasteboard.general.string = details.errorText
UIPasteboard.general.string = details.errorText()
ToastModel.main.add(.success(String("Copied")))
} label: {
Text(Image(systemName: Icons.copy))
Expand All @@ -68,7 +68,7 @@ struct ErrorLogView: View {
}
}

Text(String(describing: details.error))
Text(details.errorText(includingLocation: false))

if let location = details.location {
HStack(alignment: .top, spacing: 2) {
Expand Down
2 changes: 1 addition & 1 deletion Mlem/App/Views/Shared/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct ErrorView: View {
var body: some View {
VStack(spacing: 15) {
if showingFullError {
errorDetails(errorDetails.errorText)
errorDetails(errorDetails.errorText())
} else {
if let systemImage = errorDetails.systemImage {
Image(systemName: systemImage)
Expand Down
4 changes: 2 additions & 2 deletions Mlem/App/Views/Shared/Toast/ToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ struct ToastView: View {
VStack(alignment: .leading, spacing: 0) {
if isExpanded {
ScrollView {
Text(details.errorText)
Text(details.errorText())
.foregroundStyle(.red)
.padding(8)
.multilineTextAlignment(.leading)
}
.frame(maxWidth: .infinity)

Button("Copy", systemImage: Icons.copy) {
UIPasteboard.general.string = details.errorText
UIPasteboard.general.string = details.errorText()
}
.font(.caption)
.buttonStyle(.borderedProminent)
Expand Down

0 comments on commit 15a6f94

Please sign in to comment.