diff --git a/lib/modules/manager/maven/extract.spec.ts b/lib/modules/manager/maven/extract.spec.ts index d6689de4238d70..3efc9d99aea9fa 100644 --- a/lib/modules/manager/maven/extract.spec.ts +++ b/lib/modules/manager/maven/extract.spec.ts @@ -1,6 +1,7 @@ import { codeBlock } from 'common-tags'; import { Fixtures } from '../../../../test/fixtures'; import { fs } from '../../../../test/util'; +import { logger } from '../../../logger'; import { extractAllPackageFiles, extractExtensions, @@ -234,6 +235,17 @@ describe('modules/manager/maven/extract', () => { }); }); + it('extract dependencies with windows line endings', () => { + const logSpy = jest.spyOn(logger, 'warn'); + extractPackage( + ' \r\n', + 'some-file', + ); + expect(logSpy).toHaveBeenCalledWith( + 'Your pom.xml contains windows line endings. This is not supported and may result in parsing issues.', + ); + }); + it('tries minimum manifests', () => { const res = extractPackage(Fixtures.get('minimum.pom.xml'), 'some-file'); expect(res).toEqual({ diff --git a/lib/modules/manager/maven/extract.ts b/lib/modules/manager/maven/extract.ts index a46e485252dd27..ef06fe3911228c 100644 --- a/lib/modules/manager/maven/extract.ts +++ b/lib/modules/manager/maven/extract.ts @@ -26,6 +26,11 @@ function parsePom(raw: string, packageFile: string): XmlDocument | null { let project: XmlDocument; try { project = new XmlDocument(raw); + if (raw.includes('\r\n')) { + logger.warn( + 'Your pom.xml contains windows line endings. This is not supported and may result in parsing issues.', + ); + } } catch { logger.debug({ packageFile }, `Failed to parse as XML`); return null;