Allow non-breaking spaces in nginx config files (#10126)

Fixes @josevavia's issue in #9942.
This commit is contained in:
ohemorange
2025-01-10 15:25:05 -08:00
committed by GitHub
parent f59a639ec4
commit b18c074088
6 changed files with 31 additions and 17 deletions
@@ -35,8 +35,8 @@ class RawNginxParser:
"""A class that parses nginx configuration with pyparsing."""
# constants
space = Optional(White()).leaveWhitespace()
required_space = White().leaveWhitespace()
space = Optional(White(ws=' \t\r\n\u00a0')).leaveWhitespace()
required_space = White(ws=' \t\r\n\u00a0').leaveWhitespace()
left_bracket = Literal("{").suppress()
right_bracket = space + Literal("}").suppress()
@@ -362,6 +362,18 @@ class TestRawNginxParser(unittest.TestCase):
parsed = loads("")
assert parsed == []
def test_non_breaking_spaces(self):
# non-breaking spaces
test = u'\u00a0'
loads(test)
test = """
map $http_upgrade $connection_upgrade {
default upgrade;
''      close;
}
"""
loads(test)
class TestUnspacedList(unittest.TestCase):
"""Test the UnspacedList data structure"""
+1 -1
View File
@@ -11,7 +11,7 @@ install_requires = [
f'certbot>={version}',
# pyOpenSSL 23.1.0 is a bad release: https://github.com/pyca/pyopenssl/issues/1199
'PyOpenSSL>=17.5.0,!=23.1.0',
'pyparsing>=2.2.1',
'pyparsing>=2.4.7',
]
test_extras = [