Skip to content

Commit

Permalink
Fix regexp for matching all full urls to match part with &
Browse files Browse the repository at this point in the history
Regression introduced by Change 393975. & is htmlescaped to
& and then not matched. We allow &

Google-Bug-Id: b/361490963
Release-Notes: skip
Change-Id: I5d3fb84f5533a59ba041eef806d148a6f960c5c7
(cherry picked from commit 20014ed)
  • Loading branch information
milutin authored and paladox committed Sep 2, 2024
1 parent dd52425 commit 2c5b02c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class GrFormattedText extends LitElement {
this.repoCommentLinks = repoCommentLinks;
// Always linkify URLs starting with https?://
this.repoCommentLinks['ALWAYS_LINK_HTTP'] = {
match: '(https?://((?!&(gt|lt|amp|quot|apos);)\\S)+[\\w/~-])',
match: '(https?://((?!&(gt|lt|quot|apos);)\\S)+[\\w/~-])',
link: '$1',
enabled: true,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ suite('gr-formatted-text tests', () => {
await checkLinking('https://www.google.com/');
await checkLinking('https://www.google.com/asdf~');
await checkLinking('https://www.google.com/asdf-');
await checkLinking('https://www.google.com/asdf-');
// matches & part as well, even we first linkify and then htmlEscape
await checkLinking(
'https://google.com/traces/list?project=gerrit&tid=123'
);
});
});

Expand Down Expand Up @@ -710,6 +715,10 @@ suite('gr-formatted-text tests', () => {
await checkLinking('http://www.google.com');
await checkLinking('https://www.google.com');
await checkLinking('https://www.google.com/');
// matches & part as well, even we first linkify and then htmlEscape
await checkLinking(
'https://google.com/traces/list?project=gerrit&tid=123'
);
});

suite('user suggest fix', () => {
Expand Down

0 comments on commit 2c5b02c

Please sign in to comment.