diff options
author | freakolowsky <freak@drajv.si> | 2013-05-26 09:20:38 +0200 |
---|---|---|
committer | freakolowsky <freak@drajv.si> | 2013-05-31 16:03:58 +0200 |
commit | ffe6e12a8adc58ff880f546eedd5338686d6e3fe (patch) | |
tree | b85df55e480dbd5a53a775a5ae342e5da30fd511 /includes/installer/OracleInstaller.php | |
parent | c4d81e6c1e3d3aef7a21fbd704a94965116afebd (diff) | |
download | mediawikicore-ffe6e12a8adc58ff880f546eedd5338686d6e3fe.tar.gz mediawikicore-ffe6e12a8adc58ff880f546eedd5338686d6e3fe.zip |
Fixed EZConnect string regex in OracleInstaller class.
The Oracle connect string was valid only if it contained alphanumerics,
underscore and dot. Some new schmemes makes uses of slashes and
EZConnect has the concept of server types (pooled, dedicated, shared)
which we now validate.
The long regex is now in OracleInstaller::checkConnectStringFormat()
(flagged with @since 1.22). The patch provides a bunch of very basic
tests to test out the regex.
Change-Id: Ie3a0af9801bfdbc9129298be07e1676145a1607a
Diffstat (limited to 'includes/installer/OracleInstaller.php')
-rw-r--r-- | includes/installer/OracleInstaller.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php index e85d07f2bf54..e34bed37572d 100644 --- a/includes/installer/OracleInstaller.php +++ b/includes/installer/OracleInstaller.php @@ -86,7 +86,7 @@ class OracleInstaller extends DatabaseInstaller { $status = Status::newGood(); if ( !strlen( $newValues['wgDBserver'] ) ) { $status->fatal( 'config-missing-db-server-oracle' ); - } elseif ( !preg_match( '/^[a-zA-Z0-9_\.]+$/', $newValues['wgDBserver'] ) ) { + } elseif ( !self::checkConnectStringFormat( $newValues['wgDBserver'] ) ) { $status->fatal( 'config-invalid-db-server-oracle', $newValues['wgDBserver'] ); } if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBprefix'] ) ) { @@ -296,4 +296,24 @@ class OracleInstaller extends DatabaseInstaller { "; } + /** + * Function checks the format of Oracle connect string + * The actual validity of the string is checked by attempting to connect + * + * Regex should be able to validate all connect string formats + * [//](host|tns_name)[:port][/service_name][:POOLED] + * http://www.orafaq.com/wiki/EZCONNECT + * + * @since 1.22 + * + * @param string $connect_string + * + * @return bool Whether the connection string is valid. + */ + public static function checkConnectStringFormat( $connect_string ) { + $isValid = preg_match( '/^[[:alpha:]][\w\-]*(?:\.[[:alpha:]][\w\-]*){0,2}$/', $connect_string ); // TNS name + $isValid |= preg_match( '/^(?:\/\/)?[\w\-\.]+(?::[\d]+)?(?:\/(?:[\w\-\.]+(?::(pooled|dedicated|shared))?)?(?:\/[\w\-\.]+)?)?$/', $connect_string ); // EZConnect + return (bool)$isValid; + } + } |