mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix Snaps view search (#14693)
Closes #14687 Snap IDs were not properly encoded (and decoded) as URI components in the Snaps view search implementation. This ensures that they are.
This commit is contained in:
parent
9a153d2388
commit
4b2cd0ef7a
@ -24,10 +24,7 @@ const SnapListTab = () => {
|
||||
const snaps = useSelector(getSnaps);
|
||||
const settingsRef = useRef();
|
||||
const onClick = (snap) => {
|
||||
const route = `${SNAPS_VIEW_ROUTE}/${window.btoa(
|
||||
unescape(encodeURIComponent(snap.id)),
|
||||
)}`;
|
||||
history.push(route);
|
||||
history.push(`${SNAPS_VIEW_ROUTE}/${encodeURIComponent(snap.id)}`);
|
||||
};
|
||||
const onToggle = (snap) => {
|
||||
if (snap.enabled) {
|
||||
|
@ -32,14 +32,12 @@ function ViewSnap() {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
const { pathname } = location;
|
||||
const pathNameTail = pathname.match(/[^/]+$/u)[0];
|
||||
// The snap ID is in URI-encoded form in the last path segment of the URL.
|
||||
const decodedSnapId = decodeURIComponent(pathname.match(/[^/]+$/u)[0]);
|
||||
const snaps = useSelector(getSnaps);
|
||||
const snap = Object.entries(snaps)
|
||||
.map(([_, snapState]) => snapState)
|
||||
.find((snapState) => {
|
||||
const decoded = decodeURIComponent(escape(window.atob(pathNameTail)));
|
||||
return snapState.id === decoded;
|
||||
});
|
||||
.find((snapState) => snapState.id === decodedSnapId);
|
||||
|
||||
const [isShowingRemoveWarning, setIsShowingRemoveWarning] = useState(false);
|
||||
|
||||
|
@ -717,9 +717,7 @@ export const getSnapsRouteObjects = createSelector(getSnaps, (snaps) => {
|
||||
tabMessage: () => snap.manifest.proposedName,
|
||||
descriptionMessage: () => snap.manifest.description,
|
||||
sectionMessage: () => snap.manifest.description,
|
||||
route: `${SNAPS_VIEW_ROUTE}/${window.btoa(
|
||||
unescape(encodeURIComponent(snap.id)),
|
||||
)}`,
|
||||
route: `${SNAPS_VIEW_ROUTE}/${encodeURIComponent(snap.id)}`,
|
||||
icon: 'fa fa-flask',
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user