Ticket #458 (closed Bug report: fixed)

Opened 5 years ago

Last modified 4 years ago

Problem with spaces at network name

Reported by: anonymous Owned by:
Priority: low Milestone: WifiDog Auth Server 1.0
Component: Auth server, Usability, Interface and translations Version:
Keywords: Cc:

Description

I've created a new network with ID "PFC Network". Wifidog gave no error, but when I tried to modify network parameters, I get an error as "UPDATE networks SET name = where ...". The problem was the space in the ID.

I think it could be a good idea don't let people use invalid characters at ID fields.

Thanks...

Attachments

Change History

Changed 5 years ago by networkfusion

  • milestone changed from Not yet assigned to a Milestone to WifiDog Auth Server 1.0

Changed 4 years ago by Robin Jones

A Possible solution to this is as follows, replacing the current class in Network.php:

    /**
     * Process the new object interface.
     *
     * Will return the new object if the user has the credentials and the form
     * was fully filled.
     *
     * @return mixed The Network object or null if no new Network was created.
     *
     * @static
     * @access public
     */
    public static function processCreateNewObjectUI()
    {
        // Init values
        $retval = null;
        $name = "new_network_id";

        if (!empty($_REQUEST[$name])) {
            $network_id = $_REQUEST[$name];

            if (!preg_match('/^[0-9a-zA-Z_-]+$/', $network_id)) {
            echo  _("The Network ID entered was not valid. It must only contain Alphanumerical Characters, Hyphens and Underscores e.g. My_Network-6");
            return;
            }

            if ($network_id) {
                Security::requirePermission(Permission::P('SERVER_PERM_ADD_NEW_NETWORK'), Server::getServer());
                $retval = self::createNewObject($network_id);
            }
        }

        return $retval;
    }

Although we do need to think of a better way to perform error handling and form validation through the whole of the admin interface.

Changed 4 years ago by benoitg

Just blindly throw an exception with the error message, it will display prettyly (wifidog has a custom exception handler).

Changed 4 years ago by Robin Jones

Is this better?

 public static function processCreateNewObjectUI()
    {
        // Init values
        $retval = null;
        $name = "new_network_id";

        if (!empty($_REQUEST[$name])) {
            $network_id = $_REQUEST[$name];

            if (!preg_match('/^[0-9a-zA-Z_-]+$/', $network_id)) {
            throw new Exception(_("The Network ID entered was not valid. It must only contain Alphanumerical Characters, Hyphens and Underscores e.g. My_Network-6"));
            return;
            }

            if ($network_id) {
                Security::requirePermission(Permission::P('SERVER_PERM_ADD_NEW_NETWORK'), Server::getServer());
                $retval = self::createNewObject($network_id);
            }
        }

        return $retval;
    }

Changed 4 years ago by networkfusion

  • status changed from new to closed
  • resolution set to fixed

Add/Change #458 (Problem with spaces at network name)

Author


E-mail address and user name can be saved in the Preferences.


Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.