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.
This commit is contained in:
+4
-4
@@ -428,9 +428,9 @@ build_wordpress_section() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to get actual domain from WP database options (more reliable)
|
# 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_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 "'[^']+'" | 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 "'[^']+'" | 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
|
# 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)
|
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
|
# Get WP version
|
||||||
local version=""
|
local version=""
|
||||||
if [ -f "${wp_dir}/wp-includes/version.php" ]; then
|
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
|
fi
|
||||||
|
|
||||||
# Count plugins
|
# Count plugins
|
||||||
|
|||||||
Reference in New Issue
Block a user