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

During installation, trim inputs in the database setup page to avoid whitespaces issues #12502

Merged
merged 3 commits into from Mar 20, 2018

Conversation

fdellwing
Copy link
Contributor

@fdellwing fdellwing commented Jan 24, 2018

Fixes #12499

'password' => $this->getSubmitValue('password'),
'host' => trim($this->getSubmitValue('host')),
'username' => trim($this->getSubmitValue('username')),
'password' => trim($this->getSubmitValue('password')),
Copy link
Member

Choose a reason for hiding this comment

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

A password may end or start with a whitespace maybe? possibly the same for username (although not sure)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure you cannot use whitespaces in MySQL/MariaDB username and password. If anyone can provide source otherwise, you are welcome.

Copy link
Member

Choose a reason for hiding this comment

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

just tested it and worked with a whitespace at the end of the password. For username didn't work but not sure if there is a way to make it work...

CREATE USER 'newuser2'@'%' IDENTIFIED BY 'password ';
GRANT ALL PRIVILEGES ON * . * TO 'newuser2'@'%';
FLUSH PRIVILEGES;

there could be whitespaces at the borders in some niche scenario
@tsteur tsteur added this to the 3.3.1 milestone Jan 25, 2018
@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Jan 25, 2018
@tsteur
Copy link
Member

tsteur commented Jan 25, 2018

Awesome looks great and will be so useful making install easier 👍 I just noticed one more thing. $this->getSubmitValue() may return null so it may end up in trim(null) which could result in notices or it will at least return an empty string "" whereas we saved null before (see php -r "var_dump(trim(null));"). I'm not sure whether this will cause any side effects or so. Therefore it would be good to execute the trim() only when getSubmitValue does not return a null

@fdellwing
Copy link
Contributor Author

I'm not at work till monday, but you can push that yourself. I think it would be easiest to save the value in an variable and than use shorthand if to return the variable or null.

@fdellwing
Copy link
Contributor Author

Should be done :)

@tsteur
Copy link
Member

tsteur commented Jan 29, 2018

Awesome, does it need to be done for DB Name as well? Just to avoid maybe a possible notice or so? In theory might not be needed to have a check there because we check for !empty() later but may be still good to have?

@fdellwing
Copy link
Contributor Author

Are you sure it throws a notice? Did not found any information about that?

@tsteur
Copy link
Member

tsteur commented Jan 30, 2018

Only HHVM seems to trigger a notice in some versions: https://3v4l.org/71CT5
Not sure whether Matomo works on HHVM or not.

@mattab mattab merged commit 1b9c97d into matomo-org:3.x-dev Mar 20, 2018
@mattab
Copy link
Member

mattab commented Mar 20, 2018

Thanks for the PR @fdellwing! 👍

@fdellwing fdellwing deleted the patch-2 branch March 20, 2018 11:18
@mattab mattab changed the title trim inputs for database setup During installation, trim inputs in the database setup page to avoid whitespaces issues Mar 27, 2018
@mattab mattab removed the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Mar 27, 2018
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
* Update FormDatabaseSetup.php

* undo trim of user and password

there could be whitespaces at the borders in some niche scenario

* respect input could be null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants