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,6 +187,7 @@ public class ConfigurationParser {
} }
if unsupportedError == nil { if unsupportedError == nil {
if currentBlockName == nil {
Regex.blockBegin.enumerateComponents(in: line) { Regex.blockBegin.enumerateComponents(in: line) {
isHandled = true isHandled = true
let tag = $0.first! let tag = $0.first!
@ -196,6 +197,7 @@ public class ConfigurationParser {
currentBlockName = String(tag[from..<to]) currentBlockName = String(tag[from..<to])
currentBlock = [] currentBlock = []
} }
}
Regex.blockEnd.enumerateComponents(in: line) { Regex.blockEnd.enumerateComponents(in: line) {
isHandled = true isHandled = true
let tag = $0.first! let tag = $0.first!