diff --git a/app/Models/RemoteAttendanceLink.php b/app/Models/RemoteAttendanceLink.php index 31217539d..14fdd4cfc 100644 --- a/app/Models/RemoteAttendanceLink.php +++ b/app/Models/RemoteAttendanceLink.php @@ -76,12 +76,13 @@ class RemoteAttendanceLink extends Model * https://meet.google.com/ * https://teams.microsoft.com/l/meetup-join// * https://gatech.zoom.us/j/ + * https://forms.gle/ * but nothing else, to avoid users redirecting to surprising things. * * @phan-suppress PhanReadOnlyPublicProperty */ public static string $redirectRegex = '/^(https?:\/\/)?(meet\.google\.com\/[-a-z]+|teams\.microsoft\.com\/l\/' - .'meetup-join\/[-a-zA-Z0-9%\._]+\/[0-9]+|gatech\.zoom\.us\/j\/[0-9]+)(\?[^@]*)?$/'; + .'meetup-join\/[-a-zA-Z0-9%\._]+\/[0-9]+|gatech\.zoom\.us\/j\/[0-9]+|forms\.gle\/[a-zA-Z0-9])(\?[^@]*)?$/'; /** * Get the attributes that should be cast. @@ -100,8 +101,6 @@ protected function casts(): array */ public static function normalizeRedirectUrl(string $url): string { - $url = Str::lower($url); - if (Str::startsWith($url, 'https://')) { return $url; } diff --git a/app/Nova/Actions/CreateRemoteAttendanceLink.php b/app/Nova/Actions/CreateRemoteAttendanceLink.php index 342ed438d..55bed543e 100644 --- a/app/Nova/Actions/CreateRemoteAttendanceLink.php +++ b/app/Nova/Actions/CreateRemoteAttendanceLink.php @@ -87,11 +87,11 @@ public function fields(NovaRequest $request): array Text::make('Redirect URL') ->required(false) ->rules('nullable', 'regex:'.RemoteAttendanceLink::$redirectRegex, 'max:1023') - ->help('If you put a link to a Google Meet, Zoom, or Microsoft Teams meeting here, '. - 'everyone who clicks the attendance link will be redirected to that meeting after their '. + ->help('If you put a link to a Google Meet, Zoom, or Microsoft Teams meeting or a Google Forms short '. + 'URL here, everyone who clicks the attendance link will be redirected to that meeting after their '. 'attendance is recorded. If you add a redirect URL, do not share that URL directly. Only Google '. - 'Meet, Zoom, and Microsoft Teams calls are supported currently. Ask in #it-helpdesk for'. - ' other redirect URLs.'), + 'Meet, Zoom, and Microsoft Teams calls and Google Forms are supported currently. Ask in '. + '#it-helpdesk for other redirect URLs.'), Select::make('Purpose') ->required(true) diff --git a/tests/Unit/RemoteAttendanceLinkTest.php b/tests/Unit/RemoteAttendanceLinkTest.php index 4d47f4b18..a4188512a 100644 --- a/tests/Unit/RemoteAttendanceLinkTest.php +++ b/tests/Unit/RemoteAttendanceLinkTest.php @@ -63,6 +63,16 @@ public function testRedirectRegexZoom(): void $this->redirectRegexTestCase('gatech.zoom.us/j/12345?query@query', false); } + /** + * Test Google Form links. + */ + public function testRedirectRegexGoogleForm(): void + { + $this->redirectRegexTestCase('forms.gle/4PfXD3rUh8', true); + + $this->redirectRegexTestCase('forms.gle/4PfXD3rU&h8-', false); + } + private function redirectRegexTestCase(string $url, bool $expected): void { if ($expected) {