Don't parse a block begin while inside a block

If a PEM contained anything like <foobar>, the parser was doomed.

Fixes #78
This commit is contained in:
Davide De Rosa 2019-04-02 19:07:48 +02:00
parent d22420c06b
commit ccb6329f05

View File

@ -187,14 +187,16 @@ public class ConfigurationParser {
}
if unsupportedError == nil {
Regex.blockBegin.enumerateComponents(in: line) {
isHandled = true
let tag = $0.first!
let from = tag.index(after: tag.startIndex)
let to = tag.index(before: tag.endIndex)
if currentBlockName == nil {
Regex.blockBegin.enumerateComponents(in: line) {
isHandled = true
let tag = $0.first!
let from = tag.index(after: tag.startIndex)
let to = tag.index(before: tag.endIndex)
currentBlockName = String(tag[from..<to])
currentBlock = []
currentBlockName = String(tag[from..<to])
currentBlock = []
}
}
Regex.blockEnd.enumerateComponents(in: line) {
isHandled = true