Просмотр исходного кода

More robust regex for matching/parsing labels.

- limit label name to max 80 characters
- don't use `.*`
- limit total labels per document to 1000
Shane Kilkelly 9 лет назад
Родитель
Сommit
1ba8b702ad
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      services/web/public/coffee/ide/labels/LabelsManager.coffee

+ 2 - 2
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