Skip to content

Commit

Permalink
#136 Encode url path segments (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayselafsar authored Dec 24, 2024
1 parent 56a385f commit 1133a80
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private function encodeUrlPathSegments($url) {
$segments = explode('/', $url);

foreach ($segments as $index => $segment) {
if ($index > 2 && $segment !== '') {
if ($segment !== '') {
$segments[$index] = rawurlencode($segment);
}
}
Expand All @@ -193,17 +193,17 @@ private function generateDICOMJson($dicomFilePaths, $dicomFileNodes, $selectedFi
$fileUrlPath = '';
if ($isPublic) {
if ($singlePublicFileDownload) {
$urlParamFiles = substr($dicomFilePath, strrpos($dicomFilePath, '/') + 1);
$fileUrlPath = $downloadUrlPrefix.'/'.$urlParamFiles;
$urlParamFiles = $this->encodeUrlPathSegments(substr($dicomFilePath, strrpos($dicomFilePath, '/') + 1));
$fileUrlPath = $this->encodeUrlPathSegments($downloadUrlPrefix.'/'.$urlParamFiles);
} else {
$urlParamPath = substr($dicomFilePath, 0, strrpos($dicomFilePath, '/'));
$urlParamFiles = substr($dicomFilePath, strrpos($dicomFilePath, '/') + 1);
$urlParamPath = $this->encodeUrlPathSegments(substr($dicomFilePath, 0, strrpos($dicomFilePath, '/')));
$urlParamFiles = $this->encodeUrlPathSegments(substr($dicomFilePath, strrpos($dicomFilePath, '/') + 1));
$fileUrlPath = $downloadUrlPrefix.'?path='.$urlParamPath.'&files='.$urlParamFiles;
}
} else if ($currentUserPathToFile != null) {
$fileUrlPath = $downloadUrlPrefix.strstr($dicomFilePath, $currentUserPathToFile);
$fileUrlPath = $this->encodeUrlPathSegments($downloadUrlPrefix.strstr($dicomFilePath, $currentUserPathToFile));
} else {
$fileUrlPath = $downloadUrlPrefix.$dicomFilePath;
$fileUrlPath = $this->encodeUrlPathSegments($downloadUrlPrefix.$dicomFilePath);
}

$fileUrl = $this->urlGenerator->getAbsoluteURL($fileUrlPath);
Expand Down Expand Up @@ -352,7 +352,7 @@ private function generateDICOMJson($dicomFilePaths, $dicomFileNodes, $selectedFi
'WindowWidth' => $WindowWidth ? explode('\\', $WindowWidth)[0] : $WindowWidth,
'SeriesDate' => $SeriesDate,
),
'url' => 'dicomweb:'.$this->encodeUrlPathSegments($fileUrl),
'url' => 'dicomweb:'.$fileUrl,
);
array_push($dicomJson['studies'][$studyIndex]['series'][$seriesIndex]['instances'], $instance);
$dicomJson['studies'][$studyIndex]['NumInstances']++;
Expand Down

0 comments on commit 1133a80

Please sign in to comment.