mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 08:06:13 +00:00
fix: only open safe URL schemes from contact cards
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
|||||||
Clock, KeyRound, FolderInput, Plus,
|
Clock, KeyRound, FolderInput, Plus,
|
||||||
} from 'lucide-react-native';
|
} from 'lucide-react-native';
|
||||||
import type { RootStackParamList } from '../navigation/types';
|
import type { RootStackParamList } from '../navigation/types';
|
||||||
|
import { openExternalUrl } from '../lib/open-url';
|
||||||
import type { ContactCard } from '../api/types';
|
import type { ContactCard } from '../api/types';
|
||||||
import { useContactsStore } from '../stores/contacts-store';
|
import { useContactsStore } from '../stores/contacts-store';
|
||||||
import {
|
import {
|
||||||
@@ -177,7 +178,11 @@ export default function ContactDetailScreen() {
|
|||||||
Linking.openURL(`https://maps.google.com/?q=${encoded}`).catch(() => Alert.alert('Cannot open maps'));
|
Linking.openURL(`https://maps.google.com/?q=${encoded}`).catch(() => Alert.alert('Cannot open maps'));
|
||||||
};
|
};
|
||||||
const openUrl = (uri: string) => {
|
const openUrl = (uri: string) => {
|
||||||
Linking.openURL(uri).catch(() => Alert.alert('Cannot open link'));
|
// Contact data is server-supplied: only hand http(s)/mailto/tel/sms/geo
|
||||||
|
// schemes to the OS, never intent:// / file:// / third-party deep links.
|
||||||
|
void openExternalUrl(uri).then((opened) => {
|
||||||
|
if (!opened) Alert.alert('Cannot open link');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
const shareValue = (value: string) => {
|
const shareValue = (value: string) => {
|
||||||
Share.share({ message: value }).catch(() => {});
|
Share.share({ message: value }).catch(() => {});
|
||||||
|
|||||||
Reference in New Issue
Block a user