Skip to content

Commit

Permalink
safer decodeURIComponent(), fixes #277
Browse files Browse the repository at this point in the history
  • Loading branch information
aine-etke committed Jan 17, 2025
1 parent 2a5b590 commit df911c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ export const ReportMediaContent = ({ source }) => {
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}/>;
};
2 changes: 1 addition & 1 deletion src/resources/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export const UserEdit = (props: EditProps) => {
<DateField source="last_access_ts" showTime options={DATE_FORMAT} />
<NumberField source="media_length" />
<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" />
<QuarantineMediaButton label="resources.quarantine_media.action.name" />
<ProtectMediaButton label="resources.users_media.fields.safe_from_quarantine" />
Expand Down

0 comments on commit df911c9

Please sign in to comment.