You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

  1. #!/bin/sh
  2. URL="https://publicsuffix.org/list/public_suffix_list.dat"
  3. TMPFILE=$(dirname $0)/public_suffix_list.tmp
  4. DATFILE=$(dirname $0)/public_suffix_list.dat
  5. wget -O $TMPFILE $URL || exit 1
  6. # there might be backslashes (at line end they produce problems)
  7. sed -i 's/\\//g' $TMPFILE
  8. # clear DATFILE if exist
  9. printf %s "" > $DATFILE
  10. L=0; M=0
  11. export CHARSET=UTF-8 # needed for idn
  12. cat ${TMPFILE} | while read LINE; do
  13. L=$(( L + 1 ))
  14. printf "\\r\\t%s\\t%s" "in: $L " "out: $(( $L + $M )) "
  15. printf %s\\n "$LINE" | grep -E "^\/\/" >/dev/null 2>&1 && {
  16. # do not modify lines beginning with "//"
  17. printf %s\\n "$LINE" >> $DATFILE
  18. continue
  19. }
  20. printf %s\\n "$LINE" | grep -E "^$" >/dev/null 2>&1 && {
  21. # do not modify empty lines
  22. printf %s\\n "$LINE" >> $DATFILE
  23. continue
  24. }
  25. ASCII=$(idn -a "$LINE") # write ASCII and UTF-8
  26. if [ "$ASCII" != "$LINE" ]; then
  27. printf %s\\n "$ASCII" >> $DATFILE
  28. printf "\\t%s\\n" "add: $ASCII"
  29. M=$(( M + 1 ))
  30. fi
  31. printf %s\\n "$LINE" >> $DATFILE
  32. done
  33. rm -f $TMPFILE
  34. gzip -f9 $DATFILE