Skip to content

Commit

Permalink
Don't HTML-escape JSON messages
Browse files Browse the repository at this point in the history
The JSON module already escapes special characters as needed.

This was already reported in pylint-dev#2769 and partially addressed by
6b1adc6, but that commit still quotes angle
brackets ('<' and '>').
  • Loading branch information
cpitclaudel committed Mar 31, 2020
1 parent 53e5406 commit 44198b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pylint/reporters/json_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING

"""JSON reporter"""
import html
import json
import sys

Expand Down Expand Up @@ -37,7 +36,7 @@ def handle_message(self, msg):
"column": msg.column,
"path": msg.path,
"symbol": msg.symbol,
"message": html.escape(msg.msg or "", quote=False),
"message": msg.msg or "",
"message-id": msg.msg_id,
}
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ def test_json_report_when_file_has_syntax_error(self):
assert key in message
assert message[key] == value
assert "invalid syntax" in message["message"].lower()
assert "<unknown>" in message["message"].lower()

def test_json_report_when_file_is_missing(self):
out = StringIO()
Expand Down

0 comments on commit 44198b3

Please sign in to comment.