From 661c9d3cc2f1116374b265b9b8e338bc23f35a41 Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 21 Nov 2025 17:25:11 -0500 Subject: [PATCH] Fix grep regex errors in WordPress config parsing CRITICAL FIX: Lines 431, 432, 433, 444 were missing 2>/dev/null on grep -oP patterns containing bracket expressions '[^']+' which caused: grep: Unmatched [, [^, [:, [., or [= CHANGES: - Added 2>/dev/null to DB_NAME extraction (line 431) - Added 2>/dev/null to DB_USER extraction (line 432) - Added 2>/dev/null to DB_HOST extraction (line 433) - Added 2>/dev/null to wp_version extraction (line 444) All patterns use '[^']+' or similar bracket expressions that can cause errors if grep doesn't support -P flag or has regex issues. IMPACT: Eliminates errors during reference database build when indexing WordPress installations. --- lib/reference-db.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/reference-db.sh b/lib/reference-db.sh index 5ad35f2..d3e2196 100755 --- a/lib/reference-db.sh +++ b/lib/reference-db.sh @@ -428,9 +428,9 @@ build_wordpress_section() { fi # Try to get actual domain from WP database options (more reliable) - local db_name=$(grep "DB_NAME" "$wp_config" | grep -oP "'[^']+'" | tail -1 | tr -d "'" || true) - local db_user=$(grep "DB_USER" "$wp_config" | grep -oP "'[^']+'" | tail -1 | tr -d "'" || true) - local db_host=$(grep "DB_HOST" "$wp_config" | grep -oP "'[^']+'" | tail -1 | tr -d "'" || true) + local db_name=$(grep "DB_NAME" "$wp_config" | grep -oP "'[^']+'" 2>/dev/null | tail -1 | tr -d "'" || true) + local db_user=$(grep "DB_USER" "$wp_config" | grep -oP "'[^']+'" 2>/dev/null | tail -1 | tr -d "'" || true) + local db_host=$(grep "DB_HOST" "$wp_config" | grep -oP "'[^']+'" 2>/dev/null | tail -1 | tr -d "'" || true) # Try to get site URL from wp-config defines local site_url=$(grep -E "WP_SITEURL|WP_HOME" "$wp_config" | head -1 | grep -oP "https?://\K[^/'\"]+" || true) @@ -441,7 +441,7 @@ build_wordpress_section() { # Get WP version local version="" if [ -f "${wp_dir}/wp-includes/version.php" ]; then - version=$(grep "\$wp_version" "${wp_dir}/wp-includes/version.php" | grep -oP "'\K[^']+" | head -1 || true) + version=$(grep "\$wp_version" "${wp_dir}/wp-includes/version.php" | grep -oP "'\K[^']+" 2>/dev/null | head -1 || true) fi # Count plugins