From 5f9d0fb98c49533bb91fb57b6a767a0d9bbea9ce Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 11 Apr 2023 15:07:34 +0200 Subject: [PATCH] fix #5: handle entries with no attributes --- lib/ldif.pegjs | 2 +- lib/parser.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ldif.pegjs b/lib/ldif.pegjs index e962090..b8ffb06 100644 --- a/lib/ldif.pegjs +++ b/lib/ldif.pegjs @@ -58,7 +58,7 @@ ldif_content } ldif_entry "entry" - = dn:dn_spec SEP attribs:attrs_spec whitespace* { + = dn:dn_spec SEP attribs:attrs_spec? whitespace* { return new _type.Record(dn,attribs); } diff --git a/lib/parser.js b/lib/parser.js index 7b4dad9..749c458 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -595,6 +595,9 @@ module.exports = (function() { s2 = peg$parseSEP(); if (s2 !== peg$FAILED) { s3 = peg$parseattrs_spec(); + if (s3 === peg$FAILED) { + s3 = null; + } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parsewhitespace();