More robust regex for matching/parsing labels.

- limit label name to max 80 characters
- don't use `.*`
- limit total labels per document to 1000
This commit is contained in:
Shane Kilkelly 2017-05-25 09:32:10 +01:00
parent a363b62f23
commit 1ba8b702ad

View file

@ -26,8 +26,8 @@ define [
docId = @ide.editorManager.getCurrentDocId() docId = @ide.editorManager.getCurrentDocId()
docText = @ide.editorManager.getCurrentDocValue() docText = @ide.editorManager.getCurrentDocValue()
labels = [] labels = []
re = /\\label{(.*)}/g re = /\\label\{([^\}\n\\]{0,80})\}/g
while labelMatch = re.exec(docText) while (labelMatch = re.exec(docText)) and labels.length < 1000
if labelMatch[1] if labelMatch[1]
labels.push(labelMatch[1]) labels.push(labelMatch[1])
@state.documents[docId] = labels @state.documents[docId] = labels