From ef77c8593186c0dc4911c816b7967746f7771a12 Mon Sep 17 00:00:00 2001 From: Tom Boutell Date: Wed, 3 Apr 2013 13:59:31 -0400 Subject: [PATCH] Don't allow bad lines of output, as seen in the rdf property, to crash the whole show. Make sure there is a : present. Example of output that crashes when identify outputs lines containing whitespace only: (I have added | marks to show where the whitespace ends. The | marks are not in the actual output of identify.) rdf:Alt: | | | signature: a42e682fbf3b7a4aa29577935f6deed66e7a3e688a3edb8e3a0ccc7aad21d My patch is to ignore lines with no : at all in them. Otherwise all properties encountered before this point, including the format property, are lost. --- imagemagick.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imagemagick.js b/imagemagick.js index b846c0c..bfbcc51 100644 --- a/imagemagick.js +++ b/imagemagick.js @@ -120,8 +120,12 @@ function parseIdentify(input) { prevIndent = indents[indents.length - 1]; } if (comps.length < 2) { - props.push(prop); - prop = prop[currentLine.split(':')[0].trim().toLowerCase()] = {}; + // Don't allow bad lines of output, as seen in the rdf property, to + // crash the whole show. Make sure there is a : present + if (currentLine.indexOf(':') !== -1) { + props.push(prop); + prop = prop[currentLine.split(':')[0].trim().toLowerCase()] = {}; + } } else { prop[comps[0].trim().toLowerCase()] = comps[1].trim() }