Repository: planetarypy/pvl

Issue:
PVL Read ISIS Control network
**Describe the bug**
Unable to read an ISIS control network after upgrading to > 1.0. In the past, I have been able to pass a full ISIS control network to pvl and have it read the header off the network. The protobuf internals are outside the scope of the pvl library.

**To Reproduce**
Using the attached control network run a pvl.load(). The attached network is zipped so that GitHub will accept it as a filetype.

[test.net.zip](https://github.com/planetarypy/pvl/files/7521160/test.net.zip)

**Expected behavior**
A clear and concise description of what you expected to happen.

**Error logs or terminal captures**
```bash
Traceback (most recent call last):
  File "/Users/jlaura/miniconda3/envs/plio/lib/python3.8/site-packages/pvl/lexer.py", line 429, in lexer
    t = yield t
ValueError: Expecting an Aggregation Block, an Assignment Statement, or an End Statement, but found "14:37:20" 
```

**Your Environment (please complete the following information):**
 - OS: OS X Big Sur
 - Environment information: (e.g. Python version, etc.)
 - `pvl` Version 1.3.0

**Additional context**
I am not 100% sure that this is a PVL issue or an issue with the mocked control network. The Aggregation Block and lexor errors are opaque to me though, so I am looking for some additional guidance.


Comments:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index d3324bd..de80e6e 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -34,6 +34,10 @@ Fixed
 +++++
 * Deeply nested Aggregation Blocks (Object or Group) which had mis-matched Block Names
   should now properly result in LexerErrors instead of resulting in StopIteration Exceptions (Issue 100).
+* The default "Omni" parsing strategy, now considers the ASCII NULL character ("\0") a "reserved character."
+  The practical effect is that the ASCII NULL can not be in parameter names or unquoted strings (but would still
+  be successfully parsed in quoted strings). This means that PVL-text that might have incorrectly used ASCII NULLs
+  as delimiters will once again be consumed by our omnivorous parser (Issue 98).
 
 
 1.3.0 (2021-09-10)
diff --git a/pvl/grammar.py b/pvl/grammar.py
index 06eebf2..afa4e53 100755
--- a/pvl/grammar.py
+++ b/pvl/grammar.py
@@ -333,8 +333,10 @@ class OmniGrammar(PVLGrammar):
     def __init__(self):
         # Handle the fact that ISIS writes out unquoted plus signs.
         # See ISISGrammar for details.
+        # Also add the ASCII NULL ("\0") to the reserved_characters tuple.
         self.reserved_characters = tuple(
-            ISISGrammar.adjust_reserved_characters(self.reserved_characters)
+            ISISGrammar.adjust_reserved_characters(self.reserved_characters) +
+            ["\0", ]
         )
 
     def char_allowed(self, char):


Test patch:
diff --git a/tests/test_pvl.py b/tests/test_pvl.py
index b34d64e..5406372 100755
--- a/tests/test_pvl.py
+++ b/tests/test_pvl.py
@@ -842,6 +842,10 @@ def test_utf():
     label = pvl.load(utf_file)
     assert label["LABEL_REVISION_NOTE"] == "V1.0"
 
+    nulllabel = pvl.loads("foo=bar END\0wont=parse")
+    assert nulllabel["foo"] == "bar"
+    assert len(nulllabel) == 1
+
 
 def test_latin1():
     latin_file = os.path.join(BROKEN_DIR, "latin-1-degreesymb.pvl")