Merge pull request #2597 from xCh12i5/RegEx-Fix

Solves RegEx issue.
This commit is contained in:
DL6ER 2019-04-25 15:27:35 +02:00 committed by GitHub
commit 6a01a1257f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -335,14 +335,16 @@ gravity_ParseFileIntoDomains() {
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious # Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
# This helps with that and makes it easier to read # This helps with that and makes it easier to read
# It also helps with debugging so each stage of the script can be researched more in depth # It also helps with debugging so each stage of the script can be researched more in depth
# Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only. # 1) Remove carriage returns
# Last awk command takes non-commented lines and if they have 2 fields, take the right field (the domain) and leave # 2) Convert all characters to lowercase
# the left (IP address), otherwise grab the single field. # 3) Remove lines containing "#" or "/"
# 4) Remove leading tabs, spaces, etc.
< ${source} awk -F '#' '{print $1}' | \ # 5) Delete lines not matching domain names
awk -F '/' '{print $1}' | \ < "${source}" tr -d '\r' | \
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | \ tr '[:upper:]' '[:lower:]' | \
sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${destination} sed -r '/(\/|#).*$/d' | \
sed -r 's/^.*\s+//g' | \
sed -r '/([^\.]+\.)+[^\.]{2,}/!d' > "${destination}"
return 0 return 0
fi fi