[FIX] AttachmentView crashing during title decode (#2253)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-07-08 13:40:51 -03:00 committed by GitHub
parent 362ef0085e
commit 5b3be4ef0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -70,10 +70,15 @@ class AttachmentView extends React.Component {
setHeader = () => { setHeader = () => {
const { route, navigation, theme } = this.props; const { route, navigation, theme } = this.props;
const attachment = route.params?.attachment; const attachment = route.params?.attachment;
const { title } = attachment; let { title } = attachment;
try {
title = decodeURI(title);
} catch {
// Do nothing
}
const options = { const options = {
title,
headerLeft: () => <CloseModalButton testID='close-attachment-view' navigation={navigation} buttonStyle={{ color: themes[theme].previewTintColor }} />, headerLeft: () => <CloseModalButton testID='close-attachment-view' navigation={navigation} buttonStyle={{ color: themes[theme].previewTintColor }} />,
title: decodeURI(title),
headerRight: () => <SaveButton testID='save-image' onPress={this.handleSave} buttonStyle={{ color: themes[theme].previewTintColor }} />, headerRight: () => <SaveButton testID='save-image' onPress={this.handleSave} buttonStyle={{ color: themes[theme].previewTintColor }} />,
headerBackground: () => <View style={{ flex: 1, backgroundColor: themes[theme].previewBackground }} />, headerBackground: () => <View style={{ flex: 1, backgroundColor: themes[theme].previewBackground }} />,
headerTintColor: themes[theme].previewTintColor, headerTintColor: themes[theme].previewTintColor,