Closed
Conversation
MickLesk
requested changes
Jan 12, 2026
Member
MickLesk
left a comment
There was a problem hiding this comment.
It incorrectly allows:
- test..example (double dots)
- test.-example (dot + hyphen)
- test. (trailing dot)
Only 1 label, max 63 characters total (not RFC-compliant)
Hostname: max. 63 characters, no dots
FQDN: Multiple labels with dots, each label max. 63 characters, total max. 253 characters
Author
|
Should the check be fully FQDN compliant and allow capital letters as well? |
Member
|
should be like this: # ...existing code...
if result=$(whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
--title "HOSTNAME" \
--ok-button "Next" --cancel-button "Back" \
--inputbox "\nSet Hostname (or FQDN, e.g. host.example.com)" 10 58 "$_hostname" \
3>&1 1>&2 2>&3); then
local hn_test="${result:-$NSAPP}"
hn_test=$(echo "${hn_test,,}" | tr -d ' ')
# Validate hostname/FQDN according to RFC 1123/952
local valid=true
# Check total length (max 253 for FQDN)
if [[ ${#hn_test} -gt 253 ]]; then
valid=false
fi
# Split by dots and validate each label
if $valid; then
IFS='.' read -ra labels <<< "$hn_test"
for label in "${labels[@]}"; do
# Each label: 1-63 chars, alphanumeric, hyphens allowed (not at start/end)
if [[ -z "$label" ]] || [[ ${#label} -gt 63 ]]; then
valid=false
break
fi
if [[ ! "$label" =~ ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$ ]] && [[ ! "$label" =~ ^[a-z0-9]$ ]]; then
valid=false
break
fi
done
fi
if $valid; then
_hostname="$hn_test"
((STEP++))
else
whiptail --msgbox "Invalid hostname: '$hn_test'\n\nRules:\n- Only lowercase letters, digits, dots and hyphens\n- Labels separated by dots (max 63 chars each)\n- No leading/trailing hyphens or dots\n- No consecutive dots\n- Total max 253 characters" 14 60
fi
# ...existing code...its a little bit more then 2-4 changed lines |
MickLesk
added a commit
that referenced
this pull request
Jan 19, 2026
- Add validate_hostname() function for centralized validation - Validate var_hostname from environment/vars files with fallback - Allow FQDN hostnames (e.g. host.example.com) in Advanced Settings - Enforce max 253 chars total, max 63 chars per label - Prevent double dots, leading/trailing hyphens and dots Implements requested changes from PR #10621
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✍️ Description
🔗 Related Issue
Fixes #
✅ Prerequisites (X in brackets)
🛠️ Type of Change (X in brackets)
README,AppName.md,CONTRIBUTING.md, or other docs.