From 7183896ed76ac5b44d895303c8a7f6c08726b5f7 Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Wed, 13 Jul 2016 17:24:05 -0700 Subject: [PATCH] Preserve spaces before comments at the beginning of a file --- .../chive/chive-nginx-master/win-utf | 1 - certbot-nginx/certbot_nginx/nginxparser.py | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/certbot-compatibility-test/nginx/nginx-roundtrip-testdata/chive/chive-nginx-master/win-utf b/certbot-compatibility-test/nginx/nginx-roundtrip-testdata/chive/chive-nginx-master/win-utf index e4b1e8360..ed8bc007a 100644 --- a/certbot-compatibility-test/nginx/nginx-roundtrip-testdata/chive/chive-nginx-master/win-utf +++ b/certbot-compatibility-test/nginx/nginx-roundtrip-testdata/chive/chive-nginx-master/win-utf @@ -2,7 +2,6 @@ # This map is not a full windows-1251 <> utf8 map: it does not # contain Serbian and Macedonian letters. If you need a full map, # use contrib/unicode2nginx/win-utf map instead. -# charset_map windows-1251 utf-8 { diff --git a/certbot-nginx/certbot_nginx/nginxparser.py b/certbot-nginx/certbot_nginx/nginxparser.py index 10a26ecb2..d02687d2f 100644 --- a/certbot-nginx/certbot_nginx/nginxparser.py +++ b/certbot-nginx/certbot_nginx/nginxparser.py @@ -73,16 +73,11 @@ class RawNginxParser(object): block << Group(block_begin + left_bracket + block_innards + right_bracket) script = OneOrMore(Group(comment | assignment) ^ block ^ map_block) + space + stringEnd - script.parseWithTabs() - testLine = OneOrMore(Group(space + key + location_statement)).leaveWhitespace() - testTwo = OneOrMore(block) + script.parseWithTabs().leaveWhitespace() def __init__(self, source): self.source = source - def test(self): - return self.testLine.parseString(self.source) - def parse(self): """Returns the parsed tree.""" return self.script.parseString(self.source)