Skip to content

Commit 8adc420

Browse files
authored
Don't HTML-escape JSON messages (#3467)
The JSON module already escapes special characters as needed. This was already reported in #2769 and partially addressed by 6b1adc6, but that commit still quotes angle brackets ('<' and '>').
1 parent 392b062 commit 8adc420

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ What's New in Pylint 2.5.0?
77

88
Release date: TBA
99

10+
* Remove HTML quoting of messages in JSON output.
11+
12+
Close #2769
1013

1114
* Adjust the `invalid-name` rule to work with non-ASCII identifiers and add the `non-ascii-name` rule.
1215

pylint/reporters/json_reporter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
88

99
"""JSON reporter"""
10-
import html
1110
import json
1211
import sys
1312

@@ -37,7 +36,7 @@ def handle_message(self, msg):
3736
"column": msg.column,
3837
"path": msg.path,
3938
"symbol": msg.symbol,
40-
"message": html.escape(msg.msg or "", quote=False),
39+
"message": msg.msg or "",
4140
"message-id": msg.msg_id,
4241
}
4342
)

tests/test_self.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def test_json_report_when_file_has_syntax_error(self):
347347
assert key in message
348348
assert message[key] == value
349349
assert "invalid syntax" in message["message"].lower()
350+
assert "<unknown>" in message["message"].lower()
350351

351352
def test_json_report_when_file_is_missing(self):
352353
out = StringIO()

0 commit comments

Comments
 (0)