#910 closed defect (bug) (fixed)
Wordpress allows dots in prefix
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.0.6 | Priority: | normal |
Severity: | minor | Version: | 1.5 |
Component: | General | Keywords: | bg|2nd-opinion bg|dev-feedback bg|needs-patch |
Focuses: | Cc: |
Description
I accidently tried a prefix like wp1.5_ and MySQL showed me a lot of errors in the second step of installation. Wordpress should not allow using characters which MySQL doesn't like.
MySQL v 4.0.23_Debian-6-log on Linux
Change History (11)
#2
@
20 years ago
- Keywords bg|2nd-opinion bg|dev-feedback added
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
#3
@
20 years ago
Dashes are not permitted without backticks.
<?php // make sure the $table_prefix is valid if ( ( !preg_match('/^`[a-z0-9_\-]+`$/i', $table_prefix)) || ( !preg_match('/^[a-z0-9_]+$/i', $table_prefix)) ) die ('The table prefix you chose contains invalid characters. Please edit wp-config.php and ensure that the table prefix only contains letters, numbers, and underscores.'); ?>
Note that explaining the requirement for backticks sufficiently complicates the explanatory note, so I dropped dashes from that. Folks who know can use dashes in backticks, and everyone can use underscores.
#4
@
20 years ago
because that will always be true |
<?php // make sure the $table_prefix is valid if ( ( !preg_match('/^`[a-z0-9_\-]+`$/i', $table_prefix)) && ( !preg_match('/^[a-z0-9_]+$/i', $table_prefix)) ) die (__('The table prefix you chose contains invalid characters. Please edit wp-config.php and ensure that the table prefix only contains letters, numbers, and underscores.')); ?>
#6
@
20 years ago
Oh... wait a tick (pun intended)... backticks have to be around the entire table name. This is just the prefix. Dashes are out, altogether without more changes in WP code.
<?php // make sure the $table_prefix is valid if ( !preg_match('/^[a-z0-9_]+$/i', $table_prefix) ) die (__('The table prefix you chose contains invalid characters. Please edit wp-config.php and ensure that the table prefix only contains letters, numbers, and underscores.')); ?>
Note: See
TracTickets for help on using
tickets.
What is a valid table name? a-z, 0-9, _ and - right? Something like this could work in install.php somewhere. Thoughts?
<?php
make sure the $table_prefix is valid
if ( !preg_match('/[a-z0-9_\-]+$/i', $table_prefix))
?>