From cb5034da7f855d0629168807e61a79c25470f3a4 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 15 Oct 2018 19:25:23 +0200 Subject: [PATCH] Fix xmlns and schemaLocation argument order in `XMLWriter` See #2545 --- .../install/files/lib/util/XMLWriter.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/util/XMLWriter.class.php b/wcfsetup/install/files/lib/util/XMLWriter.class.php index 97eea1d0be..9450d5cf38 100644 --- a/wcfsetup/install/files/lib/util/XMLWriter.class.php +++ b/wcfsetup/install/files/lib/util/XMLWriter.class.php @@ -52,11 +52,18 @@ class XMLWriter { $this->xml->startDocument('1.0', 'UTF-8'); $this->startElement($rootElement); - $attributes = array_merge($attributes, [ - 'xmlns' => $namespace, - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => $namespace . ' ' . $schemaLocation - ]); + $attributes = array_merge( + [ + 'xmlns' => $namespace, + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => $namespace . ' ' . $schemaLocation + ], + // `xmlns`, `xmlns:xsi`, and `xsi:schemaLocation` are explicitly set + // as first attributes in that order + array_filter($attributes, function($attributeName) { + return !in_array($attributeName, ['xmlns', 'xmlns:xsi', 'xsi:schemaLocation']); + }, ARRAY_FILTER_USE_KEY) + ); $this->writeAttributes($attributes); $this->activeDocument = true; -- 2.20.1