mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 15:38:03 -05:00
fix: ensure CDN URL is only applied to asset files and improve replacement script security
This commit is contained in:
@@ -10,13 +10,16 @@ fi
|
||||
|
||||
echo "Replacing pre-baked value.."
|
||||
|
||||
# Escape special characters in REPLACEMENT for sed to avoid regex issues and injection attacks
|
||||
ESCAPED_REPLACEMENT=$(printf '%s\n' "$REPLACEMENT" | sed 's/[\/&]/\\&/g')
|
||||
|
||||
# Replace in JS files in assets directory
|
||||
find assets -type f -name "*.js" |
|
||||
while read file; do
|
||||
sed -i "s|$ORIGINAL|$REPLACEMENT|g" "$file"
|
||||
sed -i "s|$ORIGINAL|$ESCAPED_REPLACEMENT|g" "$file"
|
||||
done
|
||||
|
||||
# Replace in index.html (for asset references)
|
||||
if [ -f "index.html" ]; then
|
||||
sed -i "s|$ORIGINAL|$REPLACEMENT|g" "index.html"
|
||||
sed -i "s|$ORIGINAL|$ESCAPED_REPLACEMENT|g" "index.html"
|
||||
fi
|
||||
|
||||
@@ -62,7 +62,7 @@ export default defineConfig(({ mode }) => {
|
||||
experimental: {
|
||||
// Only apply CDN URL to files in /assets/* directory
|
||||
renderBuiltUrl(filename) {
|
||||
if (filename.startsWith("assets/")) {
|
||||
if (filename.startsWith("assets/") && cdnUrl) {
|
||||
return `${cdnUrl}/${filename}`;
|
||||
}
|
||||
return `/${filename}`;
|
||||
|
||||
Reference in New Issue
Block a user