Skip to content

Commit 8635f6b

Browse files
committed
ACP2E-923: Compact strategy causes an invalid reference to an external domain when running SCD
1 parent 9c3a50c commit 8635f6b

File tree

1 file changed

+19
-4
lines changed
  • app/code/Magento/Deploy/Package/Processor/PreProcessor

1 file changed

+19
-4
lines changed

app/code/Magento/Deploy/Package/Processor/PreProcessor/Css.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ private function hasOverrides(PackageFile $parentFile, Package $package)
120120
return false;
121121
}
122122

123+
/**
124+
* See if given path is local or remote URL
125+
*
126+
* @param string $path
127+
* @return bool
128+
*/
129+
private function isLocal(string $path): bool {
130+
$pattern = '{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i';
131+
$result = preg_match($pattern, $path);
132+
133+
return (bool) $result;
134+
}
135+
123136
/**
124137
* Build map file
125138
*
@@ -138,10 +151,12 @@ private function buildMap($packagePath, $filePath, $fullPath)
138151
$content = $this->staticDir->readFile($this->minification->addMinifiedSign($fullPath));
139152

140153
$callback = function ($matchContent) use ($packagePath, $filePath, &$imports) {
141-
$importRelPath = $this->normalize(pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']);
142-
$imports[$importRelPath] = $this->normalize(
143-
$packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']
144-
);
154+
if ($this->isLocal($matchContent['path'])) {
155+
$importRelPath = $this->normalize(pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']);
156+
$imports[$importRelPath] = $this->normalize(
157+
$packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']
158+
);
159+
}
145160
};
146161
preg_replace_callback(Import::REPLACE_PATTERN, $callback, $content);
147162

0 commit comments

Comments
 (0)