mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 12:40:56 +00:00
Improve scheme matching to avoid inadvertent blocking
Signed-off-by: Riley Avron <riley.avron@gmail.com>
This commit is contained in:
parent
512ec7fb87
commit
f390671018
10
gravity.sh
10
gravity.sh
@ -346,12 +346,16 @@ gravity_ParseFileIntoDomains() {
|
|||||||
echo -ne " ${INFO} Format: URL"
|
echo -ne " ${INFO} Format: URL"
|
||||||
|
|
||||||
awk '
|
awk '
|
||||||
# Remove URL protocol, optional "username:password@", and ":?/;"
|
# Remove URL scheme, optional "username:password@", and ":?/;"
|
||||||
/[:?\/;]/ { gsub(/(^.*:\/\/(.*:.*@)?|[:?\/;].*)/, "", $0) }
|
# The scheme must be matched carefully to avoid blocking the wrong URL
|
||||||
|
# in cases like:
|
||||||
|
# http://www.evil.com?http://www.good.com
|
||||||
|
# See RFC 3986 section 3.1 for details.
|
||||||
|
/[:?\/;]/ { gsub(/(^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/(.*:.*@)?|[:?\/;].*)/, "", $0) }
|
||||||
# Skip lines which are only IPv4 addresses
|
# Skip lines which are only IPv4 addresses
|
||||||
/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ { next }
|
/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ { next }
|
||||||
# Print if nonempty
|
# Print if nonempty
|
||||||
length { print $0 }
|
length { print }
|
||||||
' "${source}" 2> /dev/null > "${destination}"
|
' "${source}" 2> /dev/null > "${destination}"
|
||||||
|
|
||||||
echo -e "${OVER} ${TICK} Format: URL"
|
echo -e "${OVER} ${TICK} Format: URL"
|
||||||
|
Loading…
Reference in New Issue
Block a user