Fix PR description HTML escaping, the surrounding <pre> tag shouldn't be escaped (#66322)

This commit is contained in:
Mehdi Amini 2023-09-13 21:40:57 -07:00 committed by GitHub
parent c3b3942064
commit d2cd5a4595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,14 +132,14 @@ class PRSubscriber:
patch = html.escape(requests.get(self.pr.diff_url).text)
except:
patch = ""
diff_stats += "\n<pre>\n" + patch
diff_stats += "\n<pre>\n" + html.escape(patch)
# GitHub limits comments to 65,536 characters, let's limit the diff to 20kB.
DIFF_LIMIT = 20 * 1024
patch_link = f"Full diff: {self.pr.diff_url}\n"
if len(patch) > DIFF_LIMIT:
patch_link = f"\nPatch is {human_readable_size(len(patch))}, truncated to {human_readable_size(DIFF_LIMIT)} below, full version: {self.pr.diff_url}\n"
diff_stats = html.escape(diff_stats[0:DIFF_LIMIT]) + "...\n<truncated>\n"
diff_stats = diff_stats[0:DIFF_LIMIT] + "...\n<truncated>\n"
diff_stats += "</pre>"
team_mention = "@llvm/{}".format(team.slug)