From 10e4f0a3ddcf7d8d540322b8a0fbc07a01171bbb Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Wed, 14 Sep 2016 23:06:25 +0530 Subject: [PATCH] Check if the regex matching returns null before using it further Fix #12473 : Code can throw unhandled exception Signed-off-by: Deven Bansod --- js/functions.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 103ba84707..99eff84673 100644 --- a/js/functions.js +++ b/js/functions.js @@ -613,8 +613,12 @@ function confirmLink(theLink, theSqlQuery) if (is_confirmed) { if ($(theLink).hasClass('formLinkSubmit')) { var name = 'is_js_confirmed'; + if ($(theLink).attr('href').indexOf('usesubform') != -1) { - name = 'subform[' + $(theLink).attr('href').substr('#').match(/usesubform\[(\d+)\]/i)[1] + '][is_js_confirmed]'; + var matches = $(theLink).attr('href').substr('#').match(/usesubform\[(\d+)\]/i); + if (matches != null) { + name = 'subform[' + matches[1] + '][is_js_confirmed]'; + } } $(theLink).parents('form').append('');