From fdb4be831b2b012bd7b9f417f2a022654d6dcb4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20K=C3=B6rner?=
 <20133276+dazze1812@users.noreply.github.com>
Date: Thu, 18 Jan 2024 20:02:59 +0100
Subject: [PATCH] fix(conan): correct regex for packages without @user/channel
 but with revisions (#26702)

---
 lib/modules/manager/conan/__fixtures__/conanfile.txt |  9 +++++----
 lib/modules/manager/conan/extract.spec.ts            | 10 ++++++++++
 lib/modules/manager/conan/extract.ts                 |  2 +-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/lib/modules/manager/conan/__fixtures__/conanfile.txt b/lib/modules/manager/conan/__fixtures__/conanfile.txt
index d9f3d1d993..fb8a66eab4 100644
--- a/lib/modules/manager/conan/__fixtures__/conanfile.txt
+++ b/lib/modules/manager/conan/__fixtures__/conanfile.txt
@@ -1,16 +1,17 @@
 [requires]
 poco/1.9.4
-zlib/[~1.2.3, loose=False]  
+zlib/[~1.2.3, loose=False]
 fake/8.62.134@test/dev
+cairo/1.17.2#aff2d03608351db075ec1348a3afc9ff
 cairo/1.17.2@_/_#aff2d03608351db075ec1348a3afc9ff
 
 [build_requires]
 7zip/[>1.1 <2.1, include_prerelease=True]
 curl/[~1.2.3, loose=False, include_prerelease=True]@test/dev
 boost/[>1.1 <2.1]
-catch2/[2.8]     
+catch2/[2.8]
 openssl/[~=3.0]@test/prod
-cmake/[>1.1 || 0.8] 
+cmake/[>1.1 || 0.8]
 cryptopp/[1.2.7 || >=1.2.9 <2.0.0]@test/local
 #commentedout/1.2
 # commentedout/3.4
@@ -29,4 +30,4 @@ openssl:shared=True
 
 [imports]
 bin, *.dll -> ./bin # Copies all dll files from packages bin folder to my local "bin" folder
-lib, *.dylib* -> ./bin # Copies all dylib files from packages lib folder to my local "bin" folder
\ No newline at end of file
+lib, *.dylib* -> ./bin # Copies all dylib files from packages lib folder to my local "bin" folder
diff --git a/lib/modules/manager/conan/extract.spec.ts b/lib/modules/manager/conan/extract.spec.ts
index 632686835a..b0df8a12a5 100644
--- a/lib/modules/manager/conan/extract.spec.ts
+++ b/lib/modules/manager/conan/extract.spec.ts
@@ -35,6 +35,16 @@ describe('modules/manager/conan/extract', () => {
           packageName: 'fake/8.62.134@test/dev',
           replaceString: 'fake/8.62.134@test/dev',
         },
+        {
+          autoReplaceStringTemplate:
+            '{{depName}}/{{newValue}}@_/_{{#if newDigest}}#{{newDigest}}{{/if}}',
+          currentDigest: 'aff2d03608351db075ec1348a3afc9ff',
+          currentValue: '1.17.2',
+          depName: 'cairo',
+          depType: 'requires',
+          packageName: 'cairo/1.17.2@_/_',
+          replaceString: 'cairo/1.17.2#aff2d03608351db075ec1348a3afc9ff',
+        },
         {
           autoReplaceStringTemplate:
             '{{depName}}/{{newValue}}@_/_{{#if newDigest}}#{{newDigest}}{{/if}}',
diff --git a/lib/modules/manager/conan/extract.ts b/lib/modules/manager/conan/extract.ts
index e35e16a2eb..e4fab9f502 100644
--- a/lib/modules/manager/conan/extract.ts
+++ b/lib/modules/manager/conan/extract.ts
@@ -4,7 +4,7 @@ import type { PackageDependency, PackageFileContent } from '../types';
 import { isComment } from './common';
 
 const regex = regEx(
-  `(?<name>[-_a-z0-9]+)/(?<version>[^@\n{*"']+)(?<userChannel>@[-_a-zA-Z0-9]+(?:/[^#\n.{*"' ]+|))?#?(?<revision>[-_a-f0-9]+[^\n{*"'])?`,
+  `(?<name>[-_a-z0-9]+)/(?<version>[^@#\n{*"']+)(?<userChannel>@[-_a-zA-Z0-9]+(?:/[^#\n.{*"' ]+|))?#?(?<revision>[-_a-f0-9]+[^\n{*"'])?`,
 );
 
 function setDepType(content: string, originalType: string): string {
-- 
GitLab