pax_global_header00006660000000000000000000000064126005201640014506gustar00rootroot0000000000000052 comment=d1dec3d16ee5c2254962fe60834b54805e772526 libpsl-libpsl-0.11.0/000077500000000000000000000000001260052016400143355ustar00rootroot00000000000000libpsl-libpsl-0.11.0/.dir-locals.el000066400000000000000000000003221260052016400167630ustar00rootroot00000000000000;; emacs local configuration settings for libpsl source ;; surmised by dkg on 2014-03-21 14:35:49-0400 ((c-mode (indent-tabs-mode . t) (tab-width . 4) (c-basic-offset . 4) (c-file-style . "linux")) ) libpsl-libpsl-0.11.0/.gitignore000066400000000000000000000023241260052016400163260ustar00rootroot00000000000000*.gz *.o *.lo *.la *.exe *~ */.deps */.libs *.cache *.plist *.stamp aclocal.m4 ar-lib autom4te.cache/ compile config.guess config.h config.h.in config.log config.rpath config.status config.sub configure data depcomp docs/libpsl/html/ docs/libpsl/libpsl-decl-list.txt docs/libpsl/libpsl-decl.txt docs/libpsl/libpsl-overrides.txt docs/libpsl/libpsl-undeclared.txt docs/libpsl/libpsl-undocumented.txt docs/libpsl/libpsl-unused.txt docs/libpsl/libpsl.3 docs/libpsl/libpsl.args docs/libpsl/libpsl.hierarchy docs/libpsl/libpsl.interfaces docs/libpsl/libpsl.prerequisites docs/libpsl/libpsl.signals docs/libpsl/version.xml docs/libpsl/xml/ gtk-doc.m4 gtk-doc.make include/libpsl.h install-sh libpsl.pc libtool ltmain.sh m4/ Makefile Makefile.in missing nbproject/ po/Makefile.in.in po/Makevars.template po/POTFILES po/Rules-quot po/boldquot.sed po/en@boldquot.header po/en@quot.header po/insert-header.sin po/psl.pot po/libpsl.pot po/quot.sed po/remove-potcdate.sin po/remove-potcdate.sed po/stamp-po src/psl2c src/suffixes.c stamp-h1 test-driver tests/*.log tests/*.trs tests/test-is-cookie-domain-acceptable tests/test-is-public tests/test-is-public-all tests/test-is-public-builtin tests/test-is-tld tests/test-registrable-domain tools/psl libpsl-libpsl-0.11.0/.gitmodules000066400000000000000000000001141260052016400165060ustar00rootroot00000000000000[submodule "list"] path = list url = https://github.com/publicsuffix/list libpsl-libpsl-0.11.0/.travis.yml000066400000000000000000000041301260052016400164440ustar00rootroot00000000000000language: c compiler: - gcc - clang # Change this to your needs script: - ./autogen.sh - ./configure && make -j4 && make check -j4 - ./configure --enable-runtime=libicu --enable-builtin=libicu && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libicu --enable-builtin=libidn2 && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libicu --enable-builtin=libidn && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libicu --disable-builtin && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn2 --enable-builtin=libicu && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn2 --enable-builtin=libidn2 && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn2 --enable-builtin=libidn && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn2 --disable-builtin && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn --enable-builtin=libicu && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn --enable-builtin=libidn2 && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn --enable-builtin=libidn && make clean && make -j4 && make check -j4 - ./configure --enable-runtime=libidn --disable-builtin && make clean && make -j4 && make check -j4 - ./configure --disable-runtime --enable-builtin=libicu && make clean && make -j4 && make check -j4 - ./configure --disable-runtime --enable-builtin=libidn2 && make clean && make -j4 && make check -j4 - ./configure --disable-runtime --enable-builtin=libidn && make clean && make -j4 && make check -j4 - ./configure --disable-runtime --disable-builtin && make clean && make -j4 && make check -j4 - ./configure --enable-gtk-doc && make -j4 && make check -j4 - make distcheck before_install: - sudo apt-get -qq update - sudo apt-get -q install autoconf automake autopoint libtool gtk-doc-tools gettext libidn11 libidn11-dev libidn2-0 libidn2-0-dev libicu48 libicu-dev libunistring0 libunistring-dev libpsl-libpsl-0.11.0/ABOUT-NLS000066400000000000000000002671331260052016400156000ustar00rootroot000000000000001 Notes on the Free Translation Project *************************************** Free software is going international! The Free Translation Project is a way to get maintainers of free software, translators, and users all together, so that free software will gradually become able to speak many languages. A few packages already provide translations for their messages. If you found this `ABOUT-NLS' file inside a distribution, you may assume that the distributed package does use GNU `gettext' internally, itself available at your nearest GNU archive site. But you do _not_ need to install GNU `gettext' prior to configuring, installing or using this package with messages translated. Installers will find here some useful hints. These notes also explain how users should proceed for getting the programs to use the available translations. They tell how people wanting to contribute and work on translations can contact the appropriate team. 1.1 INSTALL Matters =================== Some packages are "localizable" when properly installed; the programs they contain can be made to speak your own native language. Most such packages use GNU `gettext'. Other packages have their own ways to internationalization, predating GNU `gettext'. By default, this package will be installed to allow translation of messages. It will automatically detect whether the system already provides the GNU `gettext' functions. Installers may use special options at configuration time for changing the default behaviour. The command: ./configure --disable-nls will _totally_ disable translation of messages. When you already have GNU `gettext' installed on your system and run configure without an option for your new package, `configure' will probably detect the previously built and installed `libintl' library and will decide to use it. If not, you may have to to use the `--with-libintl-prefix' option to tell `configure' where to look for it. Internationalized packages usually have many `po/LL.po' files, where LL gives an ISO 639 two-letter code identifying the language. Unless translations have been forbidden at `configure' time by using the `--disable-nls' switch, all available translations are installed together with the package. However, the environment variable `LINGUAS' may be set, prior to configuration, to limit the installed set. `LINGUAS' should then contain a space separated list of two-letter codes, stating which languages are allowed. 1.2 Using This Package ====================== As a user, if your language has been installed for this package, you only have to set the `LANG' environment variable to the appropriate `LL_CC' combination. If you happen to have the `LC_ALL' or some other `LC_xxx' environment variables set, you should unset them before setting `LANG', otherwise the setting of `LANG' will not have the desired effect. Here `LL' is an ISO 639 two-letter language code, and `CC' is an ISO 3166 two-letter country code. For example, let's suppose that you speak German and live in Germany. At the shell prompt, merely execute `setenv LANG de_DE' (in `csh'), `export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). This can be done from your `.login' or `.profile' file, once and for all. You might think that the country code specification is redundant. But in fact, some languages have dialects in different countries. For example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The country code serves to distinguish the dialects. The locale naming convention of `LL_CC', with `LL' denoting the language and `CC' denoting the country, is the one use on systems based on GNU libc. On other systems, some variations of this scheme are used, such as `LL' or `LL_CC.ENCODING'. You can get the list of locales supported by your system for your language by running the command `locale -a | grep '^LL''. Not all programs have translations for all languages. By default, an English message is shown in place of a nonexistent translation. If you understand other languages, you can set up a priority list of languages. This is done through a different environment variable, called `LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' for the purpose of message handling, but you still need to have `LANG' set to the primary language; this is required by other parts of the system libraries. For example, some Swedish users who would rather read translations in German than English for when Swedish is not available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. Special advice for Norwegian users: The language code for Norwegian bokma*l changed from `no' to `nb' recently (in 2003). During the transition period, while some message catalogs for this language are installed under `nb' and some older ones under `no', it's recommended for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and older translations are used. In the `LANGUAGE' environment variable, but not in the `LANG' environment variable, `LL_CC' combinations can be abbreviated as `LL' to denote the language's main dialect. For example, `de' is equivalent to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' (Portuguese as spoken in Portugal) in this context. 1.3 Translating Teams ===================== For the Free Translation Project to be a success, we need interested people who like their own language and write it well, and who are also able to synergize with other translators speaking the same language. Each translation team has its own mailing list. The up-to-date list of teams can be found at the Free Translation Project's homepage, `http://translationproject.org/', in the "Teams" area. If you'd like to volunteer to _work_ at translating messages, you should become a member of the translating team for your own language. The subscribing address is _not_ the same as the list itself, it has `-request' appended. For example, speakers of Swedish can send a message to `sv-request@li.org', having this message body: subscribe Keep in mind that team members are expected to participate _actively_ in translations, or at solving translational difficulties, rather than merely lurking around. If your team does not exist yet and you want to start one, or if you are unsure about what to do or how to get started, please write to `coordinator@translationproject.org' to reach the coordinator for all translator teams. The English team is special. It works at improving and uniformizing the terminology in use. Proven linguistic skills are praised more than programming skills, here. 1.4 Available Packages ====================== Languages are not equally supported in all packages. The following matrix shows the current state of internationalization, as of June 2010. The matrix shows, in regard of each package, for which languages PO files have been submitted to translation coordination, with a translation percentage of at least 50%. Ready PO files af am an ar as ast az be be@latin bg bn_IN bs ca +--------------------------------------------------+ a2ps | [] [] | aegis | | ant-phone | | anubis | | aspell | [] [] | bash | | bfd | | bibshelf | [] | binutils | | bison | | bison-runtime | [] | bluez-pin | [] [] | bombono-dvd | | buzztard | | cflow | | clisp | | coreutils | [] [] | cpio | | cppi | | cpplib | [] | cryptsetup | | dfarc | | dialog | [] [] | dico | | diffutils | [] | dink | | doodle | | e2fsprogs | [] | enscript | [] | exif | | fetchmail | [] | findutils | [] | flex | [] | freedink | | gas | | gawk | [] [] | gcal | [] | gcc | | gettext-examples | [] [] [] [] | gettext-runtime | [] [] | gettext-tools | [] [] | gip | [] | gjay | | gliv | [] | glunarclock | [] [] | gnubiff | | gnucash | [] | gnuedu | | gnulib | | gnunet | | gnunet-gtk | | gnutls | | gold | | gpe-aerial | | gpe-beam | | gpe-bluetooth | | gpe-calendar | | gpe-clock | [] | gpe-conf | | gpe-contacts | | gpe-edit | | gpe-filemanager | | gpe-go | | gpe-login | | gpe-ownerinfo | [] | gpe-package | | gpe-sketchbook | | gpe-su | [] | gpe-taskmanager | [] | gpe-timesheet | [] | gpe-today | [] | gpe-todo | | gphoto2 | | gprof | [] | gpsdrive | | gramadoir | | grep | | grub | [] [] | gsasl | | gss | | gst-plugins-bad | [] | gst-plugins-base | [] | gst-plugins-good | [] | gst-plugins-ugly | [] | gstreamer | [] [] [] | gtick | | gtkam | [] | gtkorphan | [] | gtkspell | [] [] [] | gutenprint | | hello | [] | help2man | | hylafax | | idutils | | indent | [] [] | iso_15924 | | iso_3166 | [] [] [] [] [] [] [] | iso_3166_2 | | iso_4217 | | iso_639 | [] [] [] [] | iso_639_3 | | jwhois | | kbd | | keytouch | [] | keytouch-editor | | keytouch-keyboa... | [] | klavaro | [] | latrine | | ld | [] | leafpad | [] [] | libc | [] [] | libexif | () | libextractor | | libgnutls | | libgpewidget | | libgpg-error | | libgphoto2 | | libgphoto2_port | | libgsasl | | libiconv | [] | libidn | | lifelines | | liferea | [] [] | lilypond | | linkdr | [] | lordsawar | | lprng | | lynx | [] | m4 | | mailfromd | | mailutils | | make | | man-db | | man-db-manpages | | minicom | | mkisofs | | myserver | | nano | [] [] | opcodes | | parted | | pies | | popt | | psmisc | | pspp | [] | pwdutils | | radius | [] | recode | [] [] | rosegarden | | rpm | | rush | | sarg | | screem | | scrollkeeper | [] [] [] | sed | [] [] | sharutils | [] [] | shishi | | skencil | | solfege | | solfege-manual | | soundtracker | | sp | | sysstat | | tar | [] | texinfo | | tin | | unicode-han-tra... | | unicode-transla... | | util-linux-ng | [] | vice | | vmm | | vorbis-tools | | wastesedge | | wdiff | | wget | [] [] | wyslij-po | | xchat | [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] | +--------------------------------------------------+ af am an ar as ast az be be@latin bg bn_IN bs ca 6 0 1 2 3 19 1 10 3 28 3 1 38 crh cs da de el en en_GB en_ZA eo es et eu fa +-------------------------------------------------+ a2ps | [] [] [] [] [] [] [] | aegis | [] [] [] | ant-phone | [] () | anubis | [] [] | aspell | [] [] [] [] [] | bash | [] [] [] | bfd | [] | bibshelf | [] [] [] | binutils | [] | bison | [] [] | bison-runtime | [] [] [] [] | bluez-pin | [] [] [] [] [] [] | bombono-dvd | [] | buzztard | [] [] [] | cflow | [] [] | clisp | [] [] [] [] | coreutils | [] [] [] [] | cpio | | cppi | | cpplib | [] [] [] | cryptsetup | [] | dfarc | [] [] [] | dialog | [] [] [] [] [] | dico | | diffutils | [] [] [] [] [] [] | dink | [] [] [] | doodle | [] | e2fsprogs | [] [] [] | enscript | [] [] [] | exif | () [] [] | fetchmail | [] [] () [] [] [] | findutils | [] [] [] | flex | [] [] | freedink | [] [] [] | gas | [] | gawk | [] [] [] | gcal | [] | gcc | [] [] | gettext-examples | [] [] [] [] | gettext-runtime | [] [] [] [] | gettext-tools | [] [] [] | gip | [] [] [] [] | gjay | [] | gliv | [] [] [] | glunarclock | [] [] | gnubiff | () | gnucash | [] () () () () | gnuedu | [] [] | gnulib | [] [] | gnunet | | gnunet-gtk | [] | gnutls | [] [] | gold | [] | gpe-aerial | [] [] [] [] | gpe-beam | [] [] [] [] | gpe-bluetooth | [] [] | gpe-calendar | [] | gpe-clock | [] [] [] [] | gpe-conf | [] [] [] | gpe-contacts | [] [] [] | gpe-edit | [] [] | gpe-filemanager | [] [] [] | gpe-go | [] [] [] [] | gpe-login | [] [] | gpe-ownerinfo | [] [] [] [] | gpe-package | [] [] [] | gpe-sketchbook | [] [] [] [] | gpe-su | [] [] [] [] | gpe-taskmanager | [] [] [] [] | gpe-timesheet | [] [] [] [] | gpe-today | [] [] [] [] | gpe-todo | [] [] [] | gphoto2 | [] [] () [] [] [] | gprof | [] [] [] | gpsdrive | [] [] [] | gramadoir | [] [] [] | grep | [] | grub | [] [] | gsasl | [] | gss | | gst-plugins-bad | [] [] [] [] [] | gst-plugins-base | [] [] [] [] [] | gst-plugins-good | [] [] [] [] [] [] | gst-plugins-ugly | [] [] [] [] [] [] | gstreamer | [] [] [] [] [] | gtick | [] () [] | gtkam | [] [] () [] [] | gtkorphan | [] [] [] [] | gtkspell | [] [] [] [] [] [] [] | gutenprint | [] [] [] | hello | [] [] [] [] | help2man | [] | hylafax | [] [] | idutils | [] [] | indent | [] [] [] [] [] [] [] | iso_15924 | [] () [] [] | iso_3166 | [] [] [] [] () [] [] [] () | iso_3166_2 | () | iso_4217 | [] [] [] () [] [] | iso_639 | [] [] [] [] () [] [] | iso_639_3 | [] | jwhois | [] | kbd | [] [] [] [] [] | keytouch | [] [] | keytouch-editor | [] [] | keytouch-keyboa... | [] | klavaro | [] [] [] [] | latrine | [] () | ld | [] [] | leafpad | [] [] [] [] [] [] | libc | [] [] [] [] | libexif | [] [] () | libextractor | | libgnutls | [] | libgpewidget | [] [] | libgpg-error | [] [] | libgphoto2 | [] () | libgphoto2_port | [] () [] | libgsasl | | libiconv | [] [] [] [] [] | libidn | [] [] [] | lifelines | [] () | liferea | [] [] [] [] [] | lilypond | [] [] [] | linkdr | [] [] [] | lordsawar | [] | lprng | | lynx | [] [] [] [] | m4 | [] [] [] [] | mailfromd | | mailutils | [] | make | [] [] [] | man-db | | man-db-manpages | | minicom | [] [] [] [] | mkisofs | | myserver | | nano | [] [] [] | opcodes | [] [] | parted | [] [] | pies | | popt | [] [] [] [] [] | psmisc | [] [] [] | pspp | [] | pwdutils | [] | radius | [] | recode | [] [] [] [] [] [] | rosegarden | () () () | rpm | [] [] [] | rush | | sarg | | screem | | scrollkeeper | [] [] [] [] [] | sed | [] [] [] [] [] [] | sharutils | [] [] [] [] | shishi | | skencil | [] () [] | solfege | [] [] [] | solfege-manual | [] [] | soundtracker | [] [] [] | sp | [] | sysstat | [] [] [] | tar | [] [] [] [] | texinfo | [] [] [] | tin | [] [] | unicode-han-tra... | | unicode-transla... | | util-linux-ng | [] [] [] [] | vice | () () | vmm | [] | vorbis-tools | [] [] | wastesedge | [] | wdiff | [] [] | wget | [] [] [] | wyslij-po | | xchat | [] [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] [] [] [] | +-------------------------------------------------+ crh cs da de el en en_GB en_ZA eo es et eu fa 5 64 105 117 18 1 8 0 28 89 18 19 0 fi fr ga gl gu he hi hr hu hy id is it ja ka kn +----------------------------------------------------+ a2ps | [] [] [] [] | aegis | [] [] | ant-phone | [] [] | anubis | [] [] [] [] | aspell | [] [] [] [] | bash | [] [] [] [] | bfd | [] [] [] | bibshelf | [] [] [] [] [] | binutils | [] [] [] | bison | [] [] [] [] | bison-runtime | [] [] [] [] [] [] | bluez-pin | [] [] [] [] [] [] [] [] | bombono-dvd | [] | buzztard | [] | cflow | [] [] [] | clisp | [] | coreutils | [] [] [] [] [] | cpio | [] [] [] [] | cppi | [] [] | cpplib | [] [] [] | cryptsetup | [] [] [] | dfarc | [] [] [] | dialog | [] [] [] [] [] [] [] | dico | | diffutils | [] [] [] [] [] [] [] [] [] | dink | [] | doodle | [] [] | e2fsprogs | [] [] | enscript | [] [] [] [] | exif | [] [] [] [] [] [] | fetchmail | [] [] [] [] | findutils | [] [] [] [] [] [] | flex | [] [] [] | freedink | [] [] [] | gas | [] [] | gawk | [] [] [] [] () [] | gcal | [] | gcc | [] | gettext-examples | [] [] [] [] [] [] [] | gettext-runtime | [] [] [] [] [] [] | gettext-tools | [] [] [] [] | gip | [] [] [] [] [] [] | gjay | [] | gliv | [] () | glunarclock | [] [] [] [] | gnubiff | () [] () | gnucash | () () () () () [] | gnuedu | [] [] | gnulib | [] [] [] [] [] [] | gnunet | | gnunet-gtk | [] | gnutls | [] [] | gold | [] [] | gpe-aerial | [] [] [] | gpe-beam | [] [] [] [] | gpe-bluetooth | [] [] [] [] | gpe-calendar | [] [] | gpe-clock | [] [] [] [] [] | gpe-conf | [] [] [] [] | gpe-contacts | [] [] [] [] | gpe-edit | [] [] [] | gpe-filemanager | [] [] [] [] | gpe-go | [] [] [] [] [] | gpe-login | [] [] [] | gpe-ownerinfo | [] [] [] [] [] | gpe-package | [] [] [] | gpe-sketchbook | [] [] [] [] | gpe-su | [] [] [] [] [] [] | gpe-taskmanager | [] [] [] [] [] | gpe-timesheet | [] [] [] [] [] | gpe-today | [] [] [] [] [] [] [] | gpe-todo | [] [] [] | gphoto2 | [] [] [] [] [] [] | gprof | [] [] [] [] | gpsdrive | [] [] [] | gramadoir | [] [] [] | grep | [] [] | grub | [] [] [] [] | gsasl | [] [] [] [] [] | gss | [] [] [] [] [] | gst-plugins-bad | [] [] [] [] [] [] | gst-plugins-base | [] [] [] [] [] [] | gst-plugins-good | [] [] [] [] [] [] | gst-plugins-ugly | [] [] [] [] [] [] | gstreamer | [] [] [] [] [] | gtick | [] [] [] [] [] | gtkam | [] [] [] [] [] | gtkorphan | [] [] [] | gtkspell | [] [] [] [] [] [] [] [] [] | gutenprint | [] [] [] [] | hello | [] [] [] | help2man | [] [] | hylafax | [] | idutils | [] [] [] [] [] [] | indent | [] [] [] [] [] [] [] [] | iso_15924 | [] () [] [] | iso_3166 | [] () [] [] [] [] [] [] [] [] [] [] | iso_3166_2 | () [] [] [] | iso_4217 | [] () [] [] [] [] | iso_639 | [] () [] [] [] [] [] [] [] | iso_639_3 | () [] [] | jwhois | [] [] [] [] [] | kbd | [] [] | keytouch | [] [] [] [] [] [] | keytouch-editor | [] [] [] [] [] | keytouch-keyboa... | [] [] [] [] [] | klavaro | [] [] | latrine | [] [] [] | ld | [] [] [] [] | leafpad | [] [] [] [] [] [] [] () | libc | [] [] [] [] [] | libexif | [] | libextractor | | libgnutls | [] [] | libgpewidget | [] [] [] [] | libgpg-error | [] [] | libgphoto2 | [] [] [] | libgphoto2_port | [] [] [] | libgsasl | [] [] [] [] [] | libiconv | [] [] [] [] [] [] | libidn | [] [] [] [] | lifelines | () | liferea | [] [] [] [] | lilypond | [] [] | linkdr | [] [] [] [] [] | lordsawar | | lprng | [] | lynx | [] [] [] [] [] | m4 | [] [] [] [] [] [] | mailfromd | | mailutils | [] [] | make | [] [] [] [] [] [] [] [] [] | man-db | [] [] | man-db-manpages | [] | minicom | [] [] [] [] [] | mkisofs | [] [] [] [] | myserver | | nano | [] [] [] [] [] [] | opcodes | [] [] [] [] | parted | [] [] [] [] | pies | | popt | [] [] [] [] [] [] [] [] [] | psmisc | [] [] [] | pspp | | pwdutils | [] [] | radius | [] [] | recode | [] [] [] [] [] [] [] [] | rosegarden | () () () () () | rpm | [] [] | rush | | sarg | [] | screem | [] [] | scrollkeeper | [] [] [] [] | sed | [] [] [] [] [] [] [] [] | sharutils | [] [] [] [] [] [] [] | shishi | [] | skencil | [] | solfege | [] [] [] [] | solfege-manual | [] [] | soundtracker | [] [] | sp | [] () | sysstat | [] [] [] [] [] | tar | [] [] [] [] [] [] [] | texinfo | [] [] [] [] | tin | [] | unicode-han-tra... | | unicode-transla... | [] [] | util-linux-ng | [] [] [] [] [] [] | vice | () () () | vmm | [] | vorbis-tools | [] | wastesedge | () () | wdiff | [] | wget | [] [] [] [] [] [] [] [] | wyslij-po | [] [] [] | xchat | [] [] [] [] [] [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] [] [] | +----------------------------------------------------+ fi fr ga gl gu he hi hr hu hy id is it ja ka kn 105 121 53 20 4 8 3 5 53 2 120 5 84 67 0 4 ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne +-----------------------------------------------+ a2ps | [] | aegis | | ant-phone | | anubis | [] [] | aspell | [] | bash | | bfd | | bibshelf | [] [] | binutils | | bison | [] | bison-runtime | [] [] [] [] [] | bluez-pin | [] [] [] [] [] | bombono-dvd | | buzztard | | cflow | | clisp | | coreutils | [] | cpio | | cppi | | cpplib | | cryptsetup | | dfarc | [] | dialog | [] [] [] [] [] | dico | | diffutils | [] [] | dink | | doodle | | e2fsprogs | | enscript | | exif | [] | fetchmail | | findutils | | flex | | freedink | [] | gas | | gawk | | gcal | | gcc | | gettext-examples | [] [] [] [] | gettext-runtime | [] | gettext-tools | [] | gip | [] [] | gjay | | gliv | | glunarclock | [] | gnubiff | | gnucash | () () () () | gnuedu | | gnulib | | gnunet | | gnunet-gtk | | gnutls | [] | gold | | gpe-aerial | [] | gpe-beam | [] | gpe-bluetooth | [] [] | gpe-calendar | [] | gpe-clock | [] [] [] [] [] | gpe-conf | [] [] | gpe-contacts | [] [] | gpe-edit | [] | gpe-filemanager | [] [] | gpe-go | [] [] [] | gpe-login | [] | gpe-ownerinfo | [] [] | gpe-package | [] [] | gpe-sketchbook | [] [] | gpe-su | [] [] [] [] [] [] | gpe-taskmanager | [] [] [] [] [] [] | gpe-timesheet | [] [] | gpe-today | [] [] [] [] | gpe-todo | [] [] | gphoto2 | | gprof | [] | gpsdrive | | gramadoir | | grep | | grub | | gsasl | | gss | | gst-plugins-bad | [] [] [] [] | gst-plugins-base | [] [] | gst-plugins-good | [] [] | gst-plugins-ugly | [] [] [] [] [] | gstreamer | | gtick | | gtkam | [] | gtkorphan | [] [] | gtkspell | [] [] [] [] [] [] [] | gutenprint | | hello | [] [] [] | help2man | | hylafax | | idutils | | indent | | iso_15924 | [] [] | iso_3166 | [] [] () [] [] [] [] [] | iso_3166_2 | | iso_4217 | [] [] | iso_639 | [] [] | iso_639_3 | [] | jwhois | [] | kbd | | keytouch | [] | keytouch-editor | [] | keytouch-keyboa... | [] | klavaro | [] | latrine | [] | ld | | leafpad | [] [] [] | libc | [] | libexif | | libextractor | | libgnutls | [] | libgpewidget | [] [] | libgpg-error | | libgphoto2 | | libgphoto2_port | | libgsasl | | libiconv | | libidn | | lifelines | | liferea | | lilypond | | linkdr | | lordsawar | | lprng | | lynx | | m4 | | mailfromd | | mailutils | | make | [] | man-db | | man-db-manpages | | minicom | [] | mkisofs | | myserver | | nano | [] [] | opcodes | | parted | | pies | | popt | [] [] [] | psmisc | | pspp | | pwdutils | | radius | | recode | | rosegarden | | rpm | | rush | | sarg | | screem | | scrollkeeper | [] [] | sed | | sharutils | | shishi | | skencil | | solfege | [] | solfege-manual | | soundtracker | | sp | | sysstat | [] | tar | [] | texinfo | [] | tin | | unicode-han-tra... | | unicode-transla... | | util-linux-ng | | vice | | vmm | | vorbis-tools | | wastesedge | | wdiff | | wget | [] | wyslij-po | | xchat | [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] | +-----------------------------------------------+ ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne 20 5 10 1 13 48 4 2 2 4 24 10 20 3 1 nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr +---------------------------------------------------+ a2ps | [] [] [] [] [] [] [] [] | aegis | [] [] [] | ant-phone | [] [] | anubis | [] [] [] | aspell | [] [] [] [] [] | bash | [] [] | bfd | [] | bibshelf | [] [] | binutils | [] [] | bison | [] [] [] | bison-runtime | [] [] [] [] [] [] [] | bluez-pin | [] [] [] [] [] [] [] [] | bombono-dvd | [] () | buzztard | [] [] | cflow | [] | clisp | [] [] | coreutils | [] [] [] [] [] [] | cpio | [] [] [] | cppi | [] | cpplib | [] | cryptsetup | [] | dfarc | [] | dialog | [] [] [] [] | dico | [] | diffutils | [] [] [] [] [] [] | dink | () | doodle | [] [] | e2fsprogs | [] [] | enscript | [] [] [] [] [] | exif | [] [] [] () [] | fetchmail | [] [] [] [] | findutils | [] [] [] [] [] | flex | [] [] [] [] [] | freedink | [] [] | gas | | gawk | [] [] [] [] | gcal | | gcc | [] | gettext-examples | [] [] [] [] [] [] [] [] | gettext-runtime | [] [] [] [] [] [] [] [] [] | gettext-tools | [] [] [] [] [] [] | gip | [] [] [] [] [] | gjay | | gliv | [] [] [] [] [] [] | glunarclock | [] [] [] [] [] | gnubiff | [] () | gnucash | [] () () () | gnuedu | [] | gnulib | [] [] [] [] | gnunet | | gnunet-gtk | | gnutls | [] [] | gold | | gpe-aerial | [] [] [] [] [] [] [] | gpe-beam | [] [] [] [] [] [] [] | gpe-bluetooth | [] [] | gpe-calendar | [] [] [] [] | gpe-clock | [] [] [] [] [] [] [] [] | gpe-conf | [] [] [] [] [] [] [] | gpe-contacts | [] [] [] [] [] | gpe-edit | [] [] [] | gpe-filemanager | [] [] [] | gpe-go | [] [] [] [] [] [] [] [] | gpe-login | [] [] | gpe-ownerinfo | [] [] [] [] [] [] [] [] | gpe-package | [] [] | gpe-sketchbook | [] [] [] [] [] [] [] | gpe-su | [] [] [] [] [] [] [] [] | gpe-taskmanager | [] [] [] [] [] [] [] [] | gpe-timesheet | [] [] [] [] [] [] [] [] | gpe-today | [] [] [] [] [] [] [] [] | gpe-todo | [] [] [] [] [] | gphoto2 | [] [] [] [] [] [] [] [] | gprof | [] [] [] | gpsdrive | [] [] | gramadoir | [] [] | grep | [] [] [] [] | grub | [] [] [] | gsasl | [] [] [] [] | gss | [] [] [] | gst-plugins-bad | [] [] [] [] [] [] | gst-plugins-base | [] [] [] [] [] | gst-plugins-good | [] [] [] [] [] | gst-plugins-ugly | [] [] [] [] [] [] | gstreamer | [] [] [] [] [] | gtick | [] [] [] | gtkam | [] [] [] [] [] [] | gtkorphan | [] | gtkspell | [] [] [] [] [] [] [] [] [] [] | gutenprint | [] [] | hello | [] [] [] [] | help2man | [] [] | hylafax | [] | idutils | [] [] [] [] [] | indent | [] [] [] [] [] [] [] | iso_15924 | [] [] [] [] | iso_3166 | [] [] [] [] [] () [] [] [] [] [] [] [] [] | iso_3166_2 | [] [] [] | iso_4217 | [] [] [] [] [] [] [] [] | iso_639 | [] [] [] [] [] [] [] [] [] | iso_639_3 | [] [] | jwhois | [] [] [] [] | kbd | [] [] [] | keytouch | [] [] [] | keytouch-editor | [] [] [] | keytouch-keyboa... | [] [] [] | klavaro | [] [] | latrine | [] [] | ld | | leafpad | [] [] [] [] [] [] [] [] [] | libc | [] [] [] [] | libexif | [] [] () [] | libextractor | | libgnutls | [] [] | libgpewidget | [] [] [] | libgpg-error | [] [] | libgphoto2 | [] [] | libgphoto2_port | [] [] [] [] [] | libgsasl | [] [] [] [] [] | libiconv | [] [] [] [] [] | libidn | [] [] | lifelines | [] [] | liferea | [] [] [] [] [] () () [] | lilypond | [] | linkdr | [] [] [] | lordsawar | | lprng | [] | lynx | [] [] [] | m4 | [] [] [] [] [] | mailfromd | [] | mailutils | [] | make | [] [] [] [] | man-db | [] [] [] | man-db-manpages | [] [] [] | minicom | [] [] [] [] | mkisofs | [] [] [] | myserver | | nano | [] [] [] [] | opcodes | [] [] | parted | [] [] [] [] | pies | [] | popt | [] [] [] [] | psmisc | [] [] [] | pspp | [] [] | pwdutils | [] | radius | [] [] [] | recode | [] [] [] [] [] [] [] [] | rosegarden | () () | rpm | [] [] [] | rush | [] [] | sarg | | screem | | scrollkeeper | [] [] [] [] [] [] [] [] | sed | [] [] [] [] [] [] [] [] [] | sharutils | [] [] [] [] | shishi | [] | skencil | [] [] | solfege | [] [] [] [] | solfege-manual | [] [] [] | soundtracker | [] | sp | | sysstat | [] [] [] [] | tar | [] [] [] [] | texinfo | [] [] [] [] | tin | [] | unicode-han-tra... | | unicode-transla... | | util-linux-ng | [] [] [] [] [] | vice | [] | vmm | [] | vorbis-tools | [] [] | wastesedge | [] | wdiff | [] [] | wget | [] [] [] [] [] [] [] | wyslij-po | [] [] [] | xchat | [] [] [] [] [] [] [] [] [] | xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] [] | xkeyboard-config | [] [] [] | +---------------------------------------------------+ nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr 135 10 4 7 105 1 29 62 47 91 3 54 46 9 37 sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW +---------------------------------------------------+ a2ps | [] [] [] [] [] | 27 aegis | [] | 9 ant-phone | [] [] [] [] | 9 anubis | [] [] [] [] | 15 aspell | [] [] [] | 20 bash | [] [] [] | 12 bfd | [] | 6 bibshelf | [] [] [] | 16 binutils | [] [] | 8 bison | [] [] | 12 bison-runtime | [] [] [] [] [] [] | 29 bluez-pin | [] [] [] [] [] [] [] [] | 37 bombono-dvd | [] | 4 buzztard | [] | 7 cflow | [] [] [] | 9 clisp | | 10 coreutils | [] [] [] [] | 22 cpio | [] [] [] [] [] [] | 13 cppi | [] [] | 5 cpplib | [] [] [] [] [] [] | 14 cryptsetup | [] [] | 7 dfarc | [] | 9 dialog | [] [] [] [] [] [] [] | 30 dico | [] | 2 diffutils | [] [] [] [] [] [] | 30 dink | | 4 doodle | [] [] | 7 e2fsprogs | [] [] [] | 11 enscript | [] [] [] [] | 17 exif | [] [] [] | 16 fetchmail | [] [] [] | 17 findutils | [] [] [] [] [] | 20 flex | [] [] [] [] | 15 freedink | [] | 10 gas | [] | 4 gawk | [] [] [] [] | 18 gcal | [] [] | 5 gcc | [] [] [] | 7 gettext-examples | [] [] [] [] [] [] [] | 34 gettext-runtime | [] [] [] [] [] [] [] | 29 gettext-tools | [] [] [] [] [] [] | 22 gip | [] [] [] [] | 22 gjay | [] | 3 gliv | [] [] [] | 14 glunarclock | [] [] [] [] [] | 19 gnubiff | [] [] | 4 gnucash | () [] () [] () | 10 gnuedu | [] [] | 7 gnulib | [] [] [] [] | 16 gnunet | [] | 1 gnunet-gtk | [] [] [] | 5 gnutls | [] [] [] | 10 gold | [] | 4 gpe-aerial | [] [] [] | 18 gpe-beam | [] [] [] | 19 gpe-bluetooth | [] [] [] | 13 gpe-calendar | [] [] [] [] | 12 gpe-clock | [] [] [] [] [] | 28 gpe-conf | [] [] [] [] | 20 gpe-contacts | [] [] [] | 17 gpe-edit | [] [] [] | 12 gpe-filemanager | [] [] [] [] | 16 gpe-go | [] [] [] [] [] | 25 gpe-login | [] [] [] | 11 gpe-ownerinfo | [] [] [] [] [] | 25 gpe-package | [] [] [] | 13 gpe-sketchbook | [] [] [] | 20 gpe-su | [] [] [] [] [] | 30 gpe-taskmanager | [] [] [] [] [] | 29 gpe-timesheet | [] [] [] [] [] | 25 gpe-today | [] [] [] [] [] [] | 30 gpe-todo | [] [] [] [] | 17 gphoto2 | [] [] [] [] [] | 24 gprof | [] [] [] | 15 gpsdrive | [] [] [] | 11 gramadoir | [] [] [] | 11 grep | [] [] [] | 10 grub | [] [] [] | 14 gsasl | [] [] [] [] | 14 gss | [] [] [] | 11 gst-plugins-bad | [] [] [] [] | 26 gst-plugins-base | [] [] [] [] [] | 24 gst-plugins-good | [] [] [] [] | 24 gst-plugins-ugly | [] [] [] [] [] | 29 gstreamer | [] [] [] [] | 22 gtick | [] [] [] | 13 gtkam | [] [] [] | 20 gtkorphan | [] [] [] | 14 gtkspell | [] [] [] [] [] [] [] [] [] | 45 gutenprint | [] | 10 hello | [] [] [] [] [] [] | 21 help2man | [] [] | 7 hylafax | [] | 5 idutils | [] [] [] [] | 17 indent | [] [] [] [] [] [] | 30 iso_15924 | () [] () [] [] | 16 iso_3166 | [] [] () [] [] () [] [] [] () | 53 iso_3166_2 | () [] () [] | 9 iso_4217 | [] () [] [] () [] [] | 26 iso_639 | [] [] [] () [] () [] [] [] [] | 38 iso_639_3 | [] () | 8 jwhois | [] [] [] [] [] | 16 kbd | [] [] [] [] [] | 15 keytouch | [] [] [] | 16 keytouch-editor | [] [] [] | 14 keytouch-keyboa... | [] [] [] | 14 klavaro | [] | 11 latrine | [] [] [] | 10 ld | [] [] [] [] | 11 leafpad | [] [] [] [] [] [] | 33 libc | [] [] [] [] [] | 21 libexif | [] () | 7 libextractor | [] | 1 libgnutls | [] [] [] | 9 libgpewidget | [] [] [] | 14 libgpg-error | [] [] [] | 9 libgphoto2 | [] [] | 8 libgphoto2_port | [] [] [] [] | 14 libgsasl | [] [] [] | 13 libiconv | [] [] [] [] | 21 libidn | () [] [] | 11 lifelines | [] | 4 liferea | [] [] [] | 21 lilypond | [] | 7 linkdr | [] [] [] [] [] | 17 lordsawar | | 1 lprng | [] | 3 lynx | [] [] [] [] | 17 m4 | [] [] [] [] | 19 mailfromd | [] [] | 3 mailutils | [] | 5 make | [] [] [] [] | 21 man-db | [] [] [] | 8 man-db-manpages | | 4 minicom | [] [] | 16 mkisofs | [] [] | 9 myserver | | 0 nano | [] [] [] [] | 21 opcodes | [] [] [] | 11 parted | [] [] [] [] [] | 15 pies | [] [] | 3 popt | [] [] [] [] [] [] | 27 psmisc | [] [] | 11 pspp | | 4 pwdutils | [] [] | 6 radius | [] [] | 9 recode | [] [] [] [] | 28 rosegarden | () | 0 rpm | [] [] [] | 11 rush | [] [] | 4 sarg | | 1 screem | [] | 3 scrollkeeper | [] [] [] [] [] | 27 sed | [] [] [] [] [] | 30 sharutils | [] [] [] [] [] | 22 shishi | [] | 3 skencil | [] [] | 7 solfege | [] [] [] [] | 16 solfege-manual | [] | 8 soundtracker | [] [] [] | 9 sp | [] | 3 sysstat | [] [] | 15 tar | [] [] [] [] [] [] | 23 texinfo | [] [] [] [] [] | 17 tin | | 4 unicode-han-tra... | | 0 unicode-transla... | | 2 util-linux-ng | [] [] [] [] | 20 vice | () () | 1 vmm | [] | 4 vorbis-tools | [] | 6 wastesedge | | 2 wdiff | [] [] | 7 wget | [] [] [] [] [] | 26 wyslij-po | [] [] | 8 xchat | [] [] [] [] [] [] | 36 xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | 63 xkeyboard-config | [] [] [] | 22 +---------------------------------------------------+ 85 teams sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW 178 domains 119 1 3 3 0 10 65 51 155 17 98 7 41 2618 Some counters in the preceding matrix are higher than the number of visible blocks let us expect. This is because a few extra PO files are used for implementing regional variants of languages, or language dialects. For a PO file in the matrix above to be effective, the package to which it applies should also have been internationalized and distributed as such by its maintainer. There might be an observable lag between the mere existence a PO file and its wide availability in a distribution. If June 2010 seems to be old, you may fetch a more recent copy of this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date matrix with full percentage details can be found at `http://translationproject.org/extra/matrix.html'. 1.5 Using `gettext' in new packages =================================== If you are writing a freely available program and want to internationalize it you are welcome to use GNU `gettext' in your package. Of course you have to respect the GNU Library General Public License which covers the use of the GNU `gettext' library. This means in particular that even non-free programs can use `libintl' as a shared library, whereas only free software can use `libintl' as a static library or use modified versions of `libintl'. Once the sources are changed appropriately and the setup can handle the use of `gettext' the only thing missing are the translations. The Free Translation Project is also available for packages which are not developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact `coordinator@translationproject.org' to make the `.pot' files available to the translation teams. libpsl-libpsl-0.11.0/AUTHORS000066400000000000000000000010531260052016400154040ustar00rootroot00000000000000Authors of and contributors to libpsl. Thank you very much for spending your time ! Also many thanks for anyone who contributed ideas, took part in discussions or 'just' asked questions. Please drop me a note if you feel you should have been mentioned here. Tim Ruehsen (Implementation of libpsl) Daniel Kahn Gillmor (Discussion, Ideas, Organization, Code) Daniel Stenberg (Discussion, Ideas) Darshit Shah (Patching Wget to work with libpsl) Dagobert Michelsen (Fixed Solaris building) Christopher Meng (Fedora building) Jakub Čajka Giuseppe Scrivano libpsl-libpsl-0.11.0/COPYING000066400000000000000000000020441260052016400153700ustar00rootroot00000000000000Copyright (C) 2014-2015 Tim Rühsen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libpsl-libpsl-0.11.0/LICENSE000066400000000000000000000020441260052016400153420ustar00rootroot00000000000000Copyright (C) 2014-2015 Tim Rühsen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libpsl-libpsl-0.11.0/Makefile.am000066400000000000000000000013171260052016400163730ustar00rootroot00000000000000# got some hints from https://gitorious.org/openismus-playground/examplelib/source SUBDIRS = po include src tools $(LIBPSL_DOCS) tests ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} # Enable GTK-Doc during make distcheck #DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-man ## Install the generated pkg-config file (.pc) into the expected location for ## architecture-dependent package configuration information. Occasionally, ## pkg-config files are also used for architecture-independent data packages, ## in which case the correct install location would be $(datadir)/pkgconfig. pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libpsl.pc EXTRA_DIST = config.rpath LICENSE $(PSL_FILE) list/tests/test_psl.txt libpsl-libpsl-0.11.0/NEWS000066400000000000000000000063731260052016400150450ustar00rootroot00000000000000Copyright (C) 2014-2015 Tim Rühsen 23.09.2015 Release V0.11.0 * Add new function psl_check_version_number() * Add version defines to include file 19.09.2025 Release V0.10.0 * Code simplified * Less data entries, faster lookups * Add new function psl_suffix_wildcard_count() * Add new helper function psl_builtin_outdated() 15.09.2015 Release V0.9.0 * Added semantic checks to PSL entries when generating built-in data * Fix test suite for TLD exceptions (not used yet in reality) * Removed wrong assumption from test suite * Support explicit combination of 'foo.bar' and '*.foo.bar' 14.08.2015 Release V0.8.1 * Fix documentation * Add syntax checking of tests_psl.txt 06.08.2015 Release V0.8.0 * Add https://github.com/publicsuffix as git submodule * Support Debian 'Reproducible Builds' * Fix generation of docs * Check UTF-8 sequences for validity (for libidn<=1.30) * Add LICENSE to distribution tarball * Fix compatibility function strndup 21.02.2015 Release V0.7.1 * include configured PSL file into tarball 30.01.2015 Release V0.7.0 * include effective_tld_names.dat of date 29.12.2014 * do not install docs when gtk-doc is not installed * fix several compatibility issues with Solaris * fix 'make distcheck' after 'make clean' * mark API as stable * use pkg-config to detect libicu 14.11.2014 Release V0.6.2 * revoked commit from 0.6.1 to satisfy Travis-CI 14.11.2014 Release V0.6.1 * include effective_tld_names.dat of date 04.11.2014 * fix pkg-config configuration 28.10.2014 Release V0.6.0 * added support for IP addresses in psl_is_cookie_domain_acceptable() * removed qsort_r() for compatibility * check for alloca.h before including * include effective_tld_names.dat of date 27.10.2014 03.08.2014 Release V0.5.1 * fix ASCII check for architectures where char <> signed char 02.07.2014 Release V0.5.0 * added configure --enable-runtime to allow for IDNA library selection as runtime dependency * added configure --enable-builtin to allow for IDNA library selection for generating the built-in PSL data * fixed psl_str_to_utf8lower prototype * fixed authors name to UTF-8 23.06.2014 Release V0.4.0 * depend on libicu for punycode, utf-8 and lowercase conversions * added function psl_str_to_utf8lower() * fixed locale issues * introducing psl_error_t for error codes + defines * removed redundant code from psl2c.c * updated docs * psl utility reads from stdin if no argument specified 10.06.2014 Release V0.3.1 * link psl utility dynamically * fix output of psl_filename() * cleanup for psl --help * removed check for idn2 in autogen.sh 05.06.2014 Release V0.3.0 * added support for libicu in psl2c (IDNA2008 UTS#46) this needs pkg-config and libicu-dev installed * added --version to psl utility 31.05.2014 Release V0.2.5 * added psl_get_version() * removed version from library name 30.05.2014 Release V0.2.4 * fixed psl_builtin() to return NULL if no built-in PSL data is available 27.05.2014 Release V0.2.3 * changed API version to 0.2 26.05.2014 Release V0.2.2 * changed code to C89 * added a few test cases * build static library by default 25.04.2014 Hotfix release V0.2.1 * updated to the latest Publix Suffix List 25.04.2014 Initial release V0.2 libpsl-libpsl-0.11.0/README000066400000000000000000000000001260052016400152030ustar00rootroot00000000000000libpsl-libpsl-0.11.0/README.md000066400000000000000000000056061260052016400156230ustar00rootroot00000000000000[![Build Status](https://travis-ci.org/rockdaboot/libpsl.png?branch=master)](https://travis-ci.org/rockdaboot/libpsl) libpsl - C library to handle the Public Suffix List =================================================== A "public suffix" is a domain name under which Internet users can directly register own names. Browsers and other web clients can use it to - avoid privacy-leaking "supercookies" - avoid privacy-leaking "super domain" certificates ([see post from Jeffry Walton](http://lists.gnu.org/archive/html/bug-wget/2014-03/msg00093.html)) - domain highlighting parts of the domain in a user interface - sorting domain lists by site Libpsl... - has built-in PSL data for fast access - allows to load PSL data from files - checks if a given domain is a "public suffix" - provides immediate cookie domain verification - finds the longest public part of a given domain - finds the shortest private part of a given domain - works with international domains (UTF-8 and IDNA2008 Punycode) - is thread-safe - handles IDNA2008 UTS#46 (libicu is used by psl2c if installed) Find more information about the Publix Suffix List [here](http://publicsuffix.org/). Download the Public Suffix List [here](https://hg.mozilla.org/mozilla-central/raw-file/tip/netwerk/dns/effective_tld_names.dat). API Documentation ----------------- You find the current API documentation [here](https://rockdaboot.github.io/libpsl). Quick API example ----------------- #include #include int main(int argc, char **argv) { const char *domain = "www.example.com"; const char *cookie_domain = ".com"; const psl_ctx_t *psl = psl_builtin(); int is_public, is_acceptable; is_public = psl_is_public_suffix(psl, domain); printf("%s %s a public suffix.\n", domain, is_public ? "is" : "is not"); is_acceptable = psl_is_cookie_domain_acceptable(psl, domain, cookie_domain); printf("cookie domain '%s' %s acceptable for domain '%s'.\n", cookie_domain, is_acceptable ? "is" : "is not", domain); return 0; } Command Line Tool ----------------- Libpsl comes with a tool 'psl' that gives you access to most of the library API via command line. $ psl --help prints the usage. License ------- Libpsl is made available under the terms of the MIT license.
See the LICENSE file that accompanies this distribution for the full text of the license. Building from git ----------------- Download project and prepare sources with git clone http://github.com/rockdaboot/libpsl ./autogen.sh ./configure make make check Mailing List ------------ [Mailing List Archive](http://news.gmane.org/gmane.network.dns.libpsl.bugs) [Mailing List](https://groups.google.com/forum/#!forum/libpsl-bugs) To join the mailing list send an email to and follow the instructions provided by the answer mail. Or click [join](https://groups.google.com/forum/#!forum/libpsl-bugs/join). libpsl-libpsl-0.11.0/autogen.sh000077500000000000000000000021141260052016400163340ustar00rootroot00000000000000# !/bin/sh -e AUTORECONF=`which autoreconf 2>/dev/null` if test $? -ne 0; then echo "No 'autoreconf' found. You must install the autoconf package." exit 1 fi GIT=`which git 2>/dev/null` if test $? -ne 0; then echo "No 'git' found. You must install the git package." exit 1 fi # create m4 before gtkdocize mkdir m4 2>/dev/null GTKDOCIZE=`which gtkdocize 2>/dev/null` if test $? -ne 0; then echo "No gtk-doc support found. You can't build the docs." # rm because gtk-doc.make might be a link to a protected file rm -f gtk-doc.make 2>/dev/null echo "EXTRA_DIST =" >gtk-doc.make echo "CLEANFILES =" >>gtk-doc.make GTKDOCIZE="" else $GTKDOCIZE || exit $? fi $GIT submodule init $GIT submodule update $AUTORECONF --install --force --symlink || exit $? echo echo "----------------------------------------------------------------" echo "Initialized build system. For a common configuration please run:" echo "----------------------------------------------------------------" echo if test -z $GTKDOCIZE; then echo "./configure" else echo "./configure --enable-gtk-doc" fi echo libpsl-libpsl-0.11.0/configure.ac000066400000000000000000000245101260052016400166250ustar00rootroot00000000000000 AC_INIT([libpsl], [0.11.0], [tim.ruehsen@gmx.de], [libpsl], [http://github.com/rockdaboot/libpsl]) AC_PREREQ([2.59]) AM_INIT_AUTOMAKE([1.10 -Wall no-define foreign]) # Generate two configuration headers; one for building the library itself with # an autogenerated template, and a second one that will be installed alongside # the library. AC_CONFIG_HEADERS([config.h]) AC_PROG_CC m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) #LT_INIT([disable-static]) LT_INIT AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl Check that compiler understands inline AC_C_INLINE # # Generate version defines for include file # AC_SUBST([LIBPSL_VERSION_MAJOR], [`echo -n $VERSION|cut -d'.' -f1`]) AC_SUBST([LIBPSL_VERSION_MINOR], [`echo -n $VERSION|cut -d'.' -f2`]) AC_SUBST([LIBPSL_VERSION_PATCH], [`echo -n $VERSION|cut -d'.' -f3`]) AC_SUBST([LIBPSL_VERSION_NUMBER], [`printf '0x%02x%02x%02x' $LIBPSL_VERSION_MAJOR $LIBPSL_VERSION_MINOR $LIBPSL_VERSION_PATCH`]) AC_CONFIG_FILES([include/libpsl.h]) # # Gettext # AM_GNU_GETTEXT([external],[need-ngettext]) AM_GNU_GETTEXT_VERSION([0.18.1]) # # check for gtk-doc # m4_ifdef([GTK_DOC_CHECK], [ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ],[ AM_CONDITIONAL([ENABLE_GTK_DOC], false) ]) # needed for some older versions of gtk-doc m4_ifdef([GTK_DOC_USE_LIBTOOL], [], [ AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], false) ]) if test x"$have_gtk_doc" = xyes -a x"$enable_gtk_doc" = xyes; then AC_CONFIG_FILES([docs/libpsl/Makefile docs/libpsl/version.xml]) AC_SUBST([LIBPSL_DOCS], [docs/libpsl]) fi # # enable creation of man pages # AC_ARG_ENABLE(man,[AC_HELP_STRING([--enable-man], [generate man pages [default=auto]])],enable_man=yes,enable_man=no) AS_IF([test "$enable_man" != no], [ AC_PATH_PROG([XSLTPROC], [xsltproc]) AS_IF([test -z "$XSLTPROC"], [ AS_IF([test "$enable_man" = yes], [ AC_MSG_ERROR([xsltproc is required for --enable-man]) ]) enable_man=no ]) ]) AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno) AC_MSG_CHECKING([whether to generate man pages]) AS_IF([ test "$enable_man" != no ], [ AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) ]) PKG_PROG_PKG_CONFIG # Define these substitions here to keep all version information in one place. # For information on how to properly maintain the library version information, # refer to the libtool manual, section "Updating library version information": # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html # # 1. Start with version information of ‘0:0:0’ for each libtool library. # 2. Update the version information only immediately before a public release of your software. More frequent updates are unnecessary, and only guarantee that the current interface number gets larger faster. # 3. If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’). # 4. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. # 5. If any interfaces have been added since the last public release, then increment age. # 6. If any existing interfaces have been removed or changed since the last public release, then set age to 0. AC_SUBST([LIBPSL_SO_VERSION], [4:0:4]) AC_SUBST([LIBPSL_VERSION], $VERSION) # Check for enable/disable builtin PSL data AC_ARG_ENABLE(runtime, [ --enable-runtime[[=IDNA library]] Specify the IDNA library used for libpsl run-time conversions: libicu [[default]]: IDNA2008 UTS#46 library libidn2: IDNA2008 library (also needs libunistring) libidn: IDNA2003 library (also needs libunistring) --disable-runtime Do not link runtime IDNA functionality ], [ if test "$enableval" = "libicu" -o "$enableval" = "yes"; then enable_runtime=libicu AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) elif test "$enableval" = "libidn2"; then enable_runtime=libidn2 AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2]) elif test "$enableval" = "libidn"; then enable_runtime=libidn AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn]) elif test "$enableval" = "no"; then enable_runtime=no else AC_MSG_ERROR([Unknown value $enableval for --enable-runtime]) fi ], [ # this is the default if neither --enable-runtime nor --disable-runtime were specified enable_runtime=libicu AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) ]) # Check for enable/disable builtin PSL data AC_ARG_ENABLE(builtin, [ --enable-builtin[[=IDNA library]] Specify the IDNA library used for built-in data generation: libicu [[default]]: IDNA2008 UTS#46 library libidn2: IDNA2008 library (also needs libunistring) libidn: IDNA2003 library (also needs libunistring) --disable-builtin Do not generate built-in PSL data ], [ if test "$enableval" = "libicu" -o "$enableval" = "yes"; then enable_builtin=libicu AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu]) elif test "$enableval" = "libidn2"; then enable_builtin=libidn2 AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2]) elif test "$enableval" = "libidn"; then enable_builtin=libidn AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn]) elif test "$enableval" = "no"; then enable_builtin=no else AC_MSG_ERROR(Unknown value $enableval) fi ], [ # this is the default if neither --enable-builtin nor --disable-builtin were specified enable_builtin=libicu AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu]) ]) if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu"; then # Check for libicu # using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit # using AC_SEARCH_LIBS also don't work since functions have the library version appended PKG_CHECK_MODULES([LIBICU], [icu-uc], [ HAVE_LIBICU=yes LIBS="$LIBICU_LIBS $LIBS" CFLAGS="$LIBICU_CFLAGS $CFLAGS" ], [ OLDLIBS=$LIBS LIBS="-licuuc $LIBS" AC_MSG_CHECKING([for ICU unicode library]) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include ]], [[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]])], [HAVE_LIBICU=yes; AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); AC_MSG_ERROR(You requested libicu but it is not installed.)]) LIBS=$OLDLIBS ]) fi if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2"; then # Check for libidn2 OLDLIBS=$LIBS AC_SEARCH_LIBS(idn2_lookup_u8, idn2, HAVE_LIBIDN2=yes, AC_MSG_ERROR(You requested libidn2 but it is not installed.)) LIBS=$OLDLIBS fi if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn"; then # Check for libidn OLDLIBS=$LIBS AC_SEARCH_LIBS(idna_to_ascii_8z, idn, HAVE_LIBIDN=yes, AC_MSG_ERROR(You requested libidn but it is not installed.)) LIBS=$OLDLIBS fi if test "x$HAVE_LIBIDN2" = "xyes" -o "x$HAVE_LIBIDN" = "xyes"; then # Check for libunistring, we need it for psl_str_to_utf8lower() OLDLIBS=$LIBS AC_SEARCH_LIBS(u8_tolower, unistring, HAVE_UNISTRING=yes, AC_MSG_ERROR(You requested libidn2 but libunistring is not installed.)) LIBS=$OLDLIBS fi # AM_ICONV sets @LIBICONV@ and @LTLIBICONV@ for use in Makefile.am # do not use AM_ICONV conditionally AM_ICONV AM_CONDITIONAL([WITH_LIBICU], test "x$enable_runtime" = "xlibicu") AM_CONDITIONAL([WITH_LIBIDN2], test "x$enable_runtime" = "xlibidn2") AM_CONDITIONAL([WITH_LIBIDN], test "x$enable_runtime" = "xlibidn") AM_CONDITIONAL([BUILTIN_GENERATOR_LIBICU], test "x$enable_builtin" = "xlibicu") AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN2], test "x$enable_builtin" = "xlibidn2") AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN], test "x$enable_builtin" = "xlibidn") AM_CONDITIONAL([WITH_BUILTIN], test $enable_builtin = yes) # Solaris has socket in libsocket and inet_ntop in libnsl, but also needs libsocket, so the order is important here AC_CHECK_LIB([socket], [socket], [NEEDS_SOCKET=yes], []) if test -n "$NEEDS_SOCKET" ; then AC_CHECK_LIB([nsl], [inet_ntop], [NEEDS_NSL=yes], []) fi if test -n "$NEEDS_SOCKET" && test -n "$NEEDS_NSL" ; then LIBS="$LIBS -lsocket -lnsl" elif test -n "$NEEDS_SOCKET" ; then LIBS="$LIBS -lsocket" elif test -n "$NEEDS_NSL" ; then LIBS="$LIBS -lnsl" fi # Check for valgrind ac_enable_valgrind=no AC_ARG_ENABLE(valgrind-tests, AS_HELP_STRING([--enable-valgrind-tests], [enable using Valgrind for tests]), [ac_enable_valgrind=$enableval], [ac_enable_valgrind=no]) if test "${ac_enable_valgrind}" = "yes" ; then AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) if test "$HAVE_VALGRIND" = "yes" ; then VALGRIND_ENVIRONMENT="valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-origins=yes" AC_SUBST(VALGRIND_ENVIRONMENT) TESTS_INFO="Test suite will be run under Valgrind" else TESTS_INFO="Valgrind not found" fi else TESTS_INFO="Valgrind testing not enabled" fi # Check for custom PSL file AC_ARG_WITH(psl-file, AC_HELP_STRING([--with-psl-file=[PATH]], [path to PSL file]), PSL_FILE=$withval, PSL_FILE="\$(top_srcdir)/list/public_suffix_list.dat") AC_SUBST(PSL_FILE) # Check for custom PSL test file AC_ARG_WITH(psl-testfile, AC_HELP_STRING([--with-psl-testfile=[PATH]], [path to PSL test file]), PSL_TESTFILE=$withval, PSL_TESTFILE="\$(top_srcdir)/list/tests/test_psl.txt") AC_SUBST(PSL_TESTFILE) # check for alloca / alloca.h AC_FUNC_ALLOCA AC_CHECK_FUNCS([strndup]) # Override the template file name of the generated .pc file, so that there # is no need to rename the template file when the API version changes. AC_CONFIG_FILES([Makefile include/Makefile src/Makefile tools/Makefile po/Makefile.in tests/Makefile libpsl.pc:libpsl.pc.in]) AC_OUTPUT AC_MSG_NOTICE([Summary of build options: Version: ${PACKAGE_VERSION} Host OS: ${host_os} Install prefix: ${prefix} Compiler: ${CC} CFlags: ${CFLAGS} ${CPPFLAGS} LDFlags: ${LDFLAGS} Libs: ${LIBS} Runtime: ${enable_runtime} Builtin: ${enable_builtin} PSL File: ${PSL_FILE} PSL Test File: ${PSL_TESTFILE} Tests: ${TESTS_INFO} ]) libpsl-libpsl-0.11.0/contrib/000077500000000000000000000000001260052016400157755ustar00rootroot00000000000000libpsl-libpsl-0.11.0/contrib/check-hard000077500000000000000000000037121260052016400177170ustar00rootroot00000000000000#!/bin/sh # # Do some checking before 'git push'. # Set a stricter bash mode set -e set -u CORES=$(grep -c ^processor /proc/cpuinfo 2> /dev/null || echo 0) if [ $CORES -lt 1 ]; then CORES=1; fi echo "Running: make distclean" make distclean > /dev/null || true # We define _GNU_SOURCE to avoid warnings with missing prototypes. # C89 does not know snprintf, strdup, strndup, popen, pclose CFLAGS="-std=c89 -pedantic -O2 -g -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wwrite-strings -Wshadow -Wformat -Wformat-security -Wunreachable-code -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -D_GNU_SOURCE" CACHEFILE=$PWD/config_check.cache # measure time consumed and print it at the end of the script START=$(date +%s.%N) # avoid annoying ar warning export ARFLAGS="cr" export AR_FLAGS="cr" echo "Running: ./autogen.sh" ./autogen.sh > /dev/null echo for CC in gcc clang; do export CC echo echo "*** Testing with CC=$CC" # the compiler changed, so we have to remove the cache file here rm -f $CACHEFILE for options in \ "--enable-runtime=libicu --enable-builtin=libicu" \ "--enable-runtime=libidn2 --enable-builtin=libidn2" \ "--enable-runtime=libidn --enable-builtin=libidn"; do export DISTCHECK_CONFIGURE_FLAGS="-C --cache-file=$CACHEFILE $options" echo echo " *** ./configure $DISTCHECK_CONFIGURE_FLAGS" ./configure $DISTCHECK_CONFIGURE_FLAGS CFLAGS="$CFLAGS" > /dev/null for xVALGRIND in 0 1; do for xLCALL in C tr_TR.utf8; do export TESTS_ENVIRONMENT="LC_ALL=$xLCALL VALGRIND_TESTS=$xVALGRIND" echo " *** TESTS_ENVIRONMENT=\"$TESTS_ENVIRONMENT\"" make check -j$CORES make check -j$CORES > /dev/null done done unset TESTS_ENVIRONMENT export TESTS_ENVIRONMENT echo echo " *** make distcheck CFLAGS=$CFLAGS -j$CORES" make distcheck CFLAGS="$CFLAGS" -j$CORES > /dev/null done done END=$(date +%s.%N) echo echo "Duration: "$(echo "$END - $START" | bc) libpsl-libpsl-0.11.0/docs/000077500000000000000000000000001260052016400152655ustar00rootroot00000000000000libpsl-libpsl-0.11.0/docs/libpsl/000077500000000000000000000000001260052016400165525ustar00rootroot00000000000000libpsl-libpsl-0.11.0/docs/libpsl/Makefile.am000066400000000000000000000102511260052016400206050ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # We require automake 1.6 at least. AUTOMAKE_OPTIONS = 1.6 # This is a blank Makefile.am for using gtk-doc. # Copy this to your project's API docs directory and modify the variables to # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples # of using the various options. # The name of the module, e.g. 'glib'. DOC_MODULE=libpsl # Uncomment for versioned docs and specify the version of the module, e.g. '2'. #DOC_MODULE_VERSION=2 # The top-level SGML file. You can change this if you want to. DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml # Directories containing the source code. # gtk-doc will search all .c and .h files beneath these paths # for inline comments documenting functions and macros. # e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk DOC_SOURCE_DIR=$(top_srcdir)/src $(top_srcdir)/include # Extra options to pass to gtkdoc-scangobj. Not normally needed. #SCANGOBJ_OPTIONS=--ignore-decorators="UNUSED_RESULT|CONST|PURE" # Extra options to supply to gtkdoc-scan. # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" SCAN_OPTIONS=--ignore-decorators="G_GNUC_PSL_UNUSED" # Extra options to supply to gtkdoc-mkdb. # e.g. MKDB_OPTIONS=--xml-mode --output-format=xml MKDB_OPTIONS=--xml-mode --output-format=xml # Extra options to supply to gtkdoc-mktmpl # e.g. MKTMPL_OPTIONS=--only-section-tmpl MKTMPL_OPTIONS= # Extra options to supply to gtkdoc-mkhtml MKHTML_OPTIONS= # Extra options to supply to gtkdoc-fixref. Not normally needed. # e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html FIXXREF_OPTIONS= # Used for dependencies. The docs will be rebuilt if any of these change. # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c HFILE_GLOB=$(top_srcdir)/include/*.h CFILE_GLOB=$(top_srcdir)/src/*.c # Extra header to include when scanning, which are not under DOC_SOURCE_DIR # e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h EXTRA_HFILES= # Header files or dirs to ignore when scanning. Use base file/dir names # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code IGNORE_HFILES=private.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png HTML_IMAGES= # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). # e.g. content_files=running.sgml building.sgml changes-2.0.sgml content_files= # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files # e.g. expand_content_files=running.sgml expand_content_files= # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget # signals and properties. # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) GTKDOC_CFLAGS= GTKDOC_LIBS= # This includes the standard gtk-doc make rules, copied by gtkdocize. include $(top_srcdir)/gtk-doc.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in EXTRA_DIST += # Files not to distribute # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt #DISTCLEANFILES += # Comment this out if you want 'make check' to test you doc status # and run some sanity checks if ENABLE_GTK_DOC TESTS_ENVIRONMENT = cd $(srcdir) && \ DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) #TESTS = $(GTKDOC_CHECK) endif -include $(top_srcdir)/git.mk theMANS = man_MANS = if ENABLE_GTK_DOC if ENABLE_MAN theMANS += libpsl.3 man_MANS += docs $(theMANS) # make distcheck -jn randomly breaks .NOTPARALLEL: %.3: sgml-build.stamp @file=xml/`basename $@|cut -d'.' -f1`.xml; \ @XSLTPROC@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $$file endif endif BUILT_EXTRA_DIST = $(theMANS) EXTRA_DIST += $(theMANS) CLEANFILES ?= CLEANFILES += $(theMANS) libpsl-overrides.txt libpsl-decl.txt libpsl-decl-list.txt clean-local: rm -rf xml html dist-hook-local: all-local libpsl-docs-clean: clean cd $(srcdir) && rm -rf xml html libpsl-libpsl-0.11.0/docs/libpsl/libpsl-docs.sgml000066400000000000000000000025631260052016400216570ustar00rootroot00000000000000 ]> Libpsl Reference Manual for Libpsl &version;. The latest version of this documentation can be found on-line at GitHub. Libpsl Overview Libpsl provides functions to work with the Mozilla Public Suffix List. Object Hierarchy API Index Index of deprecated API libpsl-libpsl-0.11.0/docs/libpsl/libpsl-sections.txt000066400000000000000000000011051260052016400224220ustar00rootroot00000000000000
libpsl Public Suffix List functions PSL_VERSION PSL_VERSION_MAJOR PSL_VERSION_MINOR PSL_VERSION_NUMBER PSL_VERSION_PATCH psl_error_t psl_ctx_t psl_load_file psl_load_fp psl_builtin psl_free psl_is_public_suffix psl_unregistrable_domain psl_registrable_domain psl_suffix_count psl_suffix_exception_count psl_suffix_wildcard_count psl_builtin_compile_time psl_builtin_file_time psl_builtin_sha1sum psl_builtin_filename psl_builtin_outdated psl_is_cookie_domain_acceptable psl_get_version psl_check_version_number psl_str_to_utf8lower
libpsl-libpsl-0.11.0/docs/libpsl/libpsl.types000066400000000000000000000000001260052016400211130ustar00rootroot00000000000000libpsl-libpsl-0.11.0/docs/libpsl/version.xml.in000066400000000000000000000000211260052016400213570ustar00rootroot00000000000000@LIBPSL_VERSION@ libpsl-libpsl-0.11.0/include/000077500000000000000000000000001260052016400157605ustar00rootroot00000000000000libpsl-libpsl-0.11.0/include/Makefile.am000066400000000000000000000000331260052016400200100ustar00rootroot00000000000000include_HEADERS = libpsl.h libpsl-libpsl-0.11.0/include/libpsl.h.in000066400000000000000000000105401260052016400200230ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of libpsl. * * Header file for libpsl library routines * * Changelog * 20.03.2014 Tim Ruehsen created * */ #ifndef _LIBPSL_LIBPSL_H #define _LIBPSL_LIBPSL_H #include #include #define PSL_VERSION "@LIBPSL_VERSION@" #define PSL_VERSION_MAJOR @LIBPSL_VERSION_MAJOR@ #define PSL_VERSION_MINOR @LIBPSL_VERSION_MINOR@ #define PSL_VERSION_PATCH @LIBPSL_VERSION_PATCH@ #define PSL_VERSION_NUMBER @LIBPSL_VERSION_NUMBER@ #ifdef __cplusplus extern "C" { #endif /** * psl_error_t: * @PSL_SUCCESS: Successful return. * @PSL_ERR_INVALID_ARG: Invalid argument. * @PSL_ERR_CONVERTER: Failed to open libicu utf-16 converter * @PSL_ERR_TO_UTF16: Failed to convert to utf-16. * @PSL_ERR_TO_LOWER: Failed to convert utf-16 to lowercase. * @PSL_ERR_TO_UTF8: Failed to convert utf-16 to utf-8. * * Return codes for PSL functions. * Negative return codes mean failure. * Positive values are reserved for non-error return codes. */ typedef enum { PSL_SUCCESS = 0, PSL_ERR_INVALID_ARG = -1, PSL_ERR_CONVERTER = -2, /* failed to open libicu utf-16 converter */ PSL_ERR_TO_UTF16 = -3, /* failed to convert to utf-16 */ PSL_ERR_TO_LOWER = -4, /* failed to convert utf-16 to lowercase */ PSL_ERR_TO_UTF8 = -5 /* failed to convert utf-16 to utf-8 */ } psl_error_t; typedef struct _psl_ctx_st psl_ctx_t; /* frees PSL context */ void psl_free(psl_ctx_t *psl); /* loads PSL data from file */ psl_ctx_t * psl_load_file(const char *fname); /* loads PSL data from FILE pointer */ psl_ctx_t * psl_load_fp(FILE *fp); /* retrieves builtin PSL data */ const psl_ctx_t * psl_builtin(void); /* checks whether domain is a public suffix or not */ int psl_is_public_suffix(const psl_ctx_t *psl, const char *domain); /* checks whether cookie_domain is acceptable for domain or not */ int psl_is_cookie_domain_acceptable(const psl_ctx_t *psl, const char *hostname, const char *cookie_domain); /* returns the longest not registrable domain within 'domain' or NULL if none found */ const char * psl_unregistrable_domain(const psl_ctx_t *psl, const char *domain); /* returns the shortest possible registrable domain part or NULL if domain is not registrable at all */ const char * psl_registrable_domain(const psl_ctx_t *psl, const char *domain); /* convert a string into lowercase UTF-8 */ psl_error_t psl_str_to_utf8lower(const char *str, const char *encoding, const char *locale, char **lower); /* does not include exceptions */ int psl_suffix_count(const psl_ctx_t *psl); /* just counts exceptions */ int psl_suffix_exception_count(const psl_ctx_t *psl); /* just counts wildcards */ int psl_suffix_wildcard_count(const psl_ctx_t *psl); /* returns compilation time */ time_t psl_builtin_compile_time(void); /* returns mtime of PSL source file */ time_t psl_builtin_file_time(void); /* returns SHA1 checksum (hex-encoded, lowercase) of PSL source file */ const char * psl_builtin_sha1sum(void); /* returns file name of PSL source file */ const char * psl_builtin_filename(void); /* returns library version string */ const char * psl_get_version(void); /* checks library version number */ int psl_check_version_number(int version); /* returns wether the built-in data is outdated or not */ int psl_builtin_outdated(void); #ifdef __cplusplus } #endif #endif /* _LIBPSL_LIBPSL_H */ libpsl-libpsl-0.11.0/libpsl.pc.in000066400000000000000000000003611260052016400165530ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE_NAME@ Description: Publix Suffix List C library. Version: @PACKAGE_VERSION@ URL: @PACKAGE_URL@ Libs: -L${libdir} -lpsl Cflags: -I${includedir} libpsl-libpsl-0.11.0/list/000077500000000000000000000000001260052016400153105ustar00rootroot00000000000000libpsl-libpsl-0.11.0/po/000077500000000000000000000000001260052016400147535ustar00rootroot00000000000000libpsl-libpsl-0.11.0/po/Makevars000066400000000000000000000044521260052016400164540ustar00rootroot00000000000000# Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. DOMAIN = $(PACKAGE) # These two variables depend on the location of this directory. subdir = po top_builddir = .. # These options get passed to xgettext. XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ # This is the copyright holder that gets inserted into the header of the # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding # package. (Note that the msgstr strings, extracted from the package's # sources, belong to the copyright holder of the package.) Translators are # expected to transfer the copyright for their translations to this person # or entity, or to disclaim their copyright. The empty string stands for # the public domain; in this case the translators are expected to disclaim # their copyright. COPYRIGHT_HOLDER = Tim Ruehsen # This is the email address or URL to which the translators shall report # bugs in the untranslated strings: # - Strings which are not entire sentences, see the maintainer guidelines # in the GNU gettext documentation, section 'Preparing Strings'. # - Strings which use unclear terms or require additional context to be # understood. # - Strings which make invalid assumptions about notation of date, time or # money. # - Pluralisation problems. # - Incorrect English spelling. # - Incorrect formatting. # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. MSGID_BUGS_ADDRESS = tim.ruehsen@gmx.de # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. EXTRA_LOCALE_CATEGORIES = # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' # context. Possible values are "yes" and "no". Set this to yes if the # package uses functions taking also a message context, like pgettext(), or # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. USE_MSGCTXT = no # These options get passed to msgmerge. # Useful options are in particular: # --previous to keep previous msgids of translated messages, # --quiet to reduce the verbosity. MSGMERGE_OPTIONS = libpsl-libpsl-0.11.0/po/POTFILES.in000066400000000000000000000001051260052016400165240ustar00rootroot00000000000000# List of source files which contain translatable strings. src/psl.c libpsl-libpsl-0.11.0/src/000077500000000000000000000000001260052016400151245ustar00rootroot00000000000000libpsl-libpsl-0.11.0/src/Makefile.am000066400000000000000000000017571260052016400171720ustar00rootroot00000000000000# suffixes.c must be created before psl.c is compiled BUILT_SOURCES = suffixes.c # suffixes.c is a built source that must be cleaned CLEANFILES = suffixes.c lib_LTLIBRARIES = libpsl.la libpsl_la_SOURCES = psl.c libpsl_la_CPPFLAGS = -I$(top_srcdir)/include # include ABI version information libpsl_la_LDFLAGS = -version-info $(LIBPSL_SO_VERSION) if WITH_LIBICU libpsl_la_LDFLAGS += -licuuc endif if WITH_LIBIDN2 libpsl_la_LDFLAGS += -lidn2 -lunistring endif if WITH_LIBIDN libpsl_la_LDFLAGS += -lidn -lunistring endif noinst_PROGRAMS = psl2c psl2c_SOURCES = psl2c.c psl2c_CPPFLAGS = -I$(top_srcdir)/include if BUILTIN_GENERATOR_LIBICU psl2c_LDADD = -licuuc endif if BUILTIN_GENERATOR_LIBIDN2 psl2c_LDADD = @LTLIBICONV@ -lidn2 -lunistring endif if BUILTIN_GENERATOR_LIBIDN psl2c_LDADD = @LTLIBICONV@ -lidn -lunistring endif # Build rule for suffix.c # PSL_FILE can be set by ./configure --with-psl-file=[PATH] suffixes.c: $(PSL_FILE) psl2c$(EXEEXT) ./psl2c$(EXEEXT) "$(PSL_FILE)" suffixes.c libpsl-libpsl-0.11.0/src/psl.c000066400000000000000000001017421260052016400160730ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of libpsl. * * Public Suffix List routines * * Changelog * 19.03.2014 Tim Ruehsen created from libmget/cookie.c * */ #if HAVE_CONFIG_H # include #endif /* if this file is included by psl2c, redefine to use requested library for builtin data */ #ifdef _LIBPSL_INCLUDED_BY_PSL2C # undef WITH_LIBICU # undef WITH_LIBIDN2 # undef WITH_LIBIDN # ifdef BUILTIN_GENERATOR_LIBICU # define WITH_LIBICU # elif defined(BUILTIN_GENERATOR_LIBIDN2) # define WITH_LIBIDN2 # elif defined(BUILTIN_GENERATOR_LIBIDN) # define WITH_LIBIDN # endif #endif #if ENABLE_NLS != 0 # include # define _(STRING) gettext(STRING) #else # define _(STRING) STRING # define ngettext(STRING1,STRING2,N) STRING2 #endif #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #ifdef WITH_LIBICU # include # include # include # include #elif defined(WITH_LIBIDN2) # include # include # include # include #elif defined(WITH_LIBIDN) # include # include # include # include # include #endif #include #include /* number of elements within an array */ #define countof(a) (sizeof(a)/sizeof(*(a))) #ifndef HAVE_STRNDUP /* I found no strndup on my old SUSE 7.3 test system (gcc 2.95) */ static char *strndup(const char *s, size_t n) { char *dst; size_t s_len = strlen(s); if (s_len > n) n = s_len; dst = malloc(n + 1); if (dst) { memcpy(dst, s, n); dst[n] = 0; } return dst; } #endif /** * SECTION:libpsl * @short_description: Public Suffix List library functions * @title: libpsl * @stability: Stable * @include: libpsl.h * * [Public Suffix List](http://publicsuffix.org/) library functions. * */ #define countof(a) (sizeof(a)/sizeof(*(a))) #define _PSL_FLAG_PLAIN (1<<0) #define _PSL_FLAG_EXCEPTION (1<<1) #define _PSL_FLAG_WILDCARD (1<<2) typedef struct { char label_buf[48]; const char * label; unsigned short length; unsigned char nlabels, /* number of labels */ flags; } _psl_entry_t; /* stripped down version libmget vector routines */ typedef struct { int (*cmp)(const _psl_entry_t **, const _psl_entry_t **); /* comparison function */ _psl_entry_t **entry; /* pointer to array of pointers to elements */ int max, /* allocated elements */ cur; /* number of elements in use */ } _psl_vector_t; struct _psl_ctx_st { _psl_vector_t *suffixes; int nsuffixes, nexceptions, nwildcards; }; /* include the PSL data compiled by 'psl2c' */ #ifndef _LIBPSL_INCLUDED_BY_PSL2C # include "suffixes.c" #else /* if this source file is included by psl2c.c, provide empty builtin data */ static _psl_entry_t suffixes[1]; static time_t _psl_file_time; static time_t _psl_compile_time; static int _psl_nsuffixes; static int _psl_nexceptions; static int _psl_nwildcards; static const char _psl_sha1_checksum[] = ""; static const char _psl_filename[] = ""; #endif /* references to this PSL will result in lookups to built-in data */ static const psl_ctx_t _builtin_psl; static _psl_vector_t *_vector_alloc(int max, int (*cmp)(const _psl_entry_t **, const _psl_entry_t **)) { _psl_vector_t *v; if (!(v = calloc(1, sizeof(_psl_vector_t)))) return NULL; if (!(v->entry = malloc(max * sizeof(_psl_entry_t *)))) { free(v); return NULL; } v->max = max; v->cmp = cmp; return v; } static void _vector_free(_psl_vector_t **v) { if (v && *v) { if ((*v)->entry) { int it; for (it = 0; it < (*v)->cur; it++) free((*v)->entry[it]); free((*v)->entry); } free(*v); } } static _psl_entry_t *_vector_get(const _psl_vector_t *v, int pos) { if (pos < 0 || !v || pos >= v->cur) return NULL; return v->entry[pos]; } /* the entries must be sorted by */ static int _vector_find(const _psl_vector_t *v, const _psl_entry_t *elem) { if (v) { int l, r, m; int res; /* binary search for element (exact match) */ for (l = 0, r = v->cur - 1; l <= r;) { m = (l + r) / 2; if ((res = v->cmp(&elem, (const _psl_entry_t **)&(v->entry[m]))) > 0) l = m + 1; else if (res < 0) r = m - 1; else return m; } } return -1; /* not found */ } static int _vector_add(_psl_vector_t *v, const _psl_entry_t *elem) { if (v) { void *elemp; elemp = malloc(sizeof(_psl_entry_t)); memcpy(elemp, elem, sizeof(_psl_entry_t)); if (v->max == v->cur) v->entry = realloc(v->entry, (v->max *= 2) * sizeof(_psl_entry_t *)); v->entry[v->cur++] = elemp; return v->cur - 1; } return -1; } static void _vector_sort(_psl_vector_t *v) { if (v && v->cmp) qsort(v->entry, v->cur, sizeof(_psl_vector_t **), (int(*)(const void *, const void *))v->cmp); } /* by this kind of sorting, we can easily see if a domain matches or not */ static int _suffix_compare(const _psl_entry_t *s1, const _psl_entry_t *s2) { int n; if ((n = s2->nlabels - s1->nlabels)) return n; /* most labels first */ if ((n = s1->length - s2->length)) return n; /* shorter rules first */ return strcmp(s1->label ? s1->label : s1->label_buf, s2->label ? s2->label : s2->label_buf); } /* needed to sort array of pointers, given to qsort() */ static int _suffix_compare_array(const _psl_entry_t **s1, const _psl_entry_t **s2) { return _suffix_compare(*s1, *s2); } static int _suffix_init(_psl_entry_t *suffix, const char *rule, size_t length) { const char *src; char *dst; suffix->label = suffix->label_buf; if (length >= sizeof(suffix->label_buf) - 1) { suffix->nlabels = 0; /* fprintf(stderr, _("Suffix rule too long (%zd, ignored): %s\n"), length, rule); */ return -1; } suffix->length = (unsigned char)length; suffix->nlabels = 1; for (dst = suffix->label_buf, src = rule; *src;) { if (*src == '.') suffix->nlabels++; *dst++ = *src++; } *dst = 0; return 0; } static int _psl_is_public_suffix(const psl_ctx_t *psl, const char *domain) { _psl_entry_t suffix, *rule; const char *p; /* this function should be called without leading dots, just make sure */ suffix.label = domain + (*domain == '.'); suffix.length = strlen(suffix.label); suffix.nlabels = 1; for (p = suffix.label; *p; p++) if (*p == '.') suffix.nlabels++; if (suffix.nlabels == 1) { /* TLD, this is the prevailing '*' match. * We don't currently support exception TLDs (TLDs that are not a public suffix) */ return 1; } /* if domain has enough labels, it is public */ if (psl == &_builtin_psl) rule = &suffixes[0]; else rule = _vector_get(psl->suffixes, 0); if (!rule || rule->nlabels < suffix.nlabels - 1) return 0; if (psl == &_builtin_psl) rule = bsearch(&suffix, suffixes, countof(suffixes), sizeof(suffixes[0]), (int(*)(const void *, const void *))_suffix_compare); else rule = _vector_get(psl->suffixes, _vector_find(psl->suffixes, &suffix)); if (rule) { /* definitely a match, no matter if the found rule is a wildcard or not */ if (rule->flags & _PSL_FLAG_EXCEPTION) return 0; if (rule->flags & _PSL_FLAG_PLAIN) return 1; } if ((suffix.label = strchr(suffix.label, '.'))) { int pos = rule - suffixes; suffix.label++; suffix.length = strlen(suffix.label); suffix.nlabels--; if (psl == &_builtin_psl) rule = bsearch(&suffix, suffixes, countof(suffixes), sizeof(suffixes[0]), (int(*)(const void *, const void *))_suffix_compare); else rule = _vector_get(psl->suffixes, (pos = _vector_find(psl->suffixes, &suffix))); if (rule) { if ((rule->flags & _PSL_FLAG_WILDCARD)) return 1; } } return 0; } /** * psl_is_public_suffix: * @psl: PSL context * @domain: Domain string * * This function checks if @domain is a public suffix by the means of the * [Mozilla Public Suffix List](http://publicsuffix.org). * * For cookie domain checking see psl_is_cookie_domain_acceptable(). * * International @domain names have to be either in lowercase UTF-8 or in ASCII form (punycode). * Other encodings result in unexpected behavior. * * @psl is a context returned by either psl_load_file(), psl_load_fp() or * psl_builtin(). * * Returns: 1 if domain is a public suffix, 0 if not. * * Since: 0.1 */ int psl_is_public_suffix(const psl_ctx_t *psl, const char *domain) { if (!psl || !domain) return 1; return _psl_is_public_suffix(psl, domain); } /** * psl_unregistrable_domain: * @psl: PSL context * @domain: Domain string * * This function finds the longest publix suffix part of @domain by the means * of the [Mozilla Public Suffix List](http://publicsuffix.org). * * International @domain names have to be either in lowercase UTF-8 or in ASCII form (punycode). * Other encodings result in unexpected behavior. * * @psl is a context returned by either psl_load_file(), psl_load_fp() or * psl_builtin(). * * Returns: Pointer to longest public suffix part of @domain or %NULL if @domain * does not contain a public suffix (or if @psl is %NULL). * * Since: 0.1 */ const char *psl_unregistrable_domain(const psl_ctx_t *psl, const char *domain) { if (!psl || !domain) return NULL; /* * We check from left to right to catch special PSL entries like 'forgot.his.name': * 'forgot.his.name' and 'name' are in the PSL while 'his.name' is not. */ while (!_psl_is_public_suffix(psl, domain)) { if ((domain = strchr(domain, '.'))) domain++; else break; /* prevent endless loop if psl_is_public_suffix() is broken. */ } return domain; } /** * psl_registrable_domain: * @psl: PSL context * @domain: Domain string * * This function finds the shortest private suffix part of @domain by the means * of the [Mozilla Public Suffix List](http://publicsuffix.org). * * International @domain names have to be either in lowercase UTF-8 or in ASCII form (punycode). * Other encodings result in unexpected behavior. * * @psl is a context returned by either psl_load_file(), psl_load_fp() or * psl_builtin(). * * Returns: Pointer to shortest private suffix part of @domain or %NULL if @domain * does not contain a private suffix (or if @psl is %NULL). * * Since: 0.1 */ const char *psl_registrable_domain(const psl_ctx_t *psl, const char *domain) { const char *p, *regdom = NULL; if (!psl || !domain || *domain == '.') return NULL; /* * We check from left to right to catch special PSL entries like 'forgot.his.name': * 'forgot.his.name' and 'name' are in the PSL while 'his.name' is not. */ while (!_psl_is_public_suffix(psl, domain)) { if ((p = strchr(domain, '.'))) { regdom = domain; domain = p + 1; } else break; /* prevent endless loop if psl_is_public_suffix() is broken. */ } return regdom; } static inline int _isspace_ascii(const char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } static int _str_is_ascii(const char *s) { while (*s && *((unsigned char *)s) < 128) s++; return !*s; } #if defined(WITH_LIBIDN) /* * Work around a libidn <= 1.30 vulnerability. * * The function checks for a valid UTF-8 character sequence before * passing it to idna_to_ascii_8z(). * * [1] http://lists.gnu.org/archive/html/help-libidn/2015-05/msg00002.html * [2] https://lists.gnu.org/archive/html/bug-wget/2015-06/msg00002.html * [3] http://curl.haxx.se/mail/lib-2015-06/0143.html */ static int _utf8_is_valid(const char *utf8) { const unsigned char *s = (const unsigned char *) utf8; while (*s) { if ((*s & 0x80) == 0) /* 0xxxxxxx ASCII char */ s++; else if ((*s & 0xE0) == 0xC0) /* 110xxxxx 10xxxxxx */ { if ((s[1] & 0xC0) != 0x80) return 0; s += 2; } else if ((*s & 0xF0) == 0xE0) /* 1110xxxx 10xxxxxx 10xxxxxx */ { if ((s[1] & 0xC0) != 0x80 || (s[2] & 0xC0) != 0x80) return 0; s += 3; } else if ((*s & 0xF8) == 0xF0) /* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ { if ((s[1] & 0xC0) != 0x80 || (s[2] & 0xC0) != 0x80 || (s[3] & 0xC0) != 0x80) return 0; s += 4; } else return 0; } return 1; } #endif #if defined(WITH_LIBICU) static void _add_punycode_if_needed(UIDNA *idna, _psl_vector_t *v, _psl_entry_t *e) { if (_str_is_ascii(e->label_buf)) return; /* IDNA2008 UTS#46 punycode conversion */ if (idna) { char lookupname[128] = ""; UErrorCode status = 0; UIDNAInfo info = UIDNA_INFO_INITIALIZER; UChar utf16_dst[128], utf16_src[128]; int32_t utf16_src_length; u_strFromUTF8(utf16_src, sizeof(utf16_src)/sizeof(utf16_src[0]), &utf16_src_length, e->label_buf, -1, &status); if (U_SUCCESS(status)) { int32_t dst_length = uidna_nameToASCII(idna, utf16_src, utf16_src_length, utf16_dst, sizeof(utf16_dst)/sizeof(utf16_dst[0]), &info, &status); if (U_SUCCESS(status)) { u_strToUTF8(lookupname, sizeof(lookupname), NULL, utf16_dst, dst_length, &status); if (U_SUCCESS(status)) { if (strcmp(e->label_buf, lookupname)) { _psl_entry_t suffix, *suffixp; /* fprintf(stderr, "libicu '%s' -> '%s'\n", e->label_buf, lookupname); */ _suffix_init(&suffix, lookupname, strlen(lookupname)); suffix.flags = e->flags; suffixp = _vector_get(v, _vector_add(v, &suffix)); suffixp->label = suffixp->label_buf; /* set label to changed address */ } /* else ignore */ } /* else fprintf(stderr, "Failed to convert UTF-16 to UTF-8 (status %d)\n", status); */ } /* else fprintf(stderr, "Failed to convert to ASCII (status %d)\n", status); */ } /* else fprintf(stderr, "Failed to convert UTF-8 to UTF-16 (status %d)\n", status); */ } } #elif defined(WITH_LIBIDN2) static void _add_punycode_if_needed(_psl_vector_t *v, _psl_entry_t *e) { char *lookupname = NULL; int rc; uint8_t *lower, resbuf[256]; size_t len = sizeof(resbuf) - 1; /* leave space for additional \0 byte */ if (_str_is_ascii(e->label_buf)) return; /* we need a conversion to lowercase */ lower = u8_tolower((uint8_t *)e->label_buf, u8_strlen((uint8_t *)e->label_buf), 0, UNINORM_NFKC, resbuf, &len); if (!lower) { /* fprintf(stderr, "u8_tolower(%s) failed (%d)\n", e->label_buf, errno); */ return; } /* u8_tolower() does not terminate the result string */ if (lower == resbuf) { lower[len]=0; } else { uint8_t *tmp = lower; lower = (uint8_t *)strndup((char *)lower, len); free(tmp); } if ((rc = idn2_lookup_u8(lower, (uint8_t **)&lookupname, 0)) == IDN2_OK) { if (strcmp(e->label_buf, lookupname)) { _psl_entry_t suffix, *suffixp; /* fprintf(stderr, "libidn '%s' -> '%s'\n", e->label_buf, lookupname); */ _suffix_init(&suffix, lookupname, strlen(lookupname)); suffix.flags = e->flags; suffixp = _vector_get(v, _vector_add(v, &suffix)); suffixp->label = suffixp->label_buf; /* set label to changed address */ } /* else ignore */ } /* else fprintf(stderr, "toASCII(%s) failed (%d): %s\n", lower, rc, idn2_strerror(rc)); */ if (lower != resbuf) free(lower); } #elif defined(WITH_LIBIDN) static void _add_punycode_if_needed(_psl_vector_t *v, _psl_entry_t *e) { char *lookupname = NULL; int rc; if (_str_is_ascii(e->label_buf)) return; if (!_utf8_is_valid(e->label_buf)) { /* fprintf(_(stderr, "Invalid UTF-8 sequence not converted: '%s'\n"), e->label_buf); */ return; } /* idna_to_ascii_8z() automatically converts UTF-8 to lowercase */ if ((rc = idna_to_ascii_8z(e->label_buf, &lookupname, IDNA_USE_STD3_ASCII_RULES)) == IDNA_SUCCESS) { if (strcmp(e->label_buf, lookupname)) { _psl_entry_t suffix, *suffixp; /* fprintf(stderr, "libidn '%s' -> '%s'\n", e->label_buf, lookupname); */ _suffix_init(&suffix, lookupname, strlen(lookupname)); suffix.flags = e->flags; suffixp = _vector_get(v, _vector_add(v, &suffix)); suffixp->label = suffixp->label_buf; /* set label to changed address */ } /* else ignore */ } /* else fprintf(_(stderr, "toASCII failed (%d): %s\n"), rc, idna_strerror(rc)); */ } #endif /** * psl_load_file: * @fname: Name of PSL file * * This function loads the public suffixes file named @fname. * To free the allocated resources, call psl_free(). * * The suffixes are expected to be lowercase UTF-8 encoded if they are international. * * Returns: Pointer to a PSL context or %NULL on failure. * * Since: 0.1 */ psl_ctx_t *psl_load_file(const char *fname) { FILE *fp; psl_ctx_t *psl = NULL; if (!fname) return NULL; if ((fp = fopen(fname, "r"))) { psl = psl_load_fp(fp); fclose(fp); } return psl; } /** * psl_load_fp: * @fp: FILE pointer * * This function loads the public suffixes from a FILE pointer. * To free the allocated resources, call psl_free(). * * The suffixes are expected to be lowercase UTF-8 encoded if they are international. * * Returns: Pointer to a PSL context or %NULL on failure. * * Since: 0.1 */ psl_ctx_t *psl_load_fp(FILE *fp) { psl_ctx_t *psl; _psl_entry_t suffix, *suffixp; char buf[256], *linep, *p; #ifdef WITH_LIBICU UIDNA *idna; UErrorCode status = 0; #endif if (!fp) return NULL; if (!(psl = calloc(1, sizeof(psl_ctx_t)))) return NULL; #ifdef WITH_LIBICU idna = uidna_openUTS46(UIDNA_USE_STD3_RULES, &status); #endif /* * as of 02.11.2012, the list at http://publicsuffix.org/list/ contains ~6000 rules and 40 exceptions. * as of 19.02.2014, the list at http://publicsuffix.org/list/ contains ~6500 rules and 19 exceptions. */ psl->suffixes = _vector_alloc(8*1024, _suffix_compare_array); while ((linep = fgets(buf, sizeof(buf), fp))) { while (_isspace_ascii(*linep)) linep++; /* ignore leading whitespace */ if (!*linep) continue; /* skip empty lines */ if (*linep == '/' && linep[1] == '/') continue; /* skip comments */ /* parse suffix rule */ for (p = linep; *linep && !_isspace_ascii(*linep);) linep++; *linep = 0; if (*p == '!') { p++; suffix.flags = _PSL_FLAG_EXCEPTION; psl->nexceptions++; } else if (*p == '*') { if (*++p != '.') { /* fprintf(stderr, _("Unsupported kind of rule (ignored): %s\n"), p - 1); */ continue; } p++; /* wildcard *.foo.bar implicitely make foo.bar a public suffix */ suffix.flags = _PSL_FLAG_WILDCARD | _PSL_FLAG_PLAIN; psl->nwildcards++; psl->nsuffixes++; } else { if (!strchr(p, '.')) continue; /* we do not need an explicit plain TLD rule, already covered by implicit '*' rule */ suffix.flags = _PSL_FLAG_PLAIN; psl->nsuffixes++; } if (_suffix_init(&suffix, p, linep - p) == 0) { int index; if ((index = _vector_find(psl->suffixes, &suffix)) >= 0) { /* Found existing entry: * Combination of exception and plain rule is ambigous * !foo.bar * foo.bar * * Allowed: * !foo.bar + *.foo.bar * foo.bar + *.foo.bar * * We do not check here, let's do it later. */ suffixp = _vector_get(psl->suffixes, index); suffixp->flags |= suffix.flags; } else { /* New entry */ suffixp = _vector_get(psl->suffixes, _vector_add(psl->suffixes, &suffix)); } suffixp->label = suffixp->label_buf; /* set label to changed address */ #ifdef WITH_LIBICU _add_punycode_if_needed(idna, psl->suffixes, suffixp); #elif defined(WITH_LIBIDN2) || defined(WITH_LIBIDN) _add_punycode_if_needed(psl->suffixes, suffixp); #endif } } _vector_sort(psl->suffixes); #ifdef WITH_LIBICU if (idna) uidna_close(idna); #endif return psl; } /** * psl_free: * @psl: PSL context pointer * * This function frees the the PSL context that has been retrieved via * psl_load_fp() or psl_load_file(). * * Since: 0.1 */ void psl_free(psl_ctx_t *psl) { if (psl && psl != &_builtin_psl) { _vector_free(&psl->suffixes); free(psl); } } /** * psl_builtin: * * This function returns the PSL context that has been generated and built in at compile-time. * You don't have to free the returned context explicitely. * * The builtin data also contains punycode entries, one for each international domain name. * * If the generation of built-in data has been disabled during compilation, %NULL will be returned. * So if using the builtin psl context, you can provide UTF-8 or punycode representations of domains to * functions like psl_is_public_suffix(). * * Returns: Pointer to the built in PSL data or NULL if this data is not available. * * Since: 0.1 */ const psl_ctx_t *psl_builtin(void) { #if defined(BUILTIN_GENERATOR_LIBICU) || defined(BUILTIN_GENERATOR_LIBIDN2) || defined(BUILTIN_GENERATOR_LIBIDN) return &_builtin_psl; #else return NULL; #endif } /** * psl_suffix_count: * @psl: PSL context pointer * * This function returns number of public suffixes maintained by @psl. * The number of exceptions within the Public Suffix List are not included. * * Returns: Number of public suffixes entries in PSL context. * * Since: 0.1 */ int psl_suffix_count(const psl_ctx_t *psl) { if (psl == &_builtin_psl) return _psl_nsuffixes; else if (psl) return psl->nsuffixes; else return 0; } /** * psl_suffix_exception_count: * @psl: PSL context pointer * * This function returns number of public suffix exceptions maintained by @psl. * * Returns: Number of public suffix exceptions in PSL context. * * Since: 0.1 */ int psl_suffix_exception_count(const psl_ctx_t *psl) { if (psl == &_builtin_psl) return _psl_nexceptions; else if (psl) return psl->nexceptions; else return 0; } /** * psl_suffix_wildcard_count: * @psl: PSL context pointer * * This function returns number of public suffix wildcards maintained by @psl. * * Returns: Number of public suffix wildcards in PSL context. * * Since: 0.10.0 */ int psl_suffix_wildcard_count(const psl_ctx_t *psl) { if (psl == &_builtin_psl) return _psl_nwildcards; else if (psl) return psl->nwildcards; else return 0; } /** * psl_builtin_compile_time: * * This function returns the time when the Publix Suffix List has been compiled into C code (by psl2c). * * If the generation of built-in data has been disabled during compilation, 0 will be returned. * * Returns: time_t value or 0. * * Since: 0.1 */ time_t psl_builtin_compile_time(void) { return _psl_compile_time; } /** * psl_builtin_file_time: * * This function returns the mtime of the Publix Suffix List file that has been built in. * * If the generation of built-in data has been disabled during compilation, 0 will be returned. * * Returns: time_t value or 0. * * Since: 0.1 */ time_t psl_builtin_file_time(void) { return _psl_file_time; } /** * psl_builtin_sha1sum: * * This function returns the SHA1 checksum of the Publix Suffix List file that has been built in. * The returned string is in lowercase hex encoding, e.g. "2af1e9e3044eda0678bb05949d7cca2f769901d8". * * If the generation of built-in data has been disabled during compilation, an empty string will be returned. * * Returns: String containing SHA1 checksum or an empty string. * * Since: 0.1 */ const char *psl_builtin_sha1sum(void) { return _psl_sha1_checksum; } /** * psl_builtin_filename: * * This function returns the file name of the Publix Suffix List file that has been built in. * * If the generation of built-in data has been disabled during compilation, an empty string will be returned. * * Returns: String containing the PSL file name or an empty string. * * Since: 0.1 */ const char *psl_builtin_filename(void) { return _psl_filename; } /** * psl_builtin_outdated: * * This function checks if the built-in data is older than the file it has been created from. * If it is, it might be a good idea for the application to reload the PSL. * The mtime is taken as reference. * * If the PSL file does not exist, it is assumed that the built-in data is not outdated. * * Returns: 1 if the built-in is outdated, 0 otherwise. * * Since: 0.10.0 */ int psl_builtin_outdated(void) { struct stat st; if (stat(_psl_filename, &st) == 0 && st.st_mtime > _psl_file_time) return 0; return 1; } /** * psl_get_version: * * Get libpsl version. * * Returns: String containing version of libpsl. * * Since: 0.2.5 **/ const char *psl_get_version(void) { #ifdef WITH_LIBICU return PACKAGE_VERSION " (+libicu/" U_ICU_VERSION ")"; #elif defined(WITH_LIBIDN2) return PACKAGE_VERSION " (+libidn2/" IDN2_VERSION ")"; #elif defined(WITH_LIBIDN) return PACKAGE_VERSION " (+libidn/" STRINGPREP_VERSION ")"; #else return PACKAGE_VERSION " (no IDNA support)"; #endif } /** * psl_check_version_number: * @version: Version number (hex) to check against. * * Check the given version number is at minimum the current library version number. * The version number must be a hexadecimal number like 0x000a01 (V0.10.1). * * Returns: Returns the library version number if the given version number is at least * the version of the library, else return 0; If the argument is 0, the function returns * the library version number without performing a check. * * Since: 0.11.0 **/ int psl_check_version_number(int version) { if (version) { int major = version >> 16; int minor = (version >> 8) & 0xFF; int patch = version & 0xFF; if (major < PSL_VERSION_MAJOR || (major == PSL_VERSION_MAJOR && minor < PSL_VERSION_MINOR) || (major == PSL_VERSION_MAJOR && minor == PSL_VERSION_MINOR && patch < PSL_VERSION_PATCH)) { return 0; } } return PSL_VERSION_NUMBER; } /* return whether hostname is an IP address or not */ static int _isip(const char *hostname) { struct in_addr addr; struct in6_addr addr6; return inet_pton(AF_INET, hostname, &addr) || inet_pton(AF_INET6, hostname, &addr6); } /** * psl_is_cookie_domain_acceptable: * @psl: PSL context pointer * @hostname: The request hostname. * @cookie_domain: The domain value from a cookie * * This helper function checks whether @cookie_domain is an acceptable cookie domain value for the request * @hostname. * * For international domain names both, @hostname and @cookie_domain, have to be either in lowercase UTF-8 * or in ASCII form (punycode). Other encodings or mixing UTF-8 and punycode result in unexpected behavior. * * Examples: * 1. Cookie domain 'example.com' would be acceptable for hostname 'www.example.com', * but '.com' or 'com' would NOT be acceptable since 'com' is a public suffix. * * 2. Cookie domain 'his.name' would be acceptable for hostname 'remember.his.name', * but NOT for 'forgot.his.name' since 'forgot.his.name' is a public suffix. * * Returns: 1 if acceptable, 0 if not acceptable. * * Since: 0.1 */ int psl_is_cookie_domain_acceptable(const psl_ctx_t *psl, const char *hostname, const char *cookie_domain) { const char *p; size_t hostname_length, cookie_domain_length; if (!psl || !hostname || !cookie_domain) return 0; while (*cookie_domain == '.') cookie_domain++; if (!strcmp(hostname, cookie_domain)) return 1; /* an exact match is acceptable (and pretty common) */ if (_isip(hostname)) return 0; /* Hostname is an IP address and these must match fully (RFC 6265, 5.1.3) */ cookie_domain_length = strlen(cookie_domain); hostname_length = strlen(hostname); if (cookie_domain_length >= hostname_length) return 0; /* cookie_domain is too long */ p = hostname + hostname_length - cookie_domain_length; if (!strcmp(p, cookie_domain) && p[-1] == '.') { /* OK, cookie_domain matches, but it must be longer than the longest public suffix in 'hostname' */ if (!(p = psl_unregistrable_domain(psl, hostname))) return 1; if (cookie_domain_length > strlen(p)) return 1; } return 0; } /** * psl_str_to_utf8lower: * @str: string to convert * @encoding: charset encoding of @str, e.g. 'iso-8859-1' or %NULL * @locale: locale of @str for to lowercase conversion, e.g. 'de' or %NULL * @lower: return value containing the converted string * * This helper function converts a string to lowercase UTF-8 representation. * Lowercase UTF-8 is needed as input to the domain checking functions. * * @lower is set to %NULL on error. * * The return value 'lower' must be freed after usage. * * Returns: psl_error_t value. * PSL_SUCCESS: Success * PSL_ERR_INVALID_ARG: @str is a %NULL value. * PSL_ERR_CONVERTER: Failed to open the unicode converter with name @encoding * PSL_ERR_TO_UTF16: Failed to convert @str to unicode * PSL_ERR_TO_LOWER: Failed to convert unicode to lowercase * PSL_ERR_TO_UTF8: Failed to convert unicode to UTF-8 * * Since: 0.4 */ psl_error_t psl_str_to_utf8lower(const char *str, const char *encoding, const char *locale, char **lower) { int ret = PSL_ERR_INVALID_ARG; if (lower) *lower = NULL; if (!str) return PSL_ERR_INVALID_ARG; /* shortcut to avoid costly conversion */ if (_str_is_ascii(str)) { if (lower) { char *p; *lower = strdup(str); /* convert ASCII string to lowercase */ for (p = *lower; *p; p++) if (isupper(*p)) *p = tolower(*p); } return PSL_SUCCESS; } #ifdef WITH_LIBICU do { size_t str_length = strlen(str); UErrorCode status = 0; UChar *utf16_dst, *utf16_lower; int32_t utf16_dst_length; char *utf8_lower; UConverter *uconv; /* C89 allocation */ utf16_dst = alloca(sizeof(UChar) * (str_length * 2 + 1)); utf16_lower = alloca(sizeof(UChar) * (str_length * 2 + 1)); utf8_lower = alloca(str_length * 2 + 1); uconv = ucnv_open(encoding, &status); if (U_SUCCESS(status)) { utf16_dst_length = ucnv_toUChars(uconv, utf16_dst, str_length * 2 + 1, str, str_length, &status); ucnv_close(uconv); if (U_SUCCESS(status)) { int32_t utf16_lower_length = u_strToLower(utf16_lower, str_length * 2 + 1, utf16_dst, utf16_dst_length, locale, &status); if (U_SUCCESS(status)) { u_strToUTF8(utf8_lower, str_length * 8 + 1, NULL, utf16_lower, utf16_lower_length, &status); if (U_SUCCESS(status)) { if (lower) *lower = strdup(utf8_lower); ret = PSL_SUCCESS; } else { ret = PSL_ERR_TO_UTF8; /* fprintf(stderr, "Failed to convert UTF-16 to UTF-8 (status %d)\n", status); */ } } else { ret = PSL_ERR_TO_LOWER; /* fprintf(stderr, "Failed to convert UTF-16 to lowercase (status %d)\n", status); */ } } else { ret = PSL_ERR_TO_UTF16; /* fprintf(stderr, "Failed to convert string to UTF-16 (status %d)\n", status); */ } } else { ret = PSL_ERR_CONVERTER; /* fprintf(stderr, "Failed to open converter for '%s' (status %d)\n", encoding, status); */ } } while (0); #elif defined(WITH_LIBIDN2) || defined(WITH_LIBIDN) do { /* find out local charset encoding */ if (!encoding) { encoding = nl_langinfo(CODESET); if (!encoding || !*encoding) encoding = "ASCII"; } /* convert to UTF-8 */ if (strcasecmp(encoding, "utf-8")) { iconv_t cd = iconv_open("utf-8", encoding); if (cd != (iconv_t)-1) { char *tmp = (char *)str; /* iconv won't change where str points to, but changes tmp itself */ size_t tmp_len = strlen(str); size_t dst_len = tmp_len * 6, dst_len_tmp = dst_len; char *dst = malloc(dst_len + 1), *dst_tmp = dst; if (iconv(cd, &tmp, &tmp_len, &dst_tmp, &dst_len_tmp) != (size_t)-1) { uint8_t *resbuf = malloc(dst_len * 2 + 1); size_t len = dst_len * 2; /* leave space for additional \0 byte */ if ((dst = (char *)u8_tolower((uint8_t *)dst, dst_len - dst_len_tmp, 0, UNINORM_NFKC, resbuf, &len))) { /* u8_tolower() does not terminate the result string */ if (lower) *lower = strndup((char *)dst, len); } else { ret = PSL_ERR_TO_LOWER; /* fprintf(stderr, "Failed to convert UTF-8 to lowercase (errno %d)\n", errno); */ } if (lower) *lower = strndup(dst, dst_len - dst_len_tmp); ret = PSL_SUCCESS; } else { ret = PSL_ERR_TO_UTF8; /* fprintf(stderr, "Failed to convert '%s' string into '%s' (%d)\n", src_encoding, dst_encoding, errno); */ } free(dst); iconv_close(cd); } else { ret = PSL_ERR_TO_UTF8; /* fprintf(stderr, "Failed to prepare encoding '%s' into '%s' (%d)\n", src_encoding, dst_encoding, errno); */ } } else ret = PSL_SUCCESS; /* convert to lowercase */ if (ret == PSL_SUCCESS) { uint8_t *dst, resbuf[256]; size_t len = sizeof(resbuf) - 1; /* leave space for additional \0 byte */ /* we need a conversion to lowercase */ if ((dst = u8_tolower((uint8_t *)str, u8_strlen((uint8_t *)str), 0, UNINORM_NFKC, resbuf, &len))) { /* u8_tolower() does not terminate the result string */ if (lower) *lower = strndup((char *)dst, len); } else { ret = PSL_ERR_TO_LOWER; /* fprintf(stderr, "Failed to convert UTF-8 to lowercase (errno %d)\n", errno); */ } } } while (0); #endif return ret; } libpsl-libpsl-0.11.0/src/psl2c.c000066400000000000000000000227441260052016400163240ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of libpsl. * * Precompile Public Suffix List into a C source file * * Changelog * 22.03.2014 Tim Ruehsen created * */ #if HAVE_CONFIG_H # include #endif #include #include #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #if defined(BUILTIN_GENERATOR_LIBICU) || defined(BUILTIN_GENERATOR_LIBIDN2) || defined(BUILTIN_GENERATOR_LIBIDN) # define _GENERATE_BUILTIN_DATA #endif #ifdef _GENERATE_BUILTIN_DATA #include /* here we include the library source code to have access to internal functions and data structures */ #define _LIBPSL_INCLUDED_BY_PSL2C # include "psl.c" #undef _LIBPSL_INCLUDED_BY_PSL2C #if 0 static int _check_psl(const psl_ctx_t *psl) { int it, pos, err = 0; /* check if plain suffix also appears in exceptions */ for (it = 0; it < psl->suffixes->cur; it++) { _psl_entry_t *e = _vector_get(psl->suffixes, it); if (!e->wildcard && _vector_find(psl->suffix_exceptions, e) >= 0) { fprintf(stderr, "Found entry '%s' also in exceptions\n", e->label); err = 1; } } /* check if exception also appears in suffix list as plain entry */ for (it = 0; it < psl->suffix_exceptions->cur; it++) { _psl_entry_t *e2, *e = _vector_get(psl->suffix_exceptions, it); if ((e2 = _vector_get(psl->suffixes, pos = _vector_find(psl->suffixes, e)))) { if (!e2->wildcard) { fprintf(stderr, "Found exception '!%s' also as suffix\n", e->label); err = 1; } /* Two same domains in a row are allowed: wildcard and non-wildcard. * Binary search find either of them, so also check previous and next entry. */ else if (pos > 0 && _suffix_compare(e, e2 = _vector_get(psl->suffixes, pos - 1)) == 0 && !e2->wildcard) { fprintf(stderr, "Found exception '!%s' also as suffix\n", e->label); err = 1; } else if (pos < psl->suffixes->cur - 1 && _suffix_compare(e, e2 = _vector_get(psl->suffixes, pos + 1)) == 0 && !e2->wildcard) { fprintf(stderr, "Found exception '!%s' also as suffix\n", e->label); err = 1; } } } /* check if non-wildcard entry is already covered by wildcard entry */ for (it = 0; it < psl->suffixes->cur; it++) { const char *p; _psl_entry_t *e = _vector_get(psl->suffixes, it); if (e->nlabels > 1 && !e->wildcard && (p = strchr(e->label, '.'))) { _psl_entry_t *e2, *e3, suffix; suffix.label = p + 1; suffix.length = strlen(p + 1); suffix.nlabels = e->nlabels - 1; e2 = _vector_get(psl->suffixes, pos = _vector_find(psl->suffixes, &suffix)); if (e2) { if (e2->wildcard) { fprintf(stderr, "Found superfluous '%s' already covered by '*.%s'\n", e->label, e2->label); err = 1; } /* Two same domains in a row are allowed: wildcard and non-wildcard. * Binary search find either of them, so also check previous and next entry. */ else if (pos > 0 && _suffix_compare(e2, e3 = _vector_get(psl->suffixes, pos - 1)) == 0 && e3->wildcard) { fprintf(stderr, "Found superfluous '%s' already covered by '*.%s'\n", e->label, e2->label); err = 1; } else if (pos < psl->suffixes->cur - 1 && _suffix_compare(e2, e3 = _vector_get(psl->suffixes, pos + 1)) == 0 && e3->wildcard) { fprintf(stderr, "Found superfluous '%s' already covered by '*.%s'\n", e->label, e2->label); err = 1; } } } } return err; } #endif static void _print_psl_entries(FILE *fpout, const _psl_vector_t *v, const char *varname) { int it; #ifdef BUILTIN_GENERATOR_LIBICU do { UVersionInfo version_info; char version[U_MAX_VERSION_STRING_LENGTH]; u_getVersion(version_info); u_versionToString(version_info, version); fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libicu/%s) */\n", version); } while (0); #elif defined(BUILTIN_GENERATOR_LIBIDN2) fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libidn2/%s) */\n", idn2_check_version(NULL)); #elif defined(BUILTIN_GENERATOR_LIBIDN) fprintf(fpout, "/* automatically generated by psl2c (punycode generated with libidn/%s) */\n", stringprep_check_version(NULL)); #else fprintf(fpout, "/* automatically generated by psl2c (without punycode support) */\n"); #endif fprintf(fpout, "static _psl_entry_t %s[] = {\n", varname); for (it = 0; it < v->cur; it++) { _psl_entry_t *e = _vector_get(v, it); fprintf(fpout, "\t{ \"%s\", NULL, %hd, %d, %d },\n", e->label_buf, e->length, (int) e->nlabels, (int) e->flags); } fprintf(fpout, "};\n"); } #if 0 #if !defined(WITH_LIBICU) && !defined(WITH_IDN2) static int _str_needs_encoding(const char *s) { while (*s && *((unsigned char *)s) < 128) s++; return !!*s; } static void _add_punycode_if_needed(_psl_vector_t *v) { int it, n; /* do not use 'it < v->cur' since v->cur is changed by _vector_add() ! */ for (it = 0, n = v->cur; it < n; it++) { _psl_entry_t *e = _vector_get(v, it); if (_str_needs_encoding(e->label_buf)) { _psl_entry_t suffix, *suffixp; char lookupname[64] = ""; /* this is much slower than the libidn2 API but should have no license issues */ FILE *pp; char cmd[16 + sizeof(e->label_buf)]; snprintf(cmd, sizeof(cmd), "idn2 '%s'", e->label_buf); if ((pp = popen(cmd, "r"))) { if (fscanf(pp, "%63s", lookupname) >= 1 && strcmp(e->label_buf, lookupname)) { /* fprintf(stderr, "idn2 '%s' -> '%s'\n", e->label_buf, lookupname); */ _suffix_init(&suffix, lookupname, strlen(lookupname)); suffix.wildcard = e->wildcard; suffixp = _vector_get(v, _vector_add(v, &suffix)); suffixp->label = suffixp->label_buf; /* set label to changed address */ } pclose(pp); } else fprintf(stderr, "Failed to call popen(%s, \"r\")\n", cmd); } } _vector_sort(v); } #endif /* !defined(WITH_LIBICU) && !defined(WITH_IDN2) */ #endif #endif /* _GENERATE_BUILTIN_DATA */ int main(int argc, const char **argv) { FILE *fpout; #ifdef _GENERATE_BUILTIN_DATA psl_ctx_t *psl; #endif int ret = 0; if (argc != 3) { fprintf(stderr, "Usage: psl2c \n"); fprintf(stderr, " is the 'public_suffix_list.dat', lowercase UTF-8 encoded\n"); fprintf(stderr, " is the the C filename to be generated from \n"); return 1; } #ifdef _GENERATE_BUILTIN_DATA if (!(psl = psl_load_file(argv[1]))) return 2; /* look for ambigious or double entries */ /* if (_check_psl(psl)) { psl_free(psl); return 5; } */ if ((fpout = fopen(argv[2], "w"))) { FILE *pp; struct stat st; size_t cmdsize = 16 + strlen(argv[1]); char *cmd = alloca(cmdsize), checksum[64] = ""; const char *source_date_epoch = NULL; #if 0 /* include library code did not generate punycode, so let's do it for the builtin data */ _add_punycode_if_needed(psl->suffixes); #endif _print_psl_entries(fpout, psl->suffixes, "suffixes"); snprintf(cmd, cmdsize, "sha1sum %s", argv[1]); if ((pp = popen(cmd, "r"))) { if (fscanf(pp, "%63[0-9a-zA-Z]", checksum) < 1) *checksum = 0; pclose(pp); } if (stat(argv[1], &st) != 0) st.st_mtime = 0; fprintf(fpout, "static time_t _psl_file_time = %lu;\n", st.st_mtime); if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH"))) fprintf(fpout, "static time_t _psl_compile_time = %lu;\n", atol(source_date_epoch)); else fprintf(fpout, "static time_t _psl_compile_time = %lu;\n", time(NULL)); fprintf(fpout, "static int _psl_nsuffixes = %d;\n", psl->nsuffixes); fprintf(fpout, "static int _psl_nexceptions = %d;\n", psl->nexceptions); fprintf(fpout, "static int _psl_nwildcards = %d;\n", psl->nwildcards); fprintf(fpout, "static const char _psl_sha1_checksum[] = \"%s\";\n", checksum); fprintf(fpout, "static const char _psl_filename[] = \"%s\";\n", argv[1]); if (fclose(fpout) != 0) ret = 4; } else { fprintf(stderr, "Failed to write open '%s'\n", argv[2]); ret = 3; } psl_free(psl); #else if ((fpout = fopen(argv[2], "w"))) { fprintf(fpout, "static _psl_entry_t suffixes[1];\n"); fprintf(fpout, "static time_t _psl_file_time;\n"); fprintf(fpout, "static time_t _psl_compile_time;\n"); fprintf(fpout, "static int _psl_nsuffixes = 0;\n"); fprintf(fpout, "static int _psl_nexceptions = 0;\n"); fprintf(fpout, "static int _psl_nwildcards = 0;\n"); fprintf(fpout, "static const char _psl_sha1_checksum[] = \"\";\n"); fprintf(fpout, "static const char _psl_filename[] = \"\";\n"); if (fclose(fpout) != 0) ret = 4; } else { fprintf(stderr, "Failed to write open '%s'\n", argv[2]); ret = 3; } #endif /* GENERATE_BUILTIN_DATA */ return ret; } libpsl-libpsl-0.11.0/tests/000077500000000000000000000000001260052016400154775ustar00rootroot00000000000000libpsl-libpsl-0.11.0/tests/Makefile.am000066400000000000000000000015731260052016400175410ustar00rootroot00000000000000DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\" -DPSL_FILE=\"$(PSL_FILE)\" -DPSL_TESTFILE=\"$(PSL_TESTFILE)\" AM_CPPFLAGS = -I$(top_srcdir)/include LDADD = ../src/libpsl.la # ./configure'd with '--disable-builtin' # Do not call test-is-public-builtin here: it does not make sense. # Do not call test-registrable-domain here: it would fail due to missing punycode entries in PSL file. PSL_TESTS = test-is-public test-is-public-all test-is-cookie-domain-acceptable if BUILTIN_GENERATOR_LIBICU PSL_TESTS += test-is-public-builtin test-registrable-domain endif if BUILTIN_GENERATOR_LIBIDN2 PSL_TESTS += test-is-public-builtin test-registrable-domain endif if BUILTIN_GENERATOR_LIBIDN PSL_TESTS += test-is-public-builtin test-registrable-domain endif check_PROGRAMS = $(PSL_TESTS) TESTS_ENVIRONMENT = TESTS_VALGRIND="@VALGRIND_ENVIRONMENT@" TESTS = $(PSL_TESTS) libpsl-libpsl-0.11.0/tests/test-is-cookie-domain-acceptable.c000066400000000000000000000102061260052016400240270ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of the test suite of libpsl. * * Test case for psl_is_cookie_doamin_acceptable() * * Changelog * 15.04.2014 Tim Ruehsen created from libmget/cookie.c * */ #if HAVE_CONFIG_H # include #endif #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #include #define countof(a) (sizeof(a)/sizeof(*(a))) static int ok, failed; static void test_psl(void) { static const struct test_data { const char *request_domain, *cookie_domain; int result; } test_data[] = { { "www.dkg.forgot.his.name", "www.dkg.forgot.his.name", 1 }, { "www.dkg.forgot.his.name", "dkg.forgot.his.name", 1 }, { "www.dkg.forgot.his.name", "forgot.his.name", 0 }, { "www.dkg.forgot.his.name", "his.name", 0 }, { "www.dkg.forgot.his.name", "name", 0 }, { "www.his.name", "www.his.name", 1 }, { "www.his.name", "his.name", 1 }, { "www.his.name", "name", 0 }, { "www.example.com", "www.example.com", 1 }, { "www.example.com", "example.com", 1 }, { "www.example.com", "com", 0 }, /* not accepted by normalization (PSL rule 'com') */ { "www.example.com", "example.org", 0 }, { "www.sa.gov.au", "sa.gov.au", 0 }, /* not accepted by normalization (PSL rule '*.ar') */ { "www.educ.ar", "educ.ar", 1 }, /* PSL exception rule '!educ.ar' */ /* RFC6265 5.1.3: Having IP addresses, request and domain IP must be identical */ { "192.1.123.2", ".1.123.2", 0 }, /* IPv4 address, partial match */ { "192.1.123.2", "192.1.123.2", 1 }, /* IPv4 address, full match */ { "::1", "::1", 1 }, /* IPv6 address, full match */ { "2a00:1450:4013:c01::8b", ":1450:4013:c01::8b", 0 }, /* IPv6 address, partial match */ { "::ffff:192.1.123.2", "::ffff:192.1.123.2", 1 }, /* IPv6 address dotted-quad, full match */ { "::ffff:192.1.123.2", ".1.123.2", 0 }, /* IPv6 address dotted-quad, partial match */ }; unsigned it; psl_ctx_t *psl; psl = psl_load_file(PSL_FILE); printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); for (it = 0; it < countof(test_data); it++) { const struct test_data *t = &test_data[it]; int result = psl_is_cookie_domain_acceptable(psl, t->request_domain, t->cookie_domain); if (result == t->result) { ok++; } else { failed++; printf("psl_is_cookie_domain_acceptable(%s, %s)=%d (expected %d)\n", t->request_domain, t->cookie_domain, result, t->result); } } psl_free(psl); } int main(int argc, const char * const *argv) { /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } printf("Summary: All %d tests passed\n", ok + failed); return 0; } libpsl-libpsl-0.11.0/tests/test-is-public-all.c000066400000000000000000000077541260052016400212720ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of the test suite of libpsl. * * Test psl_is_public_suffix() for all entries in public_suffix_list.dat * * Changelog * 19.03.2014 Tim Ruehsen created * */ #if HAVE_CONFIG_H # include #endif #include #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #include static int ok, failed; static inline int _isspace_ascii(const char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } static void test_psl(void) { FILE *fp; psl_ctx_t *psl; int result; char buf[256], *linep, *p; psl = psl_load_file(PSL_FILE); /* PSL_FILE can be set by ./configure --with-psl-file=[PATH] */ printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); if ((fp = fopen(PSL_FILE, "r"))) { while ((linep = fgets(buf, sizeof(buf), fp))) { while (_isspace_ascii(*linep)) linep++; /* ignore leading whitespace */ if (!*linep) continue; /* skip empty lines */ if (*linep == '/' && linep[1] == '/') continue; /* skip comments */ /* parse suffix rule */ for (p = linep; *linep && !_isspace_ascii(*linep);) linep++; *linep = 0; if (*p == '!') { /* an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) */ if ((result = psl_is_public_suffix(psl, p + 1))) { failed++; printf("psl_is_public_suffix(%s)=%d (expected 0)\n", p, result); } else ok++; if ((p = strchr(p, '.'))) { if (!(result = psl_is_public_suffix(psl, p + 1))) { failed++; printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p + 1, result); } else ok++; } } else if (*p == '*') { /* a wildcard, e.g. *.ck */ if (!(result = psl_is_public_suffix(psl, p + 1))) { failed++; printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p + 1, result); } else ok++; *p = 'x'; if (!(result = psl_is_public_suffix(psl, p))) { failed++; printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p, result); } else ok++; } else { if (!(result = psl_is_public_suffix(psl, p))) { failed++; printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p, result); } else ok++; } } fclose(fp); } else { printf("Failed to open %s\n", PSL_FILE); failed++; } psl_free(psl); } int main(int argc, const char * const *argv) { /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } printf("Summary: All %d tests passed\n", ok + failed); return 0; } libpsl-libpsl-0.11.0/tests/test-is-public-builtin.c000066400000000000000000000077261260052016400221670ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of the test suite of libpsl. * * Test case for psl built-in functions * * Changelog * 19.03.2014 Tim Ruehsen created from libmget/cookie.c * */ #if HAVE_CONFIG_H # include #endif #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #include #define countof(a) (sizeof(a)/sizeof(*(a))) static int ok, failed; static void test_psl(void) { /* punycode generation: idn ?? */ /* octal code generation: echo -n "??" | od -b */ static const struct test_data { const char *domain; int result; } test_data[] = { { "www.example.com", 0 }, { "com.ar", 1 }, { "www.com.ar", 0 }, { "cc.ar.us", 1 }, { ".cc.ar.us", 1 }, { "www.cc.ar.us", 0 }, { "www.ck", 0 }, /* exception from *.ck */ { "abc.www.ck", 0 }, { "xxx.ck", 1 }, { "www.xxx.ck", 0 }, { "\345\225\206\346\240\207", 1 }, /* xn--czr694b oder ?? */ { "www.\345\225\206\346\240\207", 0 }, { "xn--czr694b", 1 }, { "www.xn--czr694b", 0 }, /* some special test follow ('name' and 'forgot.his.name' are public, but e.g. his.name is not) */ { "name", 1 }, { ".name", 1 }, { "his.name", 0 }, { ".his.name", 0 }, { "forgot.his.name", 1 }, { ".forgot.his.name", 1 }, { "whoever.his.name", 0 }, { "whoever.forgot.his.name", 0 }, { ".", 1 }, /* special case */ { "", 1 }, /* special case */ { NULL, 1 }, /* special case */ { "adfhoweirh", 1 }, /* unknown TLD */ }; unsigned it; const psl_ctx_t *psl; psl = psl_builtin(); printf("have %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); for (it = 0; it < countof(test_data); it++) { const struct test_data *t = &test_data[it]; int result = psl_is_public_suffix(psl, t->domain); if (result == t->result) { ok++; } else { failed++; printf("psl_is_public_suffix(%s)=%d (expected %d)\n", t->domain, result, t->result); } } printf("psl_builtin_compile_time()=%ld\n", psl_builtin_compile_time()); psl_builtin_compile_time() == 0 ? failed++ : ok++; printf("psl_builtin_file_time()=%ld\n", psl_builtin_file_time()); psl_builtin_file_time() == 0 ? failed++ : ok++; printf("psl_builtin_sha1sum()=%s\n", psl_builtin_sha1sum()); *psl_builtin_sha1sum() == 0 ? failed++ : ok++; } int main(int argc, const char * const *argv) { /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } printf("Summary: All %d tests passed\n", ok + failed); return 0; } libpsl-libpsl-0.11.0/tests/test-is-public.c000066400000000000000000000071621260052016400205150ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of the test suite of libpsl. * * Test case for psl_load_file(), psl_is_public_suffix(), psl_free() * * Changelog * 19.03.2014 Tim Ruehsen created from libmget/cookie.c * */ #if HAVE_CONFIG_H # include #endif #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #include #define countof(a) (sizeof(a)/sizeof(*(a))) static int ok, failed; static void test_psl(void) { /* punycode generation: idn ?? */ /* octal code generation: echo -n "??" | od -b */ static const struct test_data { const char *domain; int result; } test_data[] = { { "www.example.com", 0 }, { "com.ar", 1 }, { "www.com.ar", 0 }, { "cc.ar.us", 1 }, { ".cc.ar.us", 1 }, { "www.cc.ar.us", 0 }, { "www.ck", 0 }, /* exception from *.ck */ { "abc.www.ck", 0 }, { "xxx.ck", 1 }, { "www.xxx.ck", 0 }, { "\345\225\206\346\240\207", 1 }, /* xn--czr694b or ?? */ { "www.\345\225\206\346\240\207", 0 }, /* some special test follow ('name' and 'forgot.his.name' are public, but e.g. his.name is not) */ { "name", 1 }, { ".name", 1 }, { "his.name", 0 }, { ".his.name", 0 }, { "forgot.his.name", 1 }, { ".forgot.his.name", 1 }, { "whoever.his.name", 0 }, { "whoever.forgot.his.name", 0 }, { ".", 1 }, /* special case */ { "", 1 }, /* special case */ { NULL, 1 }, /* special case */ { "adfhoweirh", 1 }, /* unknown TLD */ }; unsigned it; psl_ctx_t *psl; psl = psl_load_file(PSL_FILE); printf("loaded %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); for (it = 0; it < countof(test_data); it++) { const struct test_data *t = &test_data[it]; int result = psl_is_public_suffix(psl, t->domain); if (result == t->result) { ok++; } else { failed++; printf("psl_is_public_suffix(%s)=%d (expected %d)\n", t->domain, result, t->result); } } psl_free(psl); } int main(int argc, const char * const *argv) { /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } printf("Summary: All %d tests passed\n", ok + failed); return 0; } libpsl-libpsl-0.11.0/tests/test-registrable-domain.c000066400000000000000000000116241260052016400223740ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of the test suite of libpsl. * * Test psl_registered_domain() for all entries in test_psl.dat * * Changelog * 26.03.2014 Tim Ruehsen created * */ #if HAVE_CONFIG_H # include #endif #include #include #include #ifdef HAVE_ALLOCA_H # include #endif #ifdef WITH_LIBICU # include # include #endif #include static int ok, failed; static void test(const psl_ctx_t *psl, const char *domain, const char *expected_result) { const char *result; char *lower; /* our test data is fixed to UTF-8 (english), so provide it here */ if (psl_str_to_utf8lower(domain, "utf-8", "en", &lower) == PSL_SUCCESS) domain = lower; result = psl_registrable_domain(psl, domain); if ((result && expected_result && !strcmp(result, expected_result)) || (!result && !expected_result)) { ok++; } else { failed++; printf("psl_registrable_domain(%s)=%s (expected %s)\n", domain ? domain : "NULL", result ? result : "NULL", expected_result ? expected_result : "NULL"); } free(lower); } static void test_psl(void) { FILE *fp; const psl_ctx_t *psl; const char *p; char buf[256], domain[128], expected_regdom[128], semicolon[2]; int er_is_null, d_is_null; psl = psl_builtin(); printf("have %d suffixes and %d exceptions\n", psl_suffix_count(psl), psl_suffix_exception_count(psl)); /* special check with NULL values */ test(NULL, NULL, NULL); /* special check with NULL psl context */ test(NULL, "www.example.com", NULL); /* special check with NULL psl context and TLD */ test(NULL, "com", NULL); /* Norwegian with uppercase oe */ #ifdef WITH_LIBICU test(psl, "www.\303\230yer.no", "www.\303\270yer.no"); #endif /* Norwegian with lowercase oe */ test(psl, "www.\303\270yer.no", "www.\303\270yer.no"); /* special check with NULL psl context and TLD */ test(psl, "whoever.forgot.his.name", "whoever.forgot.his.name"); /* special check with NULL psl context and TLD */ test(psl, "forgot.his.name", NULL); /* special check with NULL psl context and TLD */ test(psl, "his.name", "his.name"); if ((fp = fopen(PSL_TESTFILE, "r"))) { while ((fgets(buf, sizeof(buf), fp))) { /* advance over ASCII white space */ for (p = buf; *p == ' ' || *p == '\t' || *p == '\r' || *p == '\n'; p++) ; if (!*p || (*p == '/' && p[1] == '/')) continue; /* ignore comments and blank lines */ er_is_null = 0; d_is_null = 0; if (sscanf(p, "checkPublicSuffix ( '%127[^']' , '%127[^']' ) %1[;]", domain, expected_regdom, semicolon) != 3) { if (sscanf(p, "checkPublicSuffix ( '%127[^']' , null ) %1[;]", domain, semicolon) == 2) { er_is_null = 1; } else if (sscanf(p, "checkPublicSuffix ( null , '%127[^']' ) %1[;]", expected_regdom, semicolon) == 2) { d_is_null = 1; } else if (sscanf(p, "checkPublicSuffix ( null , null ) %1[;]", semicolon) == 1) { d_is_null = 1; er_is_null = 1; } else { failed++; printf("Malformed line from '" PSL_TESTFILE "': %s", buf); continue; } } test(psl, d_is_null ? NULL : domain, er_is_null ? NULL : expected_regdom); } fclose(fp); } else { printf("Failed to open %s\n", PSL_TESTFILE); failed++; } } int main(int argc, const char * const *argv) { /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } printf("Summary: All %d tests passed\n", ok + failed); return 0; } libpsl-libpsl-0.11.0/tools/000077500000000000000000000000001260052016400154755ustar00rootroot00000000000000libpsl-libpsl-0.11.0/tools/Makefile.am000066400000000000000000000003231260052016400175270ustar00rootroot00000000000000bin_PROGRAMS = psl AM_CPPFLAGS = -I$(top_srcdir)/include LDADD = ../src/libpsl.la #if WITH_LIBICU # LDADD += -licuuc #endif #if WITH_LIBIDN2 # LDADD += -lidn2 #endif #if WITH_LIBIDN # LDADD += -lidn #endif libpsl-libpsl-0.11.0/tools/psl.c000066400000000000000000000164251260052016400164470ustar00rootroot00000000000000/* * Copyright(c) 2014-2015 Tim Ruehsen * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of libpsl. * * Using the libpsl functions via command line * * Changelog * 11.04.2014 Tim Ruehsen created * */ #if HAVE_CONFIG_H # include #endif #include #include #include #include #include static void usage(int err, FILE* f) { fprintf(f, "Usage: psl [options] \n"); fprintf(f, "\n"); fprintf(f, "Options:\n"); fprintf(f, " --version show library version information\n"); fprintf(f, " --use-builtin-data use the builtin PSL data [default]\n"); fprintf(f, " --load-psl-file load PSL data from file\n"); fprintf(f, " --is-public-suffix check if domains are public suffixes [default]\n"); fprintf(f, " --is-cookie-domain-acceptable \n"); fprintf(f, " check if cookie-domain is acceptable for domains\n"); fprintf(f, " --print-unreg-domain print the longest publix suffix part\n"); fprintf(f, " --print-reg-domain print the shortest private suffix part\n"); fprintf(f, " --print-info print info about library builtin data\n"); fprintf(f, "\n"); exit(err); } /* RFC 2822-compliant date format */ static const char *time2str(time_t t) { static char buf[64]; struct tm *tp = localtime(&t); strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", tp); return buf; } int main(int argc, const char *const *argv) { int mode = 1; const char *const *arg, *psl_file = NULL, *cookie_domain = NULL; psl_ctx_t *psl = (psl_ctx_t *) psl_builtin(); /* set current locale according to the environment variables */ #include setlocale(LC_ALL, ""); for (arg = argv + 1; arg < argv + argc; arg++) { if (!strncmp(*arg, "--", 2)) { if (!strcmp(*arg, "--is-public-suffix")) mode = 1; else if (!strcmp(*arg, "--print-unreg-domain")) mode = 2; else if (!strcmp(*arg, "--print-reg-domain")) mode = 3; else if (!strcmp(*arg, "--print-info")) mode = 99; else if (!strcmp(*arg, "--is-cookie-domain-acceptable") && arg < argv + argc - 1) { mode = 4; cookie_domain = *(++arg); } else if (!strcmp(*arg, "--use-builtin-data")) { psl_free(psl); if (psl_file) { fprintf(stderr, "Dropped data from %s\n", psl_file); psl_file = NULL; } if (!(psl = (psl_ctx_t *) psl_builtin())) printf("No builtin PSL data available\n"); } else if (!strcmp(*arg, "--load-psl-file") && arg < argv + argc - 1) { psl_free(psl); if (psl_file) { fprintf(stderr, "Dropped data from %s\n", psl_file); psl_file = NULL; } if (!(psl = psl_load_file(psl_file = *(++arg)))) { fprintf(stderr, "Failed to load PSL data from %s\n\n", psl_file); psl_file = NULL; } } else if (!strcmp(*arg, "--help")) { fprintf(stdout, "`psl' explores the Public Suffix List\n\n"); usage(0, stdout); } else if (!strcmp(*arg, "--version")) { printf("psl %s\n", PACKAGE_VERSION); printf("libpsl %s\n", psl_get_version()); printf("\n"); printf("Copyright (C) 2014-2015 Tim Ruehsen\n"); printf("License: MIT\n"); exit(0); } else if (!strcmp(*arg, "--")) { arg++; break; } else { fprintf(stderr, "Unknown option '%s'\n", *arg); usage(1, stderr); } } else break; } if (mode != 99) { if (!psl) { fprintf(stderr, "No PSL data available - aborting\n"); exit(2); } if (arg >= argv + argc) { char buf[256], *domain, *lower; size_t len; psl_error_t rc; /* read URLs from STDIN */ while (fgets(buf, sizeof(buf), stdin)) { for (domain = buf; isspace(*domain); domain++); /* skip leading spaces */ if (*domain == '#' || !*domain) continue; /* skip empty lines and comments */ for (len = strlen(domain); len && isspace(domain[len - 1]); len--); /* skip trailing spaces */ domain[len] = 0; if ((rc = psl_str_to_utf8lower(domain, NULL, NULL, &lower)) != PSL_SUCCESS) fprintf(stderr, "%s: Failed to convert to lowercase UTF-8 (%d)\n", domain, rc); else if (mode == 1) printf("%s: %d (%s)\n", domain, psl_is_public_suffix(psl, lower), lower); else if (mode == 2) printf("%s: %s\n", domain, psl_unregistrable_domain(psl, lower)); else if (mode == 3) printf("%s: %s\n", domain, psl_registrable_domain(psl, lower)); else if (mode == 4) { char *cookie_domain_lower; if ((rc = psl_str_to_utf8lower(domain, NULL, NULL, &cookie_domain_lower)) != PSL_SUCCESS) fprintf(stderr, "%s: Failed to convert cookie domain '%s' to lowercase UTF-8 (%d)\n", domain, cookie_domain, rc); else printf("%s: %d\n", domain, psl_is_cookie_domain_acceptable(psl, lower, cookie_domain)); free(cookie_domain_lower); } free(lower); } psl_free(psl); exit(0); } } if (mode == 1) { for (; arg < argv + argc; arg++) printf("%s: %d\n", *arg, psl_is_public_suffix(psl, *arg)); } else if (mode == 2) { for (; arg < argv + argc; arg++) printf("%s: %s\n", *arg, psl_unregistrable_domain(psl, *arg)); } else if (mode == 3) { for (; arg < argv + argc; arg++) printf("%s: %s\n", *arg, psl_registrable_domain(psl, *arg)); } else if (mode == 4) { for (; arg < argv + argc; arg++) printf("%s: %d\n", *arg, psl_is_cookie_domain_acceptable(psl, *arg, cookie_domain)); } else if (mode == 99) { if (psl && psl != psl_builtin()) { printf("suffixes: %d\n", psl_suffix_count(psl)); printf("exceptions: %d\n", psl_suffix_exception_count(psl)); printf("wildcards: %d\n", psl_suffix_wildcard_count(psl)); } psl_free(psl); psl = (psl_ctx_t *) psl_builtin(); if (psl) { printf("builtin suffixes: %d\n", psl_suffix_count(psl)); printf("builtin exceptions: %d\n", psl_suffix_exception_count(psl)); printf("builtin wildcards: %d\n", psl_suffix_wildcard_count(psl)); printf("builtin filename: %s\n", psl_builtin_filename()); printf("builtin compile time: %ld (%s)\n", psl_builtin_compile_time(), time2str(psl_builtin_compile_time())); printf("builtin file time: %ld (%s)\n", psl_builtin_file_time(), time2str(psl_builtin_file_time())); printf("builtin SHA1 file hash: %s\n", psl_builtin_sha1sum()); } else printf("No builtin PSL data available\n"); } psl_free(psl); return 0; }