Skip to content

Commit 7f3bc6b

Browse files
committed
Check CVR length
1 parent f12c1b4 commit 7f3bc6b

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9-
* Datafordeler CRV service endpoint update - GraphQL.
9+
* Datafordeler CVR service endpoint update - GraphQL.
1010

1111
## [3.0.3] - 2025-11-19
1212

src/Plugin/os2web/DataLookup/DatafordelerCVR.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
9090
*/
9191
public function lookup(string $param): CompanyLookupResult {
9292
try {
93+
if (!preg_match('/^\d{8}$/', $param)) {
94+
throw new \InvalidArgumentException('CVR must be exactly 8 digits.');
95+
}
96+
9397
$msg = sprintf('Hent virksomhed med CVRNummer: %s', $param);
9498
$this->auditLogger->info('DataLookup', $msg);
9599
$response = $this->executeQuery($param);
96100
$result = json_decode((string) $response->getBody());
97101
}
98-
catch (GuzzleException $e) {
102+
catch (GuzzleException | \InvalidArgumentException $e) {
99103
$msg = sprintf('Hent virksomhed med CVRNummer (%s): %s', $param, $e->getMessage());
100104
$this->auditLogger->error('DataLookup', $msg);
101105
$result = $e->getMessage();

0 commit comments

Comments
 (0)