Skip to content

#6069 - Double encoding Open Graph Characters #6072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion SignalUI/LinkPreview/HTMLMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,23 @@ extension HTMLMetadata {
guard let attributedString = try? NSAttributedString(data: data, options: options, documentAttributes: nil) else {
return nil
}
return attributedString.string

var decodedString = attributedString.string
//Attempt recursive decode iteratively a maximum of three times.
for _ in 0..<3 {
let decodedStringAsData = Data(decodedString.utf8)
guard let redecodedAttributedString = try? NSAttributedString(data: decodedStringAsData, options: options, documentAttributes: nil) else {
return decodedString
}
let redecodedString = redecodedAttributedString.string
if redecodedString == decodedString {
break
}
else {
decodedString = redecodedString
}
}
return decodedString
}
}

Expand Down