Filter ABP CSS selectors (#5247)

pull/5270/head
yubiuser 1 year ago committed by GitHub
commit cd638b102f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -762,25 +762,21 @@ gravity_ParseFileIntoDomains() {
tr '[:upper:]' '[:lower:]' < "${src}" > "${destination}" tr '[:upper:]' '[:lower:]' < "${src}" > "${destination}"
# 2) Remove carriage returns # 2) Remove carriage returns
sed -i 's/\r$//' "${destination}" # 3) Remove lines starting with ! (ABP Comments)
# 4) Remove lines starting with [ (ABP Header)
# 3a) Remove comments (text starting with "#", include possible spaces before the hash sign) # 5) Remove lines containing ABP extended CSS selectors ("##", "#!#", "#@#", "#?#") preceded by a letter
sed -i 's/\s*#.*//g' "${destination}" # 6) Remove comments (text starting with "#", include possible spaces before the hash sign)
# 7) Remove leading tabs, spaces, etc. (Also removes leading IP addresses)
# 3b) Remove lines starting with ! (ABP Comments) # 8) Remove empty lines
sed -i 's/\s*!.*//g' "${destination}"
sed -i -r \
# 3c) Remove lines starting with [ (ABP Header) -e 's/\r$//' \
sed -i 's/\s*\[.*//g' "${destination}" -e 's/\s*!.*//g' \
-e 's/\s*\[.*//g' \
# 4) Remove lines containing "/" -e '/[a-z]\#[$?@]{0,1}\#/d' \
sed -i -r '/(\/).*$/d' "${destination}" -e 's/\s*#.*//g' \
-e 's/^.*\s+//g' \
# 5) Remove leading tabs, spaces, etc. (Also removes leading IP addresses) -e '/^$/d' "${destination}"
sed -i -r 's/^.*\s+//g' "${destination}"
# 6) Remove empty lines
sed -i '/^$/d' "${destination}"
chmod 644 "${destination}" chmod 644 "${destination}"
} }

Loading…
Cancel
Save