From 1ba8b702ad003e1e368ea4c9179d651fd2269ef4 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 25 May 2017 09:32:10 +0100 Subject: [PATCH] More robust regex for matching/parsing labels. - limit label name to max 80 characters - don't use `.*` - limit total labels per document to 1000 --- services/web/public/coffee/ide/labels/LabelsManager.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/labels/LabelsManager.coffee b/services/web/public/coffee/ide/labels/LabelsManager.coffee index fa86414139..8c091783f1 100644 --- a/services/web/public/coffee/ide/labels/LabelsManager.coffee +++ b/services/web/public/coffee/ide/labels/LabelsManager.coffee @@ -26,8 +26,8 @@ define [ docId = @ide.editorManager.getCurrentDocId() docText = @ide.editorManager.getCurrentDocValue() labels = [] - re = /\\label{(.*)}/g - while labelMatch = re.exec(docText) + re = /\\label\{([^\}\n\\]{0,80})\}/g + while (labelMatch = re.exec(docText)) and labels.length < 1000 if labelMatch[1] labels.push(labelMatch[1]) @state.documents[docId] = labels