Skip to content

Commit

Permalink
webkitscmpy: Radar URLs in GitHub pick up surrounding punctuation
Browse files Browse the repository at this point in the history
rdar://118208532

Reviewed by Jonathan Bedard.

Adds more punctuation to be ignored when constructing link.

* Tools/CISupport/ews-build/steps.py:
(UpdatePullRequest.escape_html):
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/pull_request.py:
(PullRequest.escape_html):
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:

Canonical link: https://commits.webkit.org/271247@main
  • Loading branch information
briannafan committed Nov 29, 2023
1 parent 85e12f8 commit 4622c40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Tools/CISupport/ews-build/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6458,7 +6458,7 @@ class UpdatePullRequest(shell.ShellCommandNewStyle, GitHubMixin, AddToLogMixin):
def escape_html(cls, message):
message = ''.join(cls.ESCAPE_TABLE.get(c, c) for c in message)
message = re.sub(r'(https?://[^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="\1">\1</a>', message)
return re.sub(r'rdar://([^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="https://rdar.apple.com/\1">rdar://\1</a>', message)
return re.sub(r'rdar://([^\s<>,:;]+?)(?=[\s<>,:;().]|(&gt))', r'<a href="https://rdar.apple.com/\1">rdar://\1</a>', message)

def __init__(self, **kwargs):
super().__init__(logEnviron=False, timeout=300, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __repr__(self):
def escape_html(cls, message):
message = ''.join(cls.ESCAPE_TABLE.get(c, c) for c in message)
message = re.sub(r'(https?://[^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="\1">\1</a>', message)
return re.sub(r'rdar://([^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="https://rdar.apple.com/\1">rdar://\1</a>', message)
return re.sub(r'rdar://([^\s<>,:;]+?)(?=[\s<>,:;().]|(&gt))', r'<a href="https://rdar.apple.com/\1">rdar://\1</a>', message)

@classmethod
def unescape_html(cls, message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ def test_create_body_single_linked(self):
<a href="https://bugs.webkit.org/1234">https://bugs.webkit.org/1234</a>
<a href="https://rdar.apple.com/1234">rdar://1234</a>
Reviewed by Tim Contributor.
</pre>''',
)

def test_create_body_single_linked_punctuation(self):
self.assertEqual(
PullRequest.create_body(None, [Commit(
hash='11aa76f9fc380e9fe06157154f32b304e8dc4749',
message='[scoping] Bug to fix\nhttps://bugs.webkit.org/1234\n(rdar://1234)\n\nReviewed by Tim Contributor.\n',
)]), '''#### 11aa76f9fc380e9fe06157154f32b304e8dc4749
<pre>
[scoping] Bug to fix
<a href="https://bugs.webkit.org/1234">https://bugs.webkit.org/1234</a>
(<a href="https://rdar.apple.com/1234">rdar://1234</a>)
Reviewed by Tim Contributor.
</pre>''',
)
Expand Down

0 comments on commit 4622c40

Please sign in to comment.