Improve API endpoint name validation
							parent
							
								
									e5dd07305a
								
							
						
					
					
						commit
						26311c8ffb
					
				
							
								
								
									
										11
									
								
								index.php
								
								
								
								
							
							
						
						
									
										11
									
								
								index.php
								
								
								
								
							|  | @ -18,15 +18,12 @@ $RUNTIME['OPENSIM'] = new OpenSim(); | |||
| 
 | ||||
| include_once("config.php"); | ||||
| 
 | ||||
| //TODO: add API keys and/or rate limiting
 | ||||
| if(isset($_REQUEST['api'])) | ||||
| { | ||||
| 	if(file_exists("./api/".$_REQUEST['api'].".php")){ | ||||
| 		if($_REQUEST['api'] == str_replace("/"," ",$_REQUEST['api']) and $_REQUEST['api'] == str_replace("\\"," ",$_REQUEST['api']) and $_REQUEST['api'] == str_replace(".."," ",$_REQUEST['api'])){ | ||||
| 				include "./api/".$_REQUEST['api'].".php"; | ||||
| 		}else{ | ||||
| 			die("ERROR; ENDPOINT NOT EXIST"); | ||||
| 		} | ||||
| 	}else{ | ||||
| 	if(preg_match("[a-zA-Z0-9\.]{1,100}", $_REQUEST['api']) && file_exists("./api/".$_REQUEST['api'].".php")) { | ||||
| 		include "./api/".$_REQUEST['api'].".php"; | ||||
| 	} else { | ||||
| 		die("ERROR; ENDPOINT NOT EXIST"); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Anonymous Contributor
						Anonymous Contributor