Skip to content

Commit

Permalink
Pass quote=False to html.escape in the JSON reporter
Browse files Browse the repository at this point in the history
Close #2769
  • Loading branch information
PCManticore committed Feb 28, 2019
1 parent d7947b7 commit 3c51bfa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Pylint's ChangeLog
------------------

What's New in Pylint 2.3.1?
===========================

Release date: TBA

* Properly pass `quote=False` to `html.escape` in the JSON reporter

Close #2769

What's New in Pylint 2.3.0?
===========================

Expand Down
3 changes: 1 addition & 2 deletions pylint/reporters/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def handle_message(self, msg):
"column": msg.column,
"path": msg.path,
"symbol": msg.symbol,
# pylint: disable=deprecated-method; deprecated since 3.2.
"message": html.escape(msg.msg or ""),
"message": html.escape(msg.msg or "", quote=False),
"message-id": msg.msg_id,
}
)
Expand Down
6 changes: 6 additions & 0 deletions pylint/test/regrtest_data/unused_variable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pylint: disable=missing-docstring

def test():
variable = ''
variable2 = None
return variable2
22 changes: 22 additions & 0 deletions pylint/test/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,28 @@ def test_json_report_when_file_is_missing(self):
assert message[key] == value
assert message["message"].startswith("No module named")

def test_json_report_does_not_escape_quotes(self):
out = StringIO()
module = join(HERE, "regrtest_data", "unused_variable.py")
self._runtest([module], code=4, reporter=JSONReporter(out))
output = json.loads(out.getvalue())
assert isinstance(output, list)
assert len(output) == 1
assert isinstance(output[0], dict)
expected = {
"symbol": "unused-variable",
"module": "unused_variable",
"column": 4,
"message": "Unused variable 'variable'",
"message-id": "W0612",
"line": 4,
"type": "warning",
}
message = output[0]
for key, value in expected.items():
assert key in message
assert message[key] == value

def test_information_category_disabled_by_default(self):
expected = "Your code has been rated at 10.00/10"
path = join(HERE, "regrtest_data", "meta.py")
Expand Down

0 comments on commit 3c51bfa

Please sign in to comment.