From 930f52bb04d09d628c7365f3d9547d36b859e839 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Tue, 21 Nov 2017 13:51:02 -0700 Subject: [PATCH] Add null guard to tag parsing function to prevent parsing values that don't match tag RegEx. --- ui/src/hosts/apis/index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/src/hosts/apis/index.js b/ui/src/hosts/apis/index.js index 39caf9fbf0..f8815f07db 100644 --- a/ui/src/hosts/apis/index.js +++ b/ui/src/hosts/apis/index.js @@ -196,17 +196,21 @@ function parseSeries(series) { function parseTag(s, obj) { const match = tag.exec(s) - const kv = match[0] - const key = match[1] - const value = match[2] + if (match) { + const kv = match[0] + const key = match[1] + const value = match[2] - if (key) { - if (!obj.tags) { - obj.tags = {} + if (key) { + if (!obj.tags) { + obj.tags = {} + } + obj.tags[key] = value } - obj.tags[key] = value + return s.slice(match.index + kv.length) } - return s.slice(match.index + kv.length) + + return '' } let workStr = series.slice()