From d6ef34a03e21f8e8da0bc45d6b7124d50cfc5ec1 Mon Sep 17 00:00:00 2001 From: cumul Date: Tue, 19 Dec 2017 05:34:31 +0900 Subject: [PATCH 01/16] Use UTF-8 encoding for nginx plugin --- certbot-nginx/certbot_nginx/_internal/parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/certbot-nginx/certbot_nginx/_internal/parser.py b/certbot-nginx/certbot_nginx/_internal/parser.py index f71d7c018..38c4d63e1 100644 --- a/certbot-nginx/certbot_nginx/_internal/parser.py +++ b/certbot-nginx/certbot_nginx/_internal/parser.py @@ -1,5 +1,6 @@ """NginxParser is a member object of the NginxConfigurator class.""" import copy +import codecs import functools import glob import logging @@ -205,7 +206,7 @@ class NginxParser(object): if item in self.parsed and not override: continue try: - with open(item) as _file: + with codecs.open(item, "r", "utf-8") as _file: parsed = nginxparser.load(_file) self.parsed[item] = parsed trees.append(parsed) @@ -414,7 +415,7 @@ class NginxParser(object): def _parse_ssl_options(ssl_options): if ssl_options is not None: try: - with open(ssl_options) as _file: + with codecs.open(ssl_options, "r", "utf-8") as _file: return nginxparser.load(_file) except IOError: logger.warning("Missing NGINX TLS options file: %s", ssl_options) From 247d9cd8870635dd9d065883e7853b86c0c76531 Mon Sep 17 00:00:00 2001 From: cumul Date: Wed, 31 Oct 2018 15:45:30 +0900 Subject: [PATCH 02/16] Use `io` module instead of `codecs` See https://mail.python.org/pipermail/python-list/2015-March/687124.html --- certbot-nginx/certbot_nginx/_internal/parser.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/certbot-nginx/certbot_nginx/_internal/parser.py b/certbot-nginx/certbot_nginx/_internal/parser.py index 38c4d63e1..d6182870c 100644 --- a/certbot-nginx/certbot_nginx/_internal/parser.py +++ b/certbot-nginx/certbot_nginx/_internal/parser.py @@ -1,8 +1,8 @@ """NginxParser is a member object of the NginxConfigurator class.""" import copy -import codecs import functools import glob +import io import logging import re @@ -206,12 +206,14 @@ class NginxParser(object): if item in self.parsed and not override: continue try: - with codecs.open(item, "r", "utf-8") as _file: + with io.open(item, "r", encoding="utf-8") as _file: parsed = nginxparser.load(_file) self.parsed[item] = parsed trees.append(parsed) except IOError: logger.warning("Could not open file: %s", item) + except UnicodeDecodeError: + logger.warning("Could not read file: %s due to invalid unicode character. Only UTF-8 encoding is supported.", item) except pyparsing.ParseException as err: logger.debug("Could not parse file: %s due to %s", item, err) return trees @@ -415,10 +417,12 @@ class NginxParser(object): def _parse_ssl_options(ssl_options): if ssl_options is not None: try: - with codecs.open(ssl_options, "r", "utf-8") as _file: + with io.open(ssl_options, "r", encoding="utf-8") as _file: return nginxparser.load(_file) except IOError: logger.warning("Missing NGINX TLS options file: %s", ssl_options) + except UnicodeDecodeError: + logger.warn("Could not read file: %s due to invalid unicode character. Only UTF-8 encoding is supported.", ssl_options) except pyparsing.ParseBaseException as err: logger.debug("Could not parse file: %s due to %s", ssl_options, err) return [] From 8b90b555186c0c51b0c37389375afcda2f27a3d6 Mon Sep 17 00:00:00 2001 From: cumul Date: Wed, 31 Oct 2018 16:48:01 +0900 Subject: [PATCH 03/16] Added test for valid/invalid unicode characters --- certbot-nginx/tests/parser_test.py | 12 ++++++++++++ .../testdata/etc_nginx/invalid_unicode_comments.conf | 7 +++++++ .../testdata/etc_nginx/valid_unicode_comments.conf | 9 +++++++++ 3 files changed, 28 insertions(+) create mode 100644 certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf create mode 100644 certbot-nginx/tests/testdata/etc_nginx/valid_unicode_comments.conf diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index f3a5665c5..232346396 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -482,6 +482,18 @@ class NginxParserTest(util.NginxTest): called = True self.assertTrue(called) + def test_valid_unicode_characters(self): + nparser = parser.NginxParser(self.config_path) + # pylint: disable=protected-access + parsed = nparser._parse_files(nparser.abs_path('unicode_support/valid_unicode_comments.conf')) + self.assertEqual(['server'], parsed[0][2][0]) + self.assertEqual(['listen', '80'], parsed[0][2][1][3]) + + def test_invalid_unicode_characters(self): + nparser = parser.NginxParser(self.config_path) + # pylint: disable=protected-access + parsed = nparser._parse_files(nparser.abs_path('unicode_support/invalid_unicode_comments.conf')) + self.assertEqual([], parsed) if __name__ == "__main__": diff --git a/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf b/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf new file mode 100644 index 000000000..596044cc9 --- /dev/null +++ b/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf @@ -0,0 +1,7 @@ +# This configuration file is saved with EUC-KR (a.k.a. cp949) encoding, +# including some Korean alphabets. + +server { + # ȳϼ. 80 Ʈ û ٸ. + listen 80; +} diff --git a/certbot-nginx/tests/testdata/etc_nginx/valid_unicode_comments.conf b/certbot-nginx/tests/testdata/etc_nginx/valid_unicode_comments.conf new file mode 100644 index 000000000..89c978b2e --- /dev/null +++ b/certbot-nginx/tests/testdata/etc_nginx/valid_unicode_comments.conf @@ -0,0 +1,9 @@ +# This configuration file is saved with valid UTF-8 encoding, +# including some CJK alphabets. + +server { + # 안녕하세요. 80번 포트에서 요청을 기다린다. + # こんにちは。80番ポートからリクエストを待つ。 + # 你好。等待端口80上的请求。 + listen 80; +} From 0b21e716cabba503e4ec7ce7e722e93a319f361f Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Wed, 30 Jan 2019 15:12:55 -0800 Subject: [PATCH 04/16] Fix lint problems with long lines --- certbot-nginx/certbot_nginx/_internal/parser.py | 7 +++++-- certbot-nginx/tests/parser_test.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/certbot-nginx/certbot_nginx/_internal/parser.py b/certbot-nginx/certbot_nginx/_internal/parser.py index d6182870c..72d4d38de 100644 --- a/certbot-nginx/certbot_nginx/_internal/parser.py +++ b/certbot-nginx/certbot_nginx/_internal/parser.py @@ -213,7 +213,9 @@ class NginxParser(object): except IOError: logger.warning("Could not open file: %s", item) except UnicodeDecodeError: - logger.warning("Could not read file: %s due to invalid unicode character. Only UTF-8 encoding is supported.", item) + logger.warning("Could not read file: %s due to invalid " + "character. Only UTF-8 encoding is " + "supported.", item) except pyparsing.ParseException as err: logger.debug("Could not parse file: %s due to %s", item, err) return trees @@ -422,7 +424,8 @@ def _parse_ssl_options(ssl_options): except IOError: logger.warning("Missing NGINX TLS options file: %s", ssl_options) except UnicodeDecodeError: - logger.warn("Could not read file: %s due to invalid unicode character. Only UTF-8 encoding is supported.", ssl_options) + logger.warn("Could not read file: %s due to invalid character. " + "Only UTF-8 encoding is supported.", ssl_options) except pyparsing.ParseBaseException as err: logger.debug("Could not parse file: %s due to %s", ssl_options, err) return [] diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index 232346396..632ea179f 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -485,14 +485,16 @@ class NginxParserTest(util.NginxTest): def test_valid_unicode_characters(self): nparser = parser.NginxParser(self.config_path) # pylint: disable=protected-access - parsed = nparser._parse_files(nparser.abs_path('unicode_support/valid_unicode_comments.conf')) + path = nparser.abs_path('unicode_support/valid_unicode_comments.conf') + parsed = nparser._parse_files(path) self.assertEqual(['server'], parsed[0][2][0]) self.assertEqual(['listen', '80'], parsed[0][2][1][3]) def test_invalid_unicode_characters(self): nparser = parser.NginxParser(self.config_path) # pylint: disable=protected-access - parsed = nparser._parse_files(nparser.abs_path('unicode_support/invalid_unicode_comments.conf')) + path = nparser.abs_path('unicode_support/invalid_unicode_comments.conf') + parsed = nparser._parse_files(path) self.assertEqual([], parsed) From c3cfd412c91cfdc2d0ba95ad4c3751324bf8b132 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 01:46:41 +0900 Subject: [PATCH 05/16] Relpace deprecated `logger.warn()` with `logger.warning()` --- certbot-nginx/certbot_nginx/_internal/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/certbot-nginx/certbot_nginx/_internal/parser.py b/certbot-nginx/certbot_nginx/_internal/parser.py index 72d4d38de..0c1151826 100644 --- a/certbot-nginx/certbot_nginx/_internal/parser.py +++ b/certbot-nginx/certbot_nginx/_internal/parser.py @@ -424,8 +424,8 @@ def _parse_ssl_options(ssl_options): except IOError: logger.warning("Missing NGINX TLS options file: %s", ssl_options) except UnicodeDecodeError: - logger.warn("Could not read file: %s due to invalid character. " - "Only UTF-8 encoding is supported.", ssl_options) + logger.warning("Could not read file: %s due to invalid character. " + "Only UTF-8 encoding is supported.", ssl_options) except pyparsing.ParseBaseException as err: logger.debug("Could not parse file: %s due to %s", ssl_options, err) return [] From 22685ef86fa2f00be647403f3c64cec79b4d2be1 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 02:23:46 +0900 Subject: [PATCH 06/16] Remove `unicode_support/` path in test case --- certbot-nginx/tests/parser_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index 632ea179f..d766a6a9b 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -485,7 +485,7 @@ class NginxParserTest(util.NginxTest): def test_valid_unicode_characters(self): nparser = parser.NginxParser(self.config_path) # pylint: disable=protected-access - path = nparser.abs_path('unicode_support/valid_unicode_comments.conf') + path = nparser.abs_path('valid_unicode_comments.conf') parsed = nparser._parse_files(path) self.assertEqual(['server'], parsed[0][2][0]) self.assertEqual(['listen', '80'], parsed[0][2][1][3]) @@ -493,7 +493,7 @@ class NginxParserTest(util.NginxTest): def test_invalid_unicode_characters(self): nparser = parser.NginxParser(self.config_path) # pylint: disable=protected-access - path = nparser.abs_path('unicode_support/invalid_unicode_comments.conf') + path = nparser.abs_path('invalid_unicode_comments.conf') parsed = nparser._parse_files(path) self.assertEqual([], parsed) From 36311a276b7ffbff9bcc8b019f6a12f97e153712 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 02:46:27 +0900 Subject: [PATCH 07/16] Add test case for `_parse_ssl_options()` --- certbot-nginx/tests/parser_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index d766a6a9b..a0484f965 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -497,6 +497,25 @@ class NginxParserTest(util.NginxTest): parsed = nparser._parse_files(path) self.assertEqual([], parsed) + def test_valid_unicode_characters_in_ssl_options(self): + nparser = parser.NginxParser(self.config_path) + path = nparser.abs_path('valid_unicode_comments.conf') + parsed = parser._parse_ssl_options(path) # pylint: disable=protected-access + self.assertEqual(['server'], parsed[2][0]) + self.assertEqual(['listen', '80'], parsed[2][1][3]) + + def test_invalid_unicode_characters_in_ssl_options(self): + with self.assertLogs() as log: + nparser = parser.NginxParser(self.config_path) + path = nparser.abs_path('invalid_unicode_comments.conf') + parsed = parser._parse_ssl_options(path) # pylint: disable=protected-access + + self.assertEqual([], parsed) + self.assertTrue([ + True + for output in log.output + if ('invalid character' in output) and ('UTF-8' in output) + ]) if __name__ == "__main__": unittest.main() # pragma: no cover From 20df5507ae9a17df35f9c1152a34d0c52ba304f6 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 02:47:44 +0900 Subject: [PATCH 08/16] Add logging test for `_parse_files()` --- certbot-nginx/tests/parser_test.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index a0484f965..89bcf689a 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -491,11 +491,17 @@ class NginxParserTest(util.NginxTest): self.assertEqual(['listen', '80'], parsed[0][2][1][3]) def test_invalid_unicode_characters(self): - nparser = parser.NginxParser(self.config_path) - # pylint: disable=protected-access - path = nparser.abs_path('invalid_unicode_comments.conf') - parsed = nparser._parse_files(path) + with self.assertLogs() as log: + nparser = parser.NginxParser(self.config_path) + path = nparser.abs_path('invalid_unicode_comments.conf') + parsed = nparser._parse_files(path) # pylint: disable=protected-access + self.assertEqual([], parsed) + self.assertTrue([ + True + for output in log.output + if ('invalid character' in output) and ('UTF-8' in output) + ]) def test_valid_unicode_characters_in_ssl_options(self): nparser = parser.NginxParser(self.config_path) From 2aac24c9829d565d6ba6aa42ad9fc7e5ba4926b3 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 02:48:21 +0900 Subject: [PATCH 09/16] Trivial code clean-up --- certbot-nginx/tests/parser_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index 89bcf689a..1f9e3c996 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -484,9 +484,8 @@ class NginxParserTest(util.NginxTest): def test_valid_unicode_characters(self): nparser = parser.NginxParser(self.config_path) - # pylint: disable=protected-access path = nparser.abs_path('valid_unicode_comments.conf') - parsed = nparser._parse_files(path) + parsed = nparser._parse_files(path) # pylint: disable=protected-access self.assertEqual(['server'], parsed[0][2][0]) self.assertEqual(['listen', '80'], parsed[0][2][1][3]) From b3071aab29c480d52837e70fcf3fed9379f22200 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 02:52:41 +0900 Subject: [PATCH 10/16] Add my name to AUTHORS.md :) --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 80a24d3be..8653382b8 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -268,3 +268,4 @@ Authors * [YourDaddyIsHere](https://github.com/YourDaddyIsHere) * [Zach Shepherd](https://github.com/zjs) * [陈三](https://github.com/chenxsan) +* [Yuseong Cho](https://github.com/g6123) From d68f37ae88d32dcca97785df9ec4c3cf70c437ae Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 02:56:43 +0900 Subject: [PATCH 11/16] Add this change to CHANGELOG.md --- certbot/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certbot/CHANGELOG.md b/certbot/CHANGELOG.md index 126b07eec..837f48db2 100644 --- a/certbot/CHANGELOG.md +++ b/certbot/CHANGELOG.md @@ -17,7 +17,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/). ### Fixed -* +* Fix nginx plguin crash when non-ASCII configuration file is being read More details about these changes can be found on our GitHub repo. From 32904d8c9e2c1c6dd253eb860472053053238238 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 04:26:37 +0900 Subject: [PATCH 12/16] Add `TestCase.assertLogs()` backport for Python 2.7 --- certbot-nginx/tests/test_log_util.py | 123 +++++++++++++++++++++++++++ certbot-nginx/tests/test_util.py | 3 +- 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 certbot-nginx/tests/test_log_util.py diff --git a/certbot-nginx/tests/test_log_util.py b/certbot-nginx/tests/test_log_util.py new file mode 100644 index 000000000..f8135ca26 --- /dev/null +++ b/certbot-nginx/tests/test_log_util.py @@ -0,0 +1,123 @@ +"""Backport for `TestCase.assertLogs()`. + +Most of the idea and code are from CPython implementation. +https://github.com/python/cpython/blob/b76518d43fb82ed9e5d27025d18c90a23d525c90/Lib/unittest/case.py +""" +import logging +import collections + +__all__ = ['AssertLogsMixin'] + +LoggingWatcher = collections.namedtuple('LoggingWatcher', ['records', 'output']) + + +class CapturingHandler(logging.Handler): + """ + A logging handler capturing all (raw and formatted) logging output. + """ + + def __init__(self): + super(CapturingHandler, self).__init__() + self.watcher = LoggingWatcher([], []) + + def flush(self): + pass + + def emit(self, record): + self.watcher.records.append(record) + self.watcher.output.append(self.format(record)) + + + +class AssertLogsContext(object): + """ + A context manager used to implement `TestCase.assertLogs()`. + """ + + LOGGING_FORMAT = '%(levelname)s:%(name)s:%(message)s' + + def __init__(self, test_case, logger_name, level): + self.test_case = test_case + + self.logger_name = logger_name + self.logger_states = None + self.logger = None + + if level: + # pylint: disable=protected-access,no-member + try: + name_to_level = logging._nameToLevel # type: ignore + except AttributeError: + name_to_level = logging._levelNames # type: ignore + + self.level = name_to_level.get(level, level) + else: + self.level = logging.INFO + + self.watcher = None + + def _save_logger_states(self): + self.logger_states = (self.logger.handlers[:], self.logger.level, self.logger.propagate) + + def _restore_logger_states(self): + self.logger.handlers, self.logger.level, self.logger.propagate = self.logger_states + + def __enter__(self): + if isinstance(self.logger_name, logging.Logger): + self.logger = self.logger_name + else: + self.logger = logging.getLogger(self.logger_name) + + formatter = logging.Formatter(self.LOGGING_FORMAT) + + handler = CapturingHandler() + handler.setFormatter(formatter) + + self._save_logger_states() + self.logger.handlers = [handler] + self.logger.setLevel(self.level) + self.logger.propagate = False + + self.watcher = handler.watcher + return handler.watcher + + def __exit__(self, exc_type, exc_value, tb): + self._restore_logger_states() + + if exc_type is not None: + # let unexpected exceptions pass through + return + + if not self.watcher.records: + self._raiseFailure( + "no logs of level {} or higher triggered on {}" + .format(logging.getLevelName(self.level), self.logger.name)) + + def _raiseFailure(self, message): + message = self.test_case._formatMessage(None, message) # pylint: disable=protected-access + raise self.test_case.failureException(message) + + +class AssertLogsMixin(object): + """ + A mixin that implements `TestCase.assertLogs()`. + """ + + def assertLogs(self, logger=None, level=None): + """Fail unless a log message of level *level* or higher is emitted + on *logger_name* or its children. If omitted, *level* defaults to + INFO and *logger* defaults to the root logger. + This method must be used as a context manager, and will yield + a recording object with two attributes: `output` and `records`. + At the end of the context manager, the `output` attribute will + be a list of the matching formatted log messages and the + `records` attribute will be a list of the corresponding LogRecord + objects. + Example:: + with self.assertLogs('foo', level='INFO') as cm: + logging.getLogger('foo').info('first message') + logging.getLogger('foo.bar').error('second message') + self.assertEqual(cm.output, ['INFO:foo:first message', + 'ERROR:foo.bar:second message']) + """ + return AssertLogsContext(self, logger, level) diff --git a/certbot-nginx/tests/test_util.py b/certbot-nginx/tests/test_util.py index 8dfd18637..4c9da84bd 100644 --- a/certbot-nginx/tests/test_util.py +++ b/certbot-nginx/tests/test_util.py @@ -14,9 +14,10 @@ from certbot.plugins import common from certbot.tests import util as test_util from certbot_nginx._internal import configurator from certbot_nginx._internal import nginxparser +import test_log_util -class NginxTest(test_util.ConfigTestCase): +class NginxTest(test_log_util.AssertLogsMixin, test_util.ConfigTestCase): def setUp(self): super(NginxTest, self).setUp() From 5b29e4616c4a7bae3ba18b0eca8ae245afbf97f1 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Mon, 24 Feb 2020 05:30:54 +0900 Subject: [PATCH 13/16] Add simple comments --- certbot-nginx/tests/test_log_util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/certbot-nginx/tests/test_log_util.py b/certbot-nginx/tests/test_log_util.py index f8135ca26..7aebf2151 100644 --- a/certbot-nginx/tests/test_log_util.py +++ b/certbot-nginx/tests/test_log_util.py @@ -46,8 +46,10 @@ class AssertLogsContext(object): if level: # pylint: disable=protected-access,no-member try: + # In Python 3.x name_to_level = logging._nameToLevel # type: ignore except AttributeError: + # In Python 2.7 name_to_level = logging._levelNames # type: ignore self.level = name_to_level.get(level, level) From 2ae090529e66a059e0e077d233f427583caa7c6c Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Tue, 25 Feb 2020 13:17:25 +0900 Subject: [PATCH 14/16] Fixed typo & some trivial documentation change --- AUTHORS.md | 2 +- certbot/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 8653382b8..f5b981b8e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -266,6 +266,6 @@ Authors * [Yomna](https://github.com/ynasser) * [Yoni Jah](https://github.com/yonjah) * [YourDaddyIsHere](https://github.com/YourDaddyIsHere) +* [Yuseong Cho](https://github.com/g6123) * [Zach Shepherd](https://github.com/zjs) * [陈三](https://github.com/chenxsan) -* [Yuseong Cho](https://github.com/g6123) diff --git a/certbot/CHANGELOG.md b/certbot/CHANGELOG.md index 837f48db2..a68c50ad0 100644 --- a/certbot/CHANGELOG.md +++ b/certbot/CHANGELOG.md @@ -17,7 +17,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/). ### Fixed -* Fix nginx plguin crash when non-ASCII configuration file is being read +* Fix nginx plugin crash when non-ASCII configuration file is being read More details about these changes can be found on our GitHub repo. From ddf68aea8039b81940b7caf731405ef10613b5db Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Tue, 25 Feb 2020 13:21:10 +0900 Subject: [PATCH 15/16] Update comment in testdata file --- .../tests/testdata/etc_nginx/invalid_unicode_comments.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf b/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf index 596044cc9..4d6384535 100644 --- a/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf +++ b/certbot-nginx/tests/testdata/etc_nginx/invalid_unicode_comments.conf @@ -1,5 +1,5 @@ # This configuration file is saved with EUC-KR (a.k.a. cp949) encoding, -# including some Korean alphabets. +# including some Korean letters. server { # ȳϼ. 80 Ʈ û ٸ. From a48907920885671ef5a57bc1cda556e90c5e0e20 Mon Sep 17 00:00:00 2001 From: cumul0529 Date: Tue, 25 Feb 2020 13:26:36 +0900 Subject: [PATCH 16/16] Update parser test to better assert logging output --- certbot-nginx/tests/parser_test.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/certbot-nginx/tests/parser_test.py b/certbot-nginx/tests/parser_test.py index 1f9e3c996..fd5d338d3 100644 --- a/certbot-nginx/tests/parser_test.py +++ b/certbot-nginx/tests/parser_test.py @@ -496,11 +496,10 @@ class NginxParserTest(util.NginxTest): parsed = nparser._parse_files(path) # pylint: disable=protected-access self.assertEqual([], parsed) - self.assertTrue([ - True + self.assertTrue(any( + ('invalid character' in output) and ('UTF-8' in output) for output in log.output - if ('invalid character' in output) and ('UTF-8' in output) - ]) + )) def test_valid_unicode_characters_in_ssl_options(self): nparser = parser.NginxParser(self.config_path) @@ -516,11 +515,10 @@ class NginxParserTest(util.NginxTest): parsed = parser._parse_ssl_options(path) # pylint: disable=protected-access self.assertEqual([], parsed) - self.assertTrue([ - True + self.assertTrue(any( + ('invalid character' in output) and ('UTF-8' in output) for output in log.output - if ('invalid character' in output) and ('UTF-8' in output) - ]) + )) if __name__ == "__main__": unittest.main() # pragma: no cover