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 snaps = useSelector(getSnaps);
|
||||||
const settingsRef = useRef();
|
const settingsRef = useRef();
|
||||||
const onClick = (snap) => {
|
const onClick = (snap) => {
|
||||||
const route = `${SNAPS_VIEW_ROUTE}/${window.btoa(
|
history.push(`${SNAPS_VIEW_ROUTE}/${encodeURIComponent(snap.id)}`);
|
||||||
unescape(encodeURIComponent(snap.id)),
|
|
||||||
)}`;
|
|
||||||
history.push(route);
|
|
||||||
};
|
};
|
||||||
const onToggle = (snap) => {
|
const onToggle = (snap) => {
|
||||||
if (snap.enabled) {
|
if (snap.enabled) {
|
||||||
|
@ -32,14 +32,12 @@ function ViewSnap() {
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { pathname } = location;
|
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 snaps = useSelector(getSnaps);
|
||||||
const snap = Object.entries(snaps)
|
const snap = Object.entries(snaps)
|
||||||
.map(([_, snapState]) => snapState)
|
.map(([_, snapState]) => snapState)
|
||||||
.find((snapState) => {
|
.find((snapState) => snapState.id === decodedSnapId);
|
||||||
const decoded = decodeURIComponent(escape(window.atob(pathNameTail)));
|
|
||||||
return snapState.id === decoded;
|
|
||||||
});
|
|
||||||
|
|
||||||
const [isShowingRemoveWarning, setIsShowingRemoveWarning] = useState(false);
|
const [isShowingRemoveWarning, setIsShowingRemoveWarning] = useState(false);
|
||||||
|
|
||||||
|
@ -717,9 +717,7 @@ export const getSnapsRouteObjects = createSelector(getSnaps, (snaps) => {
|
|||||||
tabMessage: () => snap.manifest.proposedName,
|
tabMessage: () => snap.manifest.proposedName,
|
||||||
descriptionMessage: () => snap.manifest.description,
|
descriptionMessage: () => snap.manifest.description,
|
||||||
sectionMessage: () => snap.manifest.description,
|
sectionMessage: () => snap.manifest.description,
|
||||||
route: `${SNAPS_VIEW_ROUTE}/${window.btoa(
|
route: `${SNAPS_VIEW_ROUTE}/${encodeURIComponent(snap.id)}`,
|
||||||
unescape(encodeURIComponent(snap.id)),
|
|
||||||
)}`,
|
|
||||||
icon: 'fa fa-flask',
|
icon: 'fa fa-flask',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user