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 to install Piwik in database name containing a hyphen "-" #10547

Closed
wronan opened this issue Sep 23, 2016 · 7 comments · Fixed by #10688
Closed

Allow to install Piwik in database name containing a hyphen "-" #10547

wronan opened this issue Sep 23, 2016 · 7 comments · Fixed by #10688
Milestone

Comments

@wronan
Copy link
Contributor

wronan commented Sep 23, 2016

Here https://github.com/piwik/piwik/blob/master/core/DbHelper.php#L201 instead of

return (0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z_0-9.-\+]*))$/D', $dbname));

should be

return (0 !== preg_match('/(^[a-zA-Z0-9]+([a-zA-Z_0-9.\-\+]*))$/D', $dbname));

('-' was not escaped).

@tsteur
Copy link
Member

tsteur commented Sep 26, 2016

Can you maybe issue a PR for this?

@wronan
Copy link
Contributor Author

wronan commented Sep 26, 2016

Sure 👍 Just wanted to know if you are interested in fixing that first.
Will do that later today after work.

@mattab
Copy link
Member

mattab commented Sep 26, 2016

@wronan We are definitely interested in pull requests fixing bugs! :-) even better when they include a test of course, but already great to have without a test..

@kylekatarnls
Copy link
Contributor

kylekatarnls commented Sep 26, 2016

Mini-trick: the + does not need to be escaped in a class (like the dot in this expression) and neither the - if it ends the class.

So [a-zA-Z_0-9.+-] works fine in this order.

@wronan
Copy link
Contributor Author

wronan commented Sep 26, 2016

Thx. Trick is good but when some sign is escaped then it is more explicit (in my opinion).

@kylekatarnls
Copy link
Contributor

I understand, in this case, you should also escape the dot I think.

wronan added a commit to wronan/piwik that referenced this issue Oct 5, 2016
@wronan
Copy link
Contributor Author

wronan commented Oct 5, 2016

Hey guys, I PRed the changes ^
Please review.

@mattab mattab added this to the 3.0.0-b3 milestone Nov 11, 2016
@mattab mattab changed the title Bad regexp in DbHelper.php Allow to install Piwik in database name containing a hyphen "-" Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants