Skip to content

Commit bf0b3fc

Browse files
CopilotPDowney
andcommitted
fix(admin-control-panel): add Font Awesome validation, Adminer exit code, and nested div sanity check
Co-authored-by: PDowney <[email protected]> Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/0b35e578-5a1b-4f42-a916-84affdddafdf
1 parent c002944 commit bf0b3fc

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to EngineScript will be documented in this file.
44

55
Changes are organized by date, with the most recent changes listed first.
66

7+
## 2026-03-24
8+
9+
### 🔧 ADMIN CONTROL PANEL INSTALL SCRIPT ROBUSTNESS FIXES
10+
11+
- **Added Font Awesome substitution validation** in `scripts/install/tools/frontend/admin-control-panel-install.sh`. After the `sed` substitution, a `grep` check verifies the `{FONTAWESOME_VER}` placeholder is no longer present in `index.html`; if it is, the script exits with an error to prevent silent failures when the CDN URL format changes.
12+
- **Added `exit 1`** when the expected Adminer tool `<div>` is not found in `index.html` during Adminer card removal (`INSTALL_ADMINER=0`), so automated installations surface the failure instead of silently continuing.
13+
- **Added nested `<div>` sanity check** before deleting the Adminer card block. The block is extracted first and its opening/closing `<div>` counts are compared; if they are not both exactly 1, removal is skipped with a warning to avoid corrupting the HTML structure.
14+
715
## 2026-03-20 (2)
816

917
### 🔧 UPTIMECONTROLLER CODE QUALITY FIXES

scripts/install/tools/frontend/admin-control-panel-install.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ cp -a /usr/local/bin/enginescript/config/var/www/admin/control-panel/. /var/www/
3333
# the specific Font Awesome CDN URL that contains the version segment. If the
3434
# Font Awesome CDN path changes, update the pattern below accordingly.
3535
sed -i 's|\(cdnjs\.cloudflare\.com/ajax/libs/font-awesome/\){FONTAWESOME_VER}\(/css/all\.min\.css\)|\1'"${FONTAWESOME_VER}"'\2|g' /var/www/admin/control-panel/index.html
36+
37+
# Verify that the Font Awesome placeholder was successfully replaced to avoid silent failures
38+
if grep -q '{FONTAWESOME_VER}' /var/www/admin/control-panel/index.html; then
39+
echo "Error: Failed to substitute Font Awesome version in index.html; placeholder {FONTAWESOME_VER} still present." >&2
40+
exit 1
41+
fi
42+
3643
for file in index.html dashboard.js external-services/external-services.js; do
3744
sed -i "s|{ES_DASHBOARD_VER}|${ES_DASHBOARD_VER}|g" "/var/www/admin/control-panel/${file}"
3845
done
@@ -47,9 +54,21 @@ if [[ "${INSTALL_ADMINER}" -eq 0 ]]; then
4754
# To avoid corrupting the page if the structure has changed, first ensure that the expected
4855
# single-line opening <div> for the Adminer card is present before applying the sed range.
4956
if grep -qE '<div[^>]*id="adminer-tool"[^>]*>' "/var/www/admin/control-panel/index.html"; then
50-
sed -i '/<div[^>]*id="adminer-tool"[^>]*>/,/<\/div>/d' "/var/www/admin/control-panel/index.html"
57+
# Extract the block that would be deleted, then perform a simple sanity check
58+
# to ensure there are no nested <div> elements that would cause a partial removal.
59+
adminer_block="$(
60+
sed -n '/<div[^>]*id="adminer-tool"[^>]*>/,/<\/div>/p' "/var/www/admin/control-panel/index.html"
61+
)"
62+
open_div_count=$(printf '%s\n' "$adminer_block" | grep -o '<div' | wc -l | tr -d '[:space:]')
63+
close_div_count=$(printf '%s\n' "$adminer_block" | grep -o '</div>' | wc -l | tr -d '[:space:]')
64+
if [[ "$open_div_count" -eq 1 && "$close_div_count" -eq 1 ]]; then
65+
sed -i '/<div[^>]*id="adminer-tool"[^>]*>/,/<\/div>/d' "/var/www/admin/control-panel/index.html"
66+
else
67+
echo "Warning: Adminer tool block appears to contain nested <div> elements; skipping Adminer card removal to avoid corrupting index.html." >&2
68+
fi
5169
else
5270
echo "Warning: Expected Adminer tool div not found in index.html; skipping Adminer card removal." >&2
71+
exit 1
5372
fi
5473
fi
5574

0 commit comments

Comments
 (0)