Skip to content

Commit

Permalink
fix(platform/gitlab): Strip unicode null characters from markdown (#1…
Browse files Browse the repository at this point in the history
…9664)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
3 people committed Jan 11, 2023
1 parent e02ad9e commit 218ac84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/modules/platform/gitlab/index.spec.ts
Expand Up @@ -2046,6 +2046,12 @@ These updates have all been created already. Click a checkbox below to force a r
`;

describe('massageMarkdown(input)', () => {
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");
});

it('returns updated pr body', async () => {
jest.mock('../utils/pr-body');
const { smartTruncate } = require('../utils/pr-body');
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/platform/gitlab/index.ts
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), ''); // eslint-disable-line no-control-regex

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

0 comments on commit 218ac84

Please sign in to comment.