From 329d9a1c9065d816f13fc36e12c27776568d50a3 Mon Sep 17 00:00:00 2001 From: n1073645 Date: Fri, 17 Apr 2020 15:11:25 +0100 Subject: [PATCH] Only operate on non-empty input --- src/core/operations/XMLValidator.mjs | 33 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/core/operations/XMLValidator.mjs b/src/core/operations/XMLValidator.mjs index 9c13b4d9..83c1b647 100644 --- a/src/core/operations/XMLValidator.mjs +++ b/src/core/operations/XMLValidator.mjs @@ -35,22 +35,23 @@ class XMLValidator extends Operation { */ run(input, args) { - try { - // Overwrite error handler since the built-in one does not raise exceptions. - (new DOMParser.DOMParser({errorHandler: { - warning: (msg) => { - throw new OperationError(msg); - }, - error: (msg) => { - throw new OperationError(msg); - }, - fatalError: (msg) => { - throw new OperationError(msg); - }, - }})).parseFromString(input); - } catch (err) { - throw new OperationError(err); - } + if (input) + try { + // Overwrite error handler since the built-in one does not raise exceptions. + (new DOMParser.DOMParser({errorHandler: { + warning: (msg) => { + throw new OperationError(msg); + }, + error: (msg) => { + throw new OperationError(msg); + }, + fatalError: (msg) => { + throw new OperationError(msg); + }, + }})).parseFromString(input); + } catch (err) { + throw new OperationError(err); + } return input; } }