Skip to content

Commit

Permalink
Set regexp for media urls as static
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault committed Jan 27, 2025
1 parent e55ee6c commit 61e36aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lizmap/modules/lizmap/lib/Request/WMSRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class WMSRequest extends OGCRequest
{
protected $tplExceptions = 'lizmap~wms_exception';

protected static $regexp_media_urls = '#["\']((\.\./)?media/.+?\.\w{3,10})["\']#';

private $forceRequest = false;

public function getForceRequest()
Expand Down Expand Up @@ -662,7 +664,7 @@ protected function gfiVectorXmlToHtml($layerId, $layerName, $layerTitle, $layer,
$templateConfigured = true;
// first replace all "media/bla/bla/llkjk.ext" by full url
$popupTemplate = preg_replace_callback(
'#(["\']){1}((\.\./)?media/.+\.\w{3,10})(["\']){1}#U',
self::$regexp_media_urls,
array($this, 'replaceMediaPathByMediaUrl'),
$popupTemplate
);
Expand Down Expand Up @@ -741,7 +743,7 @@ protected function gfiVectorXmlToHtml($layerId, $layerName, $layerTitle, $layer,
if ($attribute['name'] == 'maptip') {
// first replace all "media/bla/bla/llkjk.ext" by full url
$maptipValue = preg_replace_callback(
'#(["\']){1}((\.\./)?media/.+\.\w{3,10})(["\']){1}#U',
self::$regexp_media_urls,
array($this, 'replaceMediaPathByMediaUrl'),
$attribute['value']
);
Expand Down Expand Up @@ -863,7 +865,7 @@ protected function replaceMediaPathByMediaUrl($matches)
array(
'repository' => $this->repository->getKey(),
'project' => $this->project->getKey(),
'path' => $matches[2],
'path' => $matches[1],
)
);
$return .= '"';
Expand Down

0 comments on commit 61e36aa

Please sign in to comment.