Skip to content

Add Docker TAGLINE env customization for modern frontend slogan#794

Merged
sstidl merged 4 commits into
masterfrom
copilot/feature-customize-docker-image
Apr 18, 2026
Merged

Add Docker TAGLINE env customization for modern frontend slogan#794
sstidl merged 4 commits into
masterfrom
copilot/feature-customize-docker-image

Conversation

Copilot AI commented Apr 18, 2026

Copy link
Copy Markdown
Contributor
  • Fix docker/entrypoint.sh: switch TAGLINE sed delimiter from # to / (apostrophe → ' contains #, breaking the #-delimited sed)
  • Add standalone-apostrophe service in tests/docker-compose-playwright.yml with TAGLINE="It'd rather be fast!"
  • Add standaloneApostrophe URL (port 18186) to tests/e2e/helpers/env.js
  • Add E2E test verifying the apostrophe tagline renders correctly in title-special-chars.spec.js

Copilot AI linked an issue Apr 18, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add customizable slogan and logo for Docker image Add Docker TAGLINE env customization for modern frontend slogan Apr 18, 2026
Copilot AI requested a review from sstidl April 18, 2026 20:08
@sstidl sstidl marked this pull request as ready for review April 18, 2026 20:32
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add Docker TAGLINE env customization for modern UI slogan

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add Docker TAGLINE environment variable for modern UI customization
• Implement tagline templating in entrypoint with HTML/sed escaping
• Set default tagline in both Dockerfile and Dockerfile.alpine
• Extend E2E tests to verify custom and default tagline rendering
• Update Docker documentation with TAGLINE variable and compose example
Diagram
flowchart LR
  A["Docker entrypoint.sh"] -->|"Process TAGLINE env"| B["HTML escape & sed escape"]
  B -->|"Replace in index-modern.html"| C["Modern UI with custom tagline"]
  D["Dockerfile/Dockerfile.alpine"] -->|"Set default TAGLINE"| E["Environment variables"]
  E -->|"Pass to container"| C
  F["E2E tests"] -->|"Verify tagline rendering"| C
  G["doc_docker.md"] -->|"Document TAGLINE"| H["Docker documentation"]
Loading

Grey Divider

File Changes

1. docker/entrypoint.sh ✨ Enhancement +9/-0

Add TAGLINE templating with escaping logic

• Added TAGLINE environment variable processing block after TITLE handling
• Normalize multiline tagline input to single line (remove carriage returns and newlines)
• HTML-escape the tagline content for safe rendering
• Sed-escape the tagline for safe regex replacement
• Replace default tagline in index-modern.html with custom value using sed

docker/entrypoint.sh


2. Dockerfile ⚙️ Configuration changes +1/-0

Set default TAGLINE environment variable

• Added ENV TAGLINE with default value matching original hardcoded tagline
• Placed after TITLE environment variable for consistency

Dockerfile


3. Dockerfile.alpine ⚙️ Configuration changes +1/-0

Set default TAGLINE environment variable

• Added ENV TAGLINE with default value matching original hardcoded tagline
• Placed after TITLE environment variable for consistency

Dockerfile.alpine


View more (4)
4. doc_docker.md 📝 Documentation +2/-0

Document TAGLINE environment variable

• Added TAGLINE to docker-compose example with commented default value
• Documented TAGLINE environment variable in the list with description and default
• Clarified that tagline appears on modern frontend (index-modern.html)

doc_docker.md


5. tests/e2e/modes.spec.js 🧪 Tests +3/-0

Add default tagline E2E assertion

• Added defaultTagline constant with original hardcoded tagline value
• Added assertion to verify default tagline renders in modern UI when TAGLINE is unset
• Targets main > p.tagline selector for verification

tests/e2e/modes.spec.js


6. tests/e2e/title-special-chars.spec.js 🧪 Tests +3/-1

Add special character tagline E2E test

• Added specialTagline constant with special characters (quotes, angle brackets, ampersand)
• Updated test description to include TAGLINE coverage
• Added assertion to verify custom tagline with special characters renders correctly
• Targets main > p.tagline selector for verification

tests/e2e/title-special-chars.spec.js


7. tests/docker-compose-playwright.yml ⚙️ Configuration changes +1/-0

Add custom TAGLINE to test compose stack

• Added TAGLINE environment variable to standalone-new service with special characters
• Tagline includes quotes, angle brackets, and ampersand for comprehensive escaping validation

tests/docker-compose-playwright.yml


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Sed breaks on apostrophes 🐞 Bug ☼ Reliability
Description
docker/entrypoint.sh replaces the modern tagline using a sed expression delimited by #, but
the replacement text is not escaped for #. Since html_escape converts ' into ' (contains
#), setting TAGLINE with an apostrophe will make sed fail and (due to set -e) prevent the
container from starting.
Code

docker/entrypoint.sh[R113-118]

+  if [ -n "$TAGLINE" ]; then
+    TAGLINE_ONE_LINE=${TAGLINE//$'\r'/}
+    TAGLINE_ONE_LINE=${TAGLINE_ONE_LINE//$'\n'/ }
+    TAGLINE_HTML_ESCAPED=$(html_escape "$TAGLINE_ONE_LINE")
+    TAGLINE_ESCAPED=$(sed_escape "$TAGLINE_HTML_ESCAPED")
+    sed -i "s#<p class=\"tagline\">No Flash, No Java, No Websockets, No Bullsh\\*t<\\/p>#<p class=\"tagline\">$TAGLINE_ESCAPED<\\/p>#g" /var/www/html/index-modern.html
Evidence
The sed command uses # as its delimiter for the TAGLINE replacement, but sed_escape() only
escapes &, /, \, and $, not #. Additionally, html_escape() turns single quotes into the
numeric entity &#39;, which introduces a literal # into the replacement string, breaking the
s#...#...# sed command and causing the entrypoint to exit because set -e is enabled.

docker/entrypoint.sh[13-13]
docker/entrypoint.sh[20-27]
docker/entrypoint.sh[29-31]
docker/entrypoint.sh[112-119]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The TAGLINE sed replacement uses `#` as the delimiter, but the escaping helper `sed_escape()` does not escape `#`. After `html_escape()`, any apostrophe becomes `&#39;` which contains `#`, breaking the sed expression and aborting the entrypoint due to `set -e`.

## Issue Context
This impacts runtime container startup whenever a user sets `TAGLINE` containing `'` (a common character), because the entrypoint script exits on sed errors.

## Fix Focus Areas
- docker/entrypoint.sh[20-31]
- docker/entrypoint.sh[112-119]

## Suggested fix
Pick one:
1) **Escape `#` in `sed_escape()`** (safe for existing callers): extend the character class to include `#` (and keep existing escapes).
2) **Switch TAGLINE sed back to `/` delimiter** (since `sed_escape()` already escapes `/`), avoiding the need for `#` escaping.

After implementing, add/adjust an E2E case where TAGLINE includes an apostrophe (e.g., `Don't`) to prevent regression.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment thread docker/entrypoint.sh Outdated
- Switch TAGLINE sed from '#' to '/' delimiter so html_escape'd
  apostrophes (&#39;) don't break the sed expression
- Add standalone-apostrophe Docker service with TAGLINE="It'd rather be fast!"
- Add standaloneApostrophe URL (port 18186) to env.js
- Add E2E test asserting the apostrophe tagline renders correctly

Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/ebe265a8-4b1e-49b5-959a-66133ea0ab3a

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
@sstidl sstidl merged commit ecb2a0e into master Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: More Docker image customization

2 participants