Welcome Guest, Not a member yet? Register   Sign In
Error Passing 32 Bit Integer in URL
#1

(This post was last modified: 04-04-2024, 09:01 PM by cx3700.)

I am not sure if this is a CL issue or a PHP or HTTP issue, but when I try to pass the number 4294967295 or anything larger in the URL, I get a 403 error. 

For example:

Code:
https://myurl.com/event?device=4294967295


throws an error but

Code:
https://myurl.com/event?device=4294967294


or

Code:
https://myurl.com/event?device=4294967290


do not. 


Is there a way around this? We use 4294967295 as the serial number for our test devices and need to pass it in the URL. 
Is there a way to encode it, or do I need to make a secial route?
Reply
#2

This is a GET parameter and should not affect CI. How do you accept it in the controller? intval() ?
Simple CI 4 project for beginners codeigniter-expenses
Reply
#3

I use $_GET, or the built in request object. Neither work. I tried intval and casting with (string)… passing it as base64 but this isn’t optimal. 

Any number lower than that works fine.
Reply
#4

Cannot reproduce.

PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function index(): string
    
{
        $device $this->request->getGet('device');

        dd($device);
    }


Navigatet to http://localhost:8080/?device=4294967295

$device string (10) "4294967295"
Reply
#5

(This post was last modified: 04-05-2024, 01:36 PM by cx3700.)

(04-05-2024, 01:19 AM)kenjis Wrote: Cannot reproduce.

PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function index(): string
    
{
        $device $this->request->getGet('device');

        dd($device);
    }


Navigatet to http://localhost:8080/?device=4294967295

$device string (10) "4294967295"


My URL has a controller path /event.

What’s your route look like?

Mine is get(‘event’, ‘Event::index);

Can you echo it to the view without casting it as a string?
Reply
#6

PHP Code:
$routes->get('event''Event::index'); 

PHP Code:
<?php

namespace App\Controllers;

use 
App\Controllers\BaseController;
use 
CodeIgniter\HTTP\ResponseInterface;

class 
Event extends BaseController
{
    public function index()
    {
        $device $this->request->getGet('device');

        return $device;
    }



Navigate to http://localhost:8080/event?device=4294967295
I see "4294967295".

The values in $_GET are all strings. So you must do something wrong in your code.
Reply
#7

(This post was last modified: 04-05-2024, 06:50 PM by cx3700.)

My code:


PHP Code:
public function index() {

    $device $this->request->getGet('device');

    echo $device;



With 4294967295
https://imgur.com/a/uQnAqbK

With 4294967294
https://imgur.com/a/BcJ7UHk


How do you explain this?
Reply
#8

What is the 403 error page? Is it provided by CI4 (your custom error page)?

Why is it a stdClass when you just echo?
Reply
#9

(This post was last modified: 04-06-2024, 01:40 PM by cx3700.)

(04-05-2024, 07:34 PM)kenjis Wrote: What is the 403 error page? Is it provided by CI4 (your custom error page)?

Why is it a stdClass when you just echo?





Sorry I was trying out different data types to see what works. My code matches yours on a clean install, and I still get the 403 error. It is the built in CI 4 error page or maybe Plesk. 


 
Reply
#10

(This post was last modified: 04-06-2024, 02:46 PM by kenjis.)

https://imgur.com/a/uQnAqbK is not the default CI4 error page.

So, the conclusion is that the web server or Web Application Firewall may be returning a 403.
Check with your service provider's technical support.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB