Regex for PDO DSN
Old regex matched ADOdb URI. Also, this regex allows the user, pass, host and database information to appear in any order.
This commit is contained in:
		
							parent
							
								
									3fc4060ef6
								
							
						
					
					
						commit
						9ac45f5363
					
				| @ -139,12 +139,12 @@ class AdminPage extends Extension { | |||||||
| 
 | 
 | ||||||
| 	private function dbdump(Page $page) { | 	private function dbdump(Page $page) { | ||||||
| 		$matches = array(); | 		$matches = array(); | ||||||
| 		preg_match("#(\w+)://(\w+):(\w+)@([\w\.\-]+)/([\w_]+)(\?.*)?#", DATABASE_DSN, $matches); | 		preg_match("#^(?P<proto>\w+)\:(?:user=(?P<user>\w+)(?:;|$)|password=(?P<password>\w+)(?:;|$)|host=(?P<host>[\w\.\-]+)(?:;|$)|dbname=(?P<dbname>[\w_]+)(?:;|$))+#", DATABASE_DSN, $matches); | ||||||
| 		$software = $matches[1]; | 		$software = $matches['proto']; | ||||||
| 		$username = $matches[2]; | 		$username = $matches['user']; | ||||||
| 		$password = $matches[3]; | 		$password = $matches['password']; | ||||||
| 		$hostname = $matches[4]; | 		$hostname = $matches['host']; | ||||||
| 		$database = $matches[5]; | 		$database = $matches['dbname']; | ||||||
| 
 | 
 | ||||||
| 		// TODO: Support more than just MySQL..
 | 		// TODO: Support more than just MySQL..
 | ||||||
| 		switch($software) { | 		switch($software) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user