mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
Check adlist URL for valid characters before adding record to the database.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -600,12 +600,17 @@ if ($_POST['action'] == 'get_groups') {
|
||||
} elseif ($_POST['action'] == 'add_adlist') {
|
||||
// Add new adlist
|
||||
try {
|
||||
$address = $_POST['address'];
|
||||
if(preg_match("/[^a-zA-Z0-9:\/?&%=~._-]/", $address) !== 0) {
|
||||
throw new Exception('Invalid adlist URL');
|
||||
}
|
||||
|
||||
$stmt = $db->prepare('INSERT INTO adlist (address,comment) VALUES (:address,:comment)');
|
||||
if (!$stmt) {
|
||||
throw new Exception('While preparing statement: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
if (!$stmt->bindValue(':address', $_POST['address'], SQLITE3_TEXT)) {
|
||||
if (!$stmt->bindValue(':address', $address, SQLITE3_TEXT)) {
|
||||
throw new Exception('While binding address: ' . $db->lastErrorMsg());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user