safer decodeURIComponent(), fixes #277

This commit is contained in:
Aine 2025-01-17 09:42:21 +02:00
parent 2a5b59002e
commit df911c9e97
No known key found for this signature in database
GPG Key ID: 34969C908CCA2804
2 changed files with 5 additions and 2 deletions

View File

@ -504,7 +504,10 @@ export const ReportMediaContent = ({ source }) => {
return null; return null;
} }
const uploadName = decodeURIComponent(get(record, "event_json.content.body")?.toString()); let uploadName = "";
if (get(record, "event_json.content.body")) {
uploadName = decodeURIComponent(get(record, "event_json.content.body")?.toString());
}
return <ViewMediaButton mxcURL={mxcURL} label={mxcURL} uploadName={uploadName} mimetype={record.media_type}/>; return <ViewMediaButton mxcURL={mxcURL} label={mxcURL} uploadName={uploadName} mimetype={record.media_type}/>;
}; };

View File

@ -505,7 +505,7 @@ export const UserEdit = (props: EditProps) => {
<DateField source="last_access_ts" showTime options={DATE_FORMAT} /> <DateField source="last_access_ts" showTime options={DATE_FORMAT} />
<NumberField source="media_length" /> <NumberField source="media_length" />
<TextField source="media_type" sx={{ display: "block", width: 200, wordBreak: "break-word" }} /> <TextField source="media_type" sx={{ display: "block", width: 200, wordBreak: "break-word" }} />
<FunctionField source="upload_name" render={record => decodeURIComponent(record.upload_name)} /> <FunctionField source="upload_name" render={record => record.upload_name ? decodeURIComponent(record.upload_name) : ""} />
<TextField source="quarantined_by" /> <TextField source="quarantined_by" />
<QuarantineMediaButton label="resources.quarantine_media.action.name" /> <QuarantineMediaButton label="resources.quarantine_media.action.name" />
<ProtectMediaButton label="resources.users_media.fields.safe_from_quarantine" /> <ProtectMediaButton label="resources.users_media.fields.safe_from_quarantine" />