Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-URL-safe characters in email addresses #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Filament/Resources/TenantResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static function table(Table $table): Table
->action(function ($record){
$token = tenancy()->impersonate($record, 1, '/app', 'web');

return redirect()->to(request()->getScheme()."://".$record->domains[0]->domain.'.'. config('filament-tenancy.central_domain') . '/login/url?token='.$token->token .'&email='. $record->email);
return redirect()->to(request()->getScheme()."://".$record->domains[0]->domain.'.'. config('filament-tenancy.central_domain') . '/login/url?token='.$token->token .'&email='. urlencode($record->email));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Similar email parameters in other files need URL encoding

The verification revealed three other files with the same URL construction pattern that don't URL encode the email parameter:

  • src/Livewire/RegisterOtp.php
  • src/Livewire/RegisterDemo.php
  • src/Http/Controllers/AuthController.php

These locations should also apply urlencode() to the email parameter to maintain consistency and prevent potential issues with special characters.

🔗 Analysis chain

LGTM! URL encoding fix properly handles special characters.

The addition of urlencode() correctly addresses the issue with non-URL-safe characters in email addresses during tenant impersonation.

Let's verify the complete URL handling:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other potential URL encoding issues in the codebase
# Look for direct email concatenation in URLs that might need encoding

# Search for URL patterns with potential email concatenation
rg -g '*.php' "(\?|&)email=[^&'\"]+" 

# Search for other URL parameters that might need encoding
rg -g '*.php' "->to\([^)]+\+" 

Length of output: 9523


Script:

#!/bin/bash
# Let's try a more specific search for URL construction patterns
# Search for URL construction with email parameters
rg -g '*.php' -A 2 -B 2 'login/url\?.*email'

# Search for similar redirect patterns in the codebase
rg -g '*.php' -A 2 -B 2 'redirect\(\)->to\(.*token.*email'

Length of output: 4085

}),
Tables\Actions\Action::make('password')
->label(trans('filament-tenancy::messages.actions.password'))
Expand Down