Skip to content

Commit

Permalink
Cherry-pick 271247@main (4622c40). rdar://118208532
Browse files Browse the repository at this point in the history
    webkitscmpy: Radar URLs in GitHub pick up surrounding punctuation
    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

Canonical link: https://commits.webkit.org/267815.600@safari-7617-branch
  • Loading branch information
briannafan authored and JonWBedard committed Dec 1, 2023
1 parent 38eae99 commit ab2019d
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 @@ -5907,7 +5907,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 ab2019d

Please sign in to comment.