Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(platform/gitlab): Strip unicode null characters from markdown #19664

Merged
merged 8 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/modules/platform/gitlab/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,12 @@ These updates have all been created already. Click a checkbox below to force a r
expect(smartTruncate).toHaveBeenCalledTimes(1);
expect(smartTruncate).toHaveBeenCalledWith(expect.any(String), 1000000);
});

it('strips invalid unicode null characters', () => {
expect(
gitlab.massageMarkdown("The source contains 'Ruby\u0000' at: 2.7.6.219")
).toBe("The source contains 'Ruby' at: 2.7.6.219");
});
});

describe('getVulnerabilityAlerts()', () => {
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/platform/gitlab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ export function massageMarkdown(input: string): string {
let desc = input
.replace(regEx(/Pull Request/g), 'Merge Request')
.replace(regEx(/PR/g), 'MR')
.replace(regEx(/\]\(\.\.\/pull\//g), '](!');
.replace(regEx(/\]\(\.\.\/pull\//g), '](!')
// Strip unicode null characters as GitLab markdown does not permit them
.replace(regEx(/\u0000/g), "");
viceice marked this conversation as resolved.
Show resolved Hide resolved
viceice marked this conversation as resolved.
Show resolved Hide resolved

if (semver.lt(defaults.version, '13.4.0')) {
logger.debug(
Expand Down