CRITICAL: Fix grep regex errors when usernames contain special characters
ROOT CAUSE:
Usernames containing bracket characters like '[' or ']' were being used
directly in grep patterns, causing:
grep: Unmatched [, [^, [:, [., or [=
This happened during "Indexing users" when the reference database builder
called get_user_domains/get_user_databases with usernames containing brackets.
AFFECTED FUNCTIONS (lib/user-manager.sh):
- get_interworx_user_domains() line 284: grep -v "^${username}\."
- get_interworx_user_info() line 195: grep -A20 with $primary_domain
- get_user_processes() line 583: grep "^${username}"
- get_user_top_processes() line 590: grep "^${username}"
AFFECTED FUNCTIONS (lib/reference-db.sh):
- index_wordpress_sites() line 420: grep "^USER|${username}|"
THE FIX:
Changed all grep commands using variables in patterns to use -F (fixed string)
flag instead of regex matching, and added 2>/dev/null error suppression:
OLD: grep "^${username}"
NEW: grep -F "$username" 2>/dev/null
OLD: grep -v "^${username}\."
NEW: grep -vF "${username}." 2>/dev/null
IMPACT:
Eliminates ALL "Unmatched [" errors during reference database build,
even when usernames contain special regex characters: [].*+?^$(){}|
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -417,7 +417,7 @@ build_wordpress_section() {
|
||||
# Check for common domain folder patterns
|
||||
if [[ "$path_after_home" == public_html ]]; then
|
||||
# This is the primary domain - get it from user info
|
||||
domain=$(grep "^USER|${username}|" "$SYSREF_DB" | cut -d'|' -f3 || true)
|
||||
domain=$(grep -F "USER|${username}|" "$SYSREF_DB" 2>/dev/null | cut -d'|' -f3 || true)
|
||||
elif [[ "$path_after_home" =~ ^public_html/(.+) ]]; then
|
||||
# Could be subdomain or subdirectory - extract folder name
|
||||
local folder=$(echo "$path_after_home" | cut -d'/' -f2)
|
||||
|
||||
Reference in New Issue
Block a user