Fixed RB-4158 - handle numeric values better

This commit is contained in:
snipe
2026-05-21 14:19:17 +01:00
parent d329e5f862
commit 480d252173
3 changed files with 18 additions and 0 deletions
+7
View File
@@ -19,6 +19,7 @@ use Illuminate\Validation\ValidationException;
use Intervention\Image\Exception\NotSupportedException;
use JsonException;
use League\OAuth2\Server\Exception\OAuthServerException;
use Livewire\Exceptions\PublicPropertyNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Throwable;
@@ -41,6 +42,7 @@ class Handler extends ExceptionHandler
JsonException::class,
SCIMException::class, // these generally don't need to be reported
InvalidFormatException::class,
PublicPropertyNotFoundException::class,
];
/**
@@ -71,6 +73,11 @@ class Handler extends ExceptionHandler
public function render($request, Throwable $e)
{
// Livewire tried to set a property that doesn't exist (e.g. stale browser state sending a bare "0" as a property name)
if ($e instanceof PublicPropertyNotFoundException) {
return response()->json(['message' => $e->getMessage()], 422);
}
// CSRF token mismatch error
if ($e instanceof TokenMismatchException) {
return redirect()->back()->with('error', trans('general.token_expired'));
+6
View File
@@ -720,6 +720,12 @@ class Importer extends Component
$this->message_type = 'danger';
}
public function process(): void
{
$this->message = trans('general.token_expired');
$this->message_type = 'danger';
}
public function clearMessage()
{
$this->message = null;
+5
View File
@@ -618,6 +618,11 @@ document.addEventListener('livewire:init', () => {
console.error("For data-livewire-component, you probably want to use $this->getId() or {{ $this->getId() }}, as appropriate")
return false
}
// PHP property names cannot start with a digit — skip bare numeric names (e.g. "0") that would cause a 500
if (/^\d+$/.test(event.target.name)) {
console.error("Livewire select2: name attribute '" + event.target.name + "' is not a valid Livewire property name — skipping")
return false
}
Livewire.find(target.data('livewire-component')).set(event.target.name, this.options[this.selectedIndex].value)
});