LifeMate — Personal, Family & Learning Companion

fix/personal-notification-controls
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
dart 32 lines 1.18 KB
Raw
1 /// The provider receives a public video hash only, never an application URL,
2 /// token, account identifier or caller-supplied iframe markup.
3 Uri? aparatEmbedUri(String videoHash) {
4 if (!RegExp(r'^[A-Za-z0-9]{5,64}$').hasMatch(videoHash) ||
5 videoHash.contains('\n') ||
6 videoHash.contains('\r')) {
7 return null;
8 }
9 return Uri.https(
10 'www.aparat.com', '/video/video/embed/videohash/$videoHash/vt/frame');
11 }
12
13 bool isAllowedAparatNavigation(String address, String videoHash) {
14 // Uri normalizes percent-encoded unreserved characters; reject encodings
15 // before parsing so only the literal provider path can pass this boundary.
16 if (address.contains('%') ||
17 address.contains('\\') ||
18 address.trim() != address) {
19 return false;
20 }
21 final expected = aparatEmbedUri(videoHash);
22 final candidate = Uri.tryParse(address);
23 return expected != null &&
24 candidate != null &&
25 candidate.scheme == 'https' &&
26 (candidate.host == 'www.aparat.com' || candidate.host == 'aparat.com') &&
27 candidate.port == 443 &&
28 candidate.userInfo.isEmpty &&
29 !candidate.hasQuery &&
30 !candidate.hasFragment &&
31 candidate.path == expected.path;
32 }