From b5d56f99921ec30027744a4a815152cb1604edc8 Mon Sep 17 00:00:00 2001 From: "Roman Schmerold (BNoiZe)" Date: Mon, 27 Jan 2014 20:26:45 +0100 Subject: [PATCH] Fixed problems with merging oneline blocks, fixes #1360 Signed-off-by: Roman Schmerold (BNoiZe) --- scripts/jobs/cron_tasks.inc.http.30.nginx.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index e640db67..6e298436 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -437,6 +437,7 @@ class nginx { protected function mergeVhostBlocks($vhost_content) { + $vhost_content = str_replace(array("{", "}"), array("{\n", "\n}"), $vhost_content); $vhost_content = explode("\n", preg_replace('/[ \t]+/', ' ', trim(preg_replace('/\t+/', '', $vhost_content)))); $vhost_content = array_filter($vhost_content, create_function('$a','return preg_match("#\S#", $a);')); @@ -445,6 +446,7 @@ class nginx { $isOpen = false; $addAfter = false; foreach ($vhost_content as $line) { + $line = trim($line); if (substr_count($line, "{") != 0 && substr_count($line, "}") == 0 && substr_count($line, "server") == 0 && $isOpen === false) { $isOpen = true; $addAfter = array_search($line, $new_vhost_content); @@ -994,4 +996,6 @@ class nginx { } } } + + }