1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-12-13 09:56:01 +00:00

Merge pull request #6205 from PhoenixPeca/master

Improve the existing validation flow for sieve filter
This commit is contained in:
FreddleSpl0it
2025-01-14 12:08:56 +01:00
committed by GitHub
2 changed files with 4 additions and 5 deletions

View File

@@ -4,14 +4,14 @@ header('Content-Type: application/json');
if (!isset($_SESSION['mailcow_cc_role'])) { if (!isset($_SESSION['mailcow_cc_role'])) {
exit(); exit();
} }
if (isset($_GET['script'])) { if (isset($_REQUEST['script'])) {
$sieve = new Sieve\SieveParser(); $sieve = new Sieve\SieveParser();
try { try {
if (empty($_GET['script'])) { if (empty($_REQUEST['script'])) {
echo json_encode(array('type' => 'danger', 'msg' => $lang['danger']['script_empty'])); echo json_encode(array('type' => 'danger', 'msg' => $lang['danger']['script_empty']));
exit(); exit();
} }
$sieve->parse($_GET['script']); $sieve->parse($_REQUEST['script']);
} }
catch (Exception $e) { catch (Exception $e) {
echo json_encode(array('type' => 'danger', 'msg' => $e->getMessage())); echo json_encode(array('type' => 'danger', 'msg' => $e->getMessage()));

View File

@@ -179,9 +179,8 @@ $(document).ready(function() {
// Get script_data textarea content from form the button was clicked in // Get script_data textarea content from form the button was clicked in
var script = $('textarea[name="script_data"]', $(this).parents('form:first')).val(); var script = $('textarea[name="script_data"]', $(this).parents('form:first')).val();
$.ajax({ $.ajax({
dataType: 'json',
url: "/inc/ajax/sieve_validation.php", url: "/inc/ajax/sieve_validation.php",
type: "get", type: "post",
data: { script: script }, data: { script: script },
complete: function(data) { complete: function(data) {
var response = (data.responseText); var response = (data.responseText);