Skip to content

Commit

Permalink
Remote Dataset: Fix for unexpected error for long URI string (#2759)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgbaybay authored Oct 11, 2024
1 parent 4ee5f4e commit 614040e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Controller/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,11 @@ public function testRemoteRequest(Request $request, Response $response)
$dataSet->sourceId = $sanitizedParams->getInt('sourceId');
$dataSet->ignoreFirstRow = $sanitizedParams->getCheckbox('ignoreFirstRow');

// Before running the test, check if the length is within the current URI character limit
if (strlen($dataSet->uri) > 250) {
throw new InvalidArgumentException(__('URI can not be longer than 250 characters'), 'uri');
}

// Set this DataSet as active.
$dataSet->setActive();

Expand Down
5 changes: 5 additions & 0 deletions lib/Entity/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,11 @@ public function validate()
if ($this->rowLimit > $this->config->getSetting('DATASET_HARD_ROW_LIMIT')) {
throw new InvalidArgumentException(__('DataSet row limit cannot be larger than the CMS dataSet row limit'));
}

// Check if the length is within the current URI character limit
if (!v::stringType()->length(null, 250)->validate($this->uri)) {
throw new InvalidArgumentException(__('URI can not be longer than 250 characters'), 'uri');
}
}

try {
Expand Down

0 comments on commit 614040e

Please sign in to comment.