mirror of
https://github.com/mirror/wget.git
synced 2026-08-19 17:33:28 +08:00
Compare commits
104 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f694b2ea24 | ||
|
|
d260ded060 | ||
|
|
70f7cdf1af | ||
|
|
351d328c07 | ||
|
|
3b6a3e84a0 | ||
|
|
fb23bc0611 | ||
|
|
cb358c0a84 | ||
|
|
12218d353b | ||
|
|
3832728138 | ||
|
|
38933de17c | ||
|
|
aed7d4163a | ||
|
|
42c15e47b4 | ||
|
|
c3835a425a | ||
|
|
8b2954e58a | ||
|
|
bba67890f3 | ||
|
|
0c9fb2b041 | ||
|
|
fbd9b9c16b | ||
|
|
1fd32c995c | ||
|
|
c289349684 | ||
|
|
1dec2028d0 | ||
|
|
7e85e9509e | ||
|
|
85dd2f7ce2 | ||
|
|
e1fc2057c7 | ||
|
|
eaf2fc9a4f | ||
|
|
e505664ef3 | ||
|
|
e6123ed645 | ||
|
|
5137cff125 | ||
|
|
42c78fdd71 | ||
|
|
a7df7ecc2f | ||
|
|
695f11304b | ||
|
|
a12bd59111 | ||
|
|
ffb94036f2 | ||
|
|
92035dbabd | ||
|
|
c19d76c024 | ||
|
|
a300f1e47d | ||
|
|
72b2c58983 | ||
|
|
c52bbad9e4 | ||
|
|
44ba49b31f | ||
|
|
eee1589ef3 | ||
|
|
e9cc8b2f7c | ||
|
|
b8f036d16c | ||
|
|
91f0f99e9a | ||
|
|
c78caecbb4 | ||
|
|
8760123cee | ||
|
|
c9c0e4c641 | ||
|
|
9e0d87a248 | ||
|
|
6a2d67b583 | ||
|
|
49f6d0ded8 | ||
|
|
4df7703d62 | ||
|
|
7f43748544 | ||
|
|
9d35f87218 | ||
|
|
90896e3314 | ||
|
|
5ce9389384 | ||
|
|
099d8ee3da | ||
|
|
e976d4f3dc | ||
|
|
ccd369d5f2 | ||
|
|
027d9f385d | ||
|
|
83837b0606 | ||
|
|
ae80fd2ec7 | ||
|
|
277785fa2a | ||
|
|
52dd6da6e0 | ||
|
|
550457bcad | ||
|
|
8dc52c6eaa | ||
|
|
54fd8de415 | ||
|
|
81409cb9c8 | ||
|
|
0e6f1c2dac | ||
|
|
7df4b05f0b | ||
|
|
bc2891f307 | ||
|
|
6c30653a1a | ||
|
|
edbeaa0c4e | ||
|
|
e3b3ea5120 | ||
|
|
50238e49b9 | ||
|
|
6443581d72 | ||
|
|
3be7e0a53c | ||
|
|
b56a528aea | ||
|
|
dcf667fb57 | ||
|
|
a2c0835007 | ||
|
|
3ebbd84518 | ||
|
|
b60ff61b75 | ||
|
|
2c1e0326a3 | ||
|
|
359dd16760 | ||
|
|
1e229375aa | ||
|
|
4f09a3118f | ||
|
|
b1838bdfd1 | ||
|
|
98f843f3cc | ||
|
|
9e8d899a35 | ||
|
|
5dcb116087 | ||
|
|
242ddfc74e | ||
|
|
13c6e7832a | ||
|
|
22bd8011e8 | ||
|
|
fe401688a6 | ||
|
|
6e4c3ab999 | ||
|
|
022dbcb343 | ||
|
|
7c0270cdb5 | ||
|
|
67e6027ea1 | ||
|
|
e9845d2813 | ||
|
|
959e5d1e90 | ||
|
|
74f6cb8884 | ||
|
|
e2cb2fa2e3 | ||
|
|
b718128b4f | ||
|
|
798f554773 | ||
|
|
06fc1edb54 | ||
|
|
85b98d0834 | ||
|
|
4759cf099f |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "gnulib"]
|
||||
path = gnulib
|
||||
url = git://git.sv.gnu.org/gnulib.git
|
||||
41
ChangeLog
41
ChangeLog
@@ -1,3 +1,44 @@
|
||||
2013-12-22 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* gnulib: add git submodule.
|
||||
|
||||
2013-09-13 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* configure.ac: added a summary of build options
|
||||
fixed some indentations
|
||||
removed the unconditionally adding of libz with --with-ssl
|
||||
removed -lgcrypt and -lgpg-error for gnutls
|
||||
|
||||
2013-07-23 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* configure.ac: Remove AM_CONDITIONAL HAVE_NETTLE.
|
||||
Reported by: Darshit Shah <darnir@gmail.com>.
|
||||
|
||||
2013-07-13 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* configure.ac: check for libnettle when GNU TLS is used.
|
||||
|
||||
2013-05-17 Bykov Aleksey <gnfalex@rambler.ru>
|
||||
|
||||
* bootstrap: Add `mkostemp'
|
||||
|
||||
2012-10-07 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* configure.ac: Check for patchconf.
|
||||
|
||||
2012-09-23 Merinov Nikolay <kim.roader@gmail.com>
|
||||
|
||||
* m4/wget.m4 (WGET_FNMATCH): Add AC_LANG_SOURCE into
|
||||
AC_COMPILE_IFELSE in order to silence autoconf 2.68 warning.
|
||||
|
||||
2012-09-20 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* bootstrap: Update from gnulib.
|
||||
|
||||
2012-09-02 Nguyễn Thái Ngọc Duy <pclouds@gmail.com> (tiny change)
|
||||
|
||||
* po/POTFILES.in: Add more files.
|
||||
|
||||
2012-07-08 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* bootstrap: Update from gnulib.
|
||||
|
||||
32
NEWS
32
NEWS
@@ -6,6 +6,38 @@ See the end for copying conditions.
|
||||
|
||||
Please send GNU Wget bug reports to <bug-wget@gnu.org>.
|
||||
|
||||
* Changes in Wget 1.15
|
||||
|
||||
** Add support for --method.
|
||||
|
||||
** Add support for file names longer than MAX_FILE.
|
||||
|
||||
** Support FTP listing for the FTP Server on Windows Server 2008 R2.
|
||||
|
||||
** Fix a regression when -c and --content-disposition are used together.
|
||||
|
||||
** Support shorthand URLs in an input file.
|
||||
|
||||
** Fix -c with servers that don't specify a content-length.
|
||||
|
||||
** Add support for MD5-SESS
|
||||
|
||||
** Do not fail on non fatal GNU TLS alerts during handshake.
|
||||
|
||||
** Add support for --https-only. When used wget will follow only
|
||||
HTTPS links in recursive mode.
|
||||
|
||||
** Support Perfect-Forward Secrecy in --secure-protocol.
|
||||
|
||||
** Fix a problem with some IRI links that are not followed when contained in a
|
||||
HTML document.
|
||||
|
||||
** Support some FTP servers that return an empty list with "LIST -a".
|
||||
|
||||
** Specify Host with the HTTP CONNECT method.
|
||||
|
||||
** Use the correct HTTP method on a redirection.
|
||||
|
||||
* Changes in Wget 1.14
|
||||
|
||||
** Add support for content-on-error. It allows to store the HTTP
|
||||
|
||||
49
bootstrap
49
bootstrap
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2012-07-06.11; # UTC
|
||||
scriptversion=2012-07-19.14; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
@@ -77,15 +77,32 @@ Running without arguments will suffice in most cases.
|
||||
EOF
|
||||
}
|
||||
|
||||
warn()
|
||||
# warnf_ FORMAT-STRING ARG1...
|
||||
warnf_ ()
|
||||
{
|
||||
for i
|
||||
do
|
||||
echo "$i"
|
||||
done | sed -e "s/^/$me: /" >&2
|
||||
warnf_format_=$1
|
||||
shift
|
||||
nl='
|
||||
'
|
||||
case $* in
|
||||
*$nl*) me_=$(printf "$me"|tr "$nl|" '??')
|
||||
printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
|
||||
*) printf "$me: $warnf_format_" "$@" ;;
|
||||
esac >&2
|
||||
}
|
||||
|
||||
die() { warn "$@"; exit 1; }
|
||||
# warn_ WORD1...
|
||||
warn_ ()
|
||||
{
|
||||
# If IFS does not start with ' ', set it and emit the warning in a subshell.
|
||||
case $IFS in
|
||||
' '*) warnf_ '%s\n' "$*";;
|
||||
*) (IFS=' '; warn_ "$@");;
|
||||
esac
|
||||
}
|
||||
|
||||
# die WORD1...
|
||||
die() { warn_ "$@"; exit 1; }
|
||||
|
||||
# Configuration.
|
||||
|
||||
@@ -197,6 +214,8 @@ use_git=true
|
||||
# otherwise find the first of the NAMES that can be run (i.e.,
|
||||
# supports --version). If found, set ENVVAR to the program name,
|
||||
# die otherwise.
|
||||
#
|
||||
# FIXME: code duplication, see also gnu-web-doc-update.
|
||||
find_tool ()
|
||||
{
|
||||
find_tool_envvar=$1
|
||||
@@ -335,8 +354,7 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
|
||||
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
|
||||
>/dev/null && found_aux_dir=yes
|
||||
test $found_aux_dir = yes \
|
||||
|| die "expected line not found in configure.ac. Add the following:" \
|
||||
" AC_CONFIG_AUX_DIR([$build_aux])"
|
||||
|| die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
|
||||
|
||||
# If $build_aux doesn't exist, create it now, otherwise some bits
|
||||
# below will malfunction. If creating it, also mark it as ignored.
|
||||
@@ -442,7 +460,7 @@ check_versions() {
|
||||
automake-ng|aclocal-ng)
|
||||
app=${app%-ng}
|
||||
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
|
||||
warn "Error: '$app' not found or not from Automake-NG"
|
||||
warn_ "Error: '$app' not found or not from Automake-NG"
|
||||
ret=1
|
||||
continue
|
||||
} ;;
|
||||
@@ -452,20 +470,21 @@ check_versions() {
|
||||
# so we have to rely on $? rather than get_version.
|
||||
$app --version >/dev/null 2>&1
|
||||
if [ 126 -le $? ]; then
|
||||
warn "Error: '$app' not found"
|
||||
warn_ "Error: '$app' not found"
|
||||
ret=1
|
||||
fi
|
||||
else
|
||||
# Require app to produce a new enough version string.
|
||||
inst_ver=$(get_version $app)
|
||||
if [ ! "$inst_ver" ]; then
|
||||
warn "Error: '$app' not found"
|
||||
warn_ "Error: '$app' not found"
|
||||
ret=1
|
||||
else
|
||||
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
||||
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
||||
warn "Error: '$app' version == $inst_ver is too old" \
|
||||
" '$app' version >= $req_ver is required"
|
||||
warnf_ '%s\n' \
|
||||
"Error: '$app' version == $inst_ver is too old" \
|
||||
" '$app' version >= $req_ver is required"
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
@@ -761,7 +780,7 @@ version_controlled_file() {
|
||||
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
|
||||
grep '^/[^/]*/[0-9]' > /dev/null
|
||||
else
|
||||
warn "no version control for $file?"
|
||||
warn_ "no version control for $file?"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ maintainer-makefile
|
||||
mbtowc
|
||||
mkdir
|
||||
mkstemp
|
||||
mkostemp
|
||||
crypto/md5
|
||||
crypto/sha1
|
||||
pipe
|
||||
|
||||
166
configure.ac
166
configure.ac
@@ -198,7 +198,7 @@ dnl Checks for library functions.
|
||||
dnl
|
||||
AC_FUNC_MMAP
|
||||
AC_FUNC_FSEEKO
|
||||
AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48)
|
||||
AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48 pathconf)
|
||||
AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
|
||||
AC_CHECK_FUNCS(sleep symlink utime)
|
||||
|
||||
@@ -238,57 +238,54 @@ dnl Checks for libraries.
|
||||
dnl
|
||||
|
||||
AS_IF([test x"$with_zlib" != xno], [
|
||||
with_zlib=yes
|
||||
AC_CHECK_LIB(z, compress)
|
||||
])
|
||||
|
||||
AS_IF([test x"$with_ssl" = xopenssl], [
|
||||
dnl some versions of openssl use zlib compression
|
||||
AC_CHECK_LIB(z, compress)
|
||||
dnl As of this writing (OpenSSL 0.9.6), the libcrypto shared library
|
||||
dnl doesn't record its dependency on libdl, so we need to make sure
|
||||
dnl -ldl ends up in LIBS on systems that have it. Most OSes use
|
||||
dnl dlopen(), but HP-UX uses shl_load().
|
||||
AC_CHECK_LIB(dl, dlopen, [], [
|
||||
AC_CHECK_LIB(dl, shl_load)
|
||||
])
|
||||
|
||||
dnl As of this writing (OpenSSL 0.9.6), the libcrypto shared library
|
||||
dnl doesn't record its dependency on libdl, so we need to make sure
|
||||
dnl -ldl ends up in LIBS on systems that have it. Most OSes use
|
||||
dnl dlopen(), but HP-UX uses shl_load().
|
||||
AC_CHECK_LIB(dl, dlopen, [], [
|
||||
AC_CHECK_LIB(dl, shl_load)
|
||||
])
|
||||
|
||||
ssl_found=no
|
||||
case $host_os in
|
||||
*mingw32* )
|
||||
dnl prefer link to openssl dlls if possible. if not then fallback on static libs. if not then error
|
||||
ssl_found=no
|
||||
case $host_os in
|
||||
*mingw32* )
|
||||
dnl prefer link to openssl dlls if possible. if not then fallback on static libs. if not then error
|
||||
|
||||
AC_CHECK_LIB(eay32, EVP_MD_CTX_init)
|
||||
if test x"$ac_cv_lib_eay32_EVP_MD_CTX_init" != xno
|
||||
then
|
||||
AC_CHECK_LIB(ssl32, SSL_connect, [
|
||||
ssl_found=yes
|
||||
AC_MSG_NOTICE([Enabling support for SSL via OpenSSL (shared)])
|
||||
AC_LIBOBJ([openssl])
|
||||
LIBS="${LIBS} -lssl32"
|
||||
AC_DEFINE([HAVE_LIBSSL32], [1], [Define to 1 if you have the `ssl32' library (-lssl32).])
|
||||
],
|
||||
AC_MSG_ERROR([openssl not found: shared lib eay32 found but ssl32 not found]))
|
||||
AC_CHECK_LIB(eay32, EVP_MD_CTX_init)
|
||||
if test x"$ac_cv_lib_eay32_EVP_MD_CTX_init" != xno
|
||||
then
|
||||
AC_CHECK_LIB(ssl32, SSL_connect, [
|
||||
ssl_found=yes
|
||||
AC_MSG_NOTICE([Enabling support for SSL via OpenSSL (shared)])
|
||||
AC_LIBOBJ([openssl])
|
||||
LIBS="${LIBS} -lssl32"
|
||||
AC_DEFINE([HAVE_LIBSSL32], [1], [Define to 1 if you have the `ssl32' library (-lssl32).])
|
||||
],
|
||||
AC_MSG_ERROR([openssl not found: shared lib eay32 found but ssl32 not found]))
|
||||
|
||||
else
|
||||
LIBS+=' -lgdi32'
|
||||
dnl fallback and test static libs
|
||||
fi
|
||||
dnl add zdll lib as dep for above tests?
|
||||
;;
|
||||
esac
|
||||
else
|
||||
LIBS+=' -lgdi32'
|
||||
dnl fallback and test static libs
|
||||
fi
|
||||
dnl add zdll lib as dep for above tests?
|
||||
;;
|
||||
esac
|
||||
|
||||
AS_IF([test x$ssl_found != xyes],
|
||||
[
|
||||
dnl Now actually check for -lssl if it wasn't already found
|
||||
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto z], [
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/md4.h>
|
||||
#include <openssl/md5.h>
|
||||
AS_IF([test x$ssl_found != xyes], [
|
||||
dnl Now actually check for -lssl if it wasn't already found
|
||||
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/md4.h>
|
||||
#include <openssl/md5.h>
|
||||
], [SSL_library_init ()])
|
||||
if test x"$LIBSSL" != x
|
||||
then
|
||||
@@ -300,33 +297,30 @@ AS_IF([test x$ssl_found != xyes],
|
||||
then
|
||||
AC_MSG_ERROR([--with-ssl=openssl was given, but SSL is not available.])
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
], [
|
||||
# --with-ssl is not gnutls: check if it's no
|
||||
# --with-ssl is not openssl: check if it's no
|
||||
AS_IF([test x"$with_ssl" != xno], [
|
||||
dnl Now actually check for -lssl
|
||||
dnl default is -lgnutls
|
||||
with_ssl=gnutls
|
||||
|
||||
AC_CHECK_LIB(z, compress)
|
||||
AC_CHECK_LIB(gpg-error, gpg_err_init)
|
||||
AC_CHECK_LIB(gcrypt, gcry_control)
|
||||
|
||||
dnl Now actually check for -lssl
|
||||
AC_LIB_HAVE_LINKFLAGS([gnutls], [], [
|
||||
dnl Now actually check for -lgnutls
|
||||
AC_LIB_HAVE_LINKFLAGS([gnutls], [], [
|
||||
#include <gnutls/gnutls.h>
|
||||
], [gnutls_global_init()])
|
||||
if test x"$LIBGNUTLS" != x
|
||||
then
|
||||
ssl_found=yes
|
||||
AC_MSG_NOTICE([compiling in support for SSL via GnuTLS])
|
||||
AC_LIBOBJ([gnutls])
|
||||
LIBS="$LIBGNUTLS $LIBS"
|
||||
else
|
||||
AC_MSG_ERROR([--with-ssl was given, but GNUTLS is not available.])
|
||||
fi
|
||||
], [gnutls_global_init()])
|
||||
if test x"$LIBGNUTLS" != x
|
||||
then
|
||||
ssl_found=yes
|
||||
AC_MSG_NOTICE([compiling in support for SSL via GnuTLS])
|
||||
AC_LIBOBJ([gnutls])
|
||||
LIBS="$LIBGNUTLS $LIBS"
|
||||
else
|
||||
AC_MSG_ERROR([--with-ssl=gnutls was given, but GNUTLS is not available.])
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(gnutls_priority_set_direct)
|
||||
]) # endif: --with-ssl == no?
|
||||
AC_CHECK_FUNCS(gnutls_priority_set_direct)
|
||||
]) # endif: --with-ssl != no?
|
||||
]) # endif: --with-ssl == openssl?
|
||||
|
||||
dnl Enable NTLM if requested and if SSL is available.
|
||||
@@ -334,16 +328,33 @@ if test x"$LIBSSL" != x || test "$ac_cv_lib_ssl32_SSL_connect" = yes
|
||||
then
|
||||
if test x"$ENABLE_NTLM" != xno
|
||||
then
|
||||
ENABLE_NTLM=yes
|
||||
AC_DEFINE([ENABLE_NTLM], 1,
|
||||
[Define if you want the NTLM authorization support compiled in.])
|
||||
AC_LIBOBJ([http-ntlm])
|
||||
fi
|
||||
else
|
||||
dnl If SSL is unavailable and the user explicitly requested NTLM,
|
||||
dnl abort.
|
||||
if test x"$ENABLE_NTLM" = xyes
|
||||
AC_CHECK_LIB(nettle, nettle_md4_init, [HAVE_NETTLE=yes], [HAVE_NETTLE=no; AC_MSG_WARN(*** libnettle was not found. You will not be able to use NTLM)])
|
||||
|
||||
if test x"$HAVE_NETTLE" = xyes
|
||||
then
|
||||
AC_MSG_ERROR([NTLM authorization requested and OpenSSL not found; aborting])
|
||||
AC_SUBST(NETTLE_LIBS, "-lnettle")
|
||||
AC_DEFINE([HAVE_NETTLE], [1], [Use libnettle])
|
||||
if test x"$ENABLE_NTLM" != xno
|
||||
then
|
||||
ENABLE_NTLM=yes
|
||||
AC_DEFINE([ENABLE_NTLM], 1,
|
||||
[Define if you want the NTLM authorization support compiled in.])
|
||||
AC_LIBOBJ([http-ntlm])
|
||||
LIBS="$NETTLE_LIBS $LIBS"
|
||||
fi
|
||||
else
|
||||
dnl If SSL is unavailable and the user explicitly requested NTLM,
|
||||
dnl abort.
|
||||
if test x"$ENABLE_NTLM" = xyes
|
||||
then
|
||||
AC_MSG_ERROR([NTLM authorization requested and SSL not enabled; aborting])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -557,3 +568,20 @@ AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile util/Makefile
|
||||
lib/Makefile])
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
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
|
||||
SSL: $with_ssl
|
||||
Zlib: $with_zlib
|
||||
Digest: $ENABLE_DIGEST
|
||||
NTLM: $ENABLE_NTLM
|
||||
OPIE: $ENABLE_OPIE
|
||||
Debugging: $ENABLE_DEBUG
|
||||
])
|
||||
|
||||
@@ -1,3 +1,89 @@
|
||||
2013-12-29 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* wget.texi: Update to GFDL 1.3.
|
||||
|
||||
2013-12-22 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* sample.wgetrc: add links to the manual.
|
||||
|
||||
2013-10-06 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* wget.texi: add/explain quoting of wildcard patterns
|
||||
|
||||
2013-09-04 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* sample.wgetrc: added "secureprotocol" example
|
||||
* wget.texi (HTTPS (SSL/TLS) Options): Document PFS.
|
||||
|
||||
2013-08-23 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* sample.wgetrc: added "httpsonly" example
|
||||
|
||||
2013-08-22 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* wget.texi: added description for --https-only
|
||||
|
||||
2013-08-13 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* wget.texi (Download Options): Fix misspelling.
|
||||
|
||||
2013-07-09 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* wget.texi (Download Options): Add documentation for --backups.
|
||||
(Wgetrc Commands): Add documentation for backups.
|
||||
Reported by: Tomas Hozza <thozza@redhat.com>.
|
||||
|
||||
2013-07-11 Tomas Hozza <thozza@redhat.com>
|
||||
|
||||
* wget.texi: Document --regex-type and --preserve-permissions.
|
||||
|
||||
2013-06-17 Dave Reisner <dreisner@archlinux.org> (tiny change)
|
||||
|
||||
* texi2pod.pl: Fix formatting error that causes build to fail with
|
||||
Perl 5.18
|
||||
|
||||
2013-06-17 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* wget.texi (POST): Explain the new redirection rules.
|
||||
* wget.texi (Other HTTP Methods): Same.
|
||||
* wget.texi (body-data): Fix typo in description.
|
||||
|
||||
2013-05-10 Darshit Shah <darnir@gmail.com> (tiny change)
|
||||
|
||||
* wget.texi (No of tries): Fix typo to make it clear that --tries
|
||||
option sets number of tries not retries.
|
||||
Reported by: Hauke Hoffman <haukebjoernhoffman@googlemail.com>
|
||||
|
||||
2013-04-28 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* wget.texi (Types of Files...): Document --accept-regex,
|
||||
--reject-regex.
|
||||
Reported by: Tomas Hozza <thozza@redhat.com>.
|
||||
|
||||
2013-04-14 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* wget.texi (Download Options): Document "mega" dot style.
|
||||
|
||||
2013-04-05 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* doc/wget.texi: Fix ambiguous wording in --post-data section. Make it
|
||||
clear that wget does not check for the format of the post-data.
|
||||
* doc/wget.texi: Add documentation for --method, --body-data and
|
||||
--body-file.
|
||||
|
||||
2012-10-08 Stefano Lattarini <stefano.lattarini@gmail.com> (tiny change)
|
||||
|
||||
docs: fix errors and warnings with Texinfo 5
|
||||
Or rather, with the development version 4.13.90, which will
|
||||
eventually become Texinfo 5.0.
|
||||
* wget.texi: Use '@item' instead of '@itemx' in several places,
|
||||
as Texinfo 5 refuses to process an '@itemx' that is not preceded
|
||||
by an '@item'.
|
||||
|
||||
2012-08-28 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* doc/wget.texi: remove -nv from --report-speed
|
||||
|
||||
2012-08-04 mancha <mancha@mac.hush.com> (tiny change)
|
||||
|
||||
* wget.texi: Export ENVIRONMENT to the man page.
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
## You can use this file to change the default behaviour of wget or to
|
||||
## avoid having to type many many command-line options. This file does
|
||||
## not contain a comprehensive list of commands -- look at the manual
|
||||
## to find out what you can put into this file.
|
||||
## to find out what you can put into this file. You can find this here:
|
||||
## $ info wget.info 'Startup File'
|
||||
## Or online here:
|
||||
## https://www.gnu.org/software/wget/manual/wget.html#Startup-File
|
||||
##
|
||||
## Wget initialization file can reside in /usr/local/etc/wgetrc
|
||||
## (global, for all users) or $HOME/.wgetrc (for a single user).
|
||||
@@ -123,3 +126,9 @@
|
||||
|
||||
# Force the default remote server encoding
|
||||
#remoteencoding = UTF-8
|
||||
|
||||
# Turn on to prevent following non-HTTPS links when in recursive mode
|
||||
#httpsonly = off
|
||||
|
||||
# Tune HTTPS security (auto, SSLv2, SSLv3, TLSv1, PFS)
|
||||
#secureprotocol = auto
|
||||
|
||||
@@ -291,7 +291,7 @@ while(<$inf>) {
|
||||
if (defined $1) {
|
||||
my $thing = $1;
|
||||
if ($ic =~ /\@asis/) {
|
||||
$_ = "\n=item $thing\n";
|
||||
$_ = "\n=item C<$thing>\n";
|
||||
} else {
|
||||
# Entity escapes prevent munging by the <> processing below.
|
||||
$_ = "\n=item $ic\<$thing\>\n";
|
||||
|
||||
135
doc/wget.texi
135
doc/wget.texi
@@ -47,11 +47,11 @@ notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual).
|
||||
@end ignore
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
||||
copy of the license is included in the section entitled ``GNU Free
|
||||
Documentation License''.
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the section entitled
|
||||
``GNU Free Documentation License''.
|
||||
@c man end
|
||||
@end copying
|
||||
|
||||
@@ -479,8 +479,7 @@ Turn off verbose without being completely quiet (use @samp{-q} for
|
||||
that), which means that error messages and basic information still get
|
||||
printed.
|
||||
|
||||
@item -nv
|
||||
@itemx --report-speed=@var{type}
|
||||
@item --report-speed=@var{type}
|
||||
Output bandwidth as @var{type}. The only accepted value is @samp{bits}.
|
||||
|
||||
@cindex input-file
|
||||
@@ -551,10 +550,10 @@ IPs.
|
||||
|
||||
@cindex retries
|
||||
@cindex tries
|
||||
@cindex number of retries
|
||||
@cindex number of tries
|
||||
@item -t @var{number}
|
||||
@itemx --tries=@var{number}
|
||||
Set number of retries to @var{number}. Specify 0 or @samp{inf} for
|
||||
Set number of tries to @var{number}. Specify 0 or @samp{inf} for
|
||||
infinite retrying. The default is to retry 20 times, with the exception
|
||||
of fatal errors like ``connection refused'' or ``not found'' (404),
|
||||
which are not retried.
|
||||
@@ -631,6 +630,13 @@ Note that when @samp{-nc} is specified, files with the suffixes
|
||||
@samp{.html} or @samp{.htm} will be loaded from the local disk and
|
||||
parsed as if they had been retrieved from the Web.
|
||||
|
||||
@cindex backing up files
|
||||
@item --backups=@var{backups}
|
||||
Before (over)writing a file, back up an existing file by adding a
|
||||
@samp{.1} suffix (@samp{_1} on VMS) to the file name. Such backup
|
||||
files are rotated to @samp{.2}, @samp{.3}, and so on, up to
|
||||
@var{backups} (and lost beyond that).
|
||||
|
||||
@cindex continue retrieval
|
||||
@cindex incomplete downloads
|
||||
@cindex resume download
|
||||
@@ -716,9 +722,12 @@ different meaning to one dot. With the @code{default} style each dot
|
||||
represents 1K, there are ten dots in a cluster and 50 dots in a line.
|
||||
The @code{binary} style has a more ``computer''-like orientation---8K
|
||||
dots, 16-dots clusters and 48 dots per line (which makes for 384K
|
||||
lines). The @code{mega} style is suitable for downloading very large
|
||||
lines). The @code{mega} style is suitable for downloading large
|
||||
files---each dot represents 64K retrieved, there are eight dots in a
|
||||
cluster, and 48 dots on each line (so each line contains 3M).
|
||||
If @code{mega} is not enough then you can use the @code{giga}
|
||||
style---each dot represents 1M retrieved, there are eight dots in a
|
||||
cluster, and 32 dots on each line (so each line contains 32M).
|
||||
|
||||
Note that you can set the default style using the @code{progress}
|
||||
command in @file{.wgetrc}. That setting may be overridden from the
|
||||
@@ -733,7 +742,7 @@ Turn on time-stamping. @xref{Time-Stamping}, for details.
|
||||
@item --no-use-server-timestamps
|
||||
Don't set the local file's timestamp by the one on the server.
|
||||
|
||||
By default, when a file is downloaded, it's timestamps are set to
|
||||
By default, when a file is downloaded, its timestamps are set to
|
||||
match those from the remote file. This allows the use of
|
||||
@samp{--timestamping} on subsequent invocations of wget. However, it
|
||||
is sometimes useful to base the local file's timestamp on when it was
|
||||
@@ -876,7 +885,7 @@ recommendation to block many unrelated users from a web site due to the
|
||||
actions of one.
|
||||
|
||||
@cindex proxy
|
||||
@itemx --no-proxy
|
||||
@item --no-proxy
|
||||
Don't use proxies, even if the appropriate @code{*_proxy} environment
|
||||
variable is defined.
|
||||
|
||||
@@ -977,7 +986,7 @@ are outside the range of @sc{ascii} characters (that is, greater than
|
||||
whose encoding does not match the one used locally.
|
||||
|
||||
@cindex IPv6
|
||||
@itemx -4
|
||||
@item -4
|
||||
@itemx --inet4-only
|
||||
@itemx -6
|
||||
@itemx --inet6-only
|
||||
@@ -1458,6 +1467,11 @@ like everything else. Wget does not currently support
|
||||
@code{application/x-www-form-urlencoded}. Only one of
|
||||
@samp{--post-data} and @samp{--post-file} should be specified.
|
||||
|
||||
Please note that wget does not require the content to be of the form
|
||||
@code{key1=value1&key2=value2}, and neither does it test for it. Wget will
|
||||
simply transmit whatever data is provided to it. Most servers however expect
|
||||
the POST data to be in the above format when processing HTML Forms.
|
||||
|
||||
Please be aware that Wget needs to know the size of the POST data in
|
||||
advance. Therefore the argument to @code{--post-file} must be a regular
|
||||
file; specifying a FIFO or something like @file{/dev/stdin} won't work.
|
||||
@@ -1468,14 +1482,15 @@ use chunked unless it knows it's talking to an HTTP/1.1 server. And it
|
||||
can't know that until it receives a response, which in turn requires the
|
||||
request to have been completed -- a chicken-and-egg problem.
|
||||
|
||||
Note: if Wget is redirected after the POST request is completed, it
|
||||
will not send the POST data to the redirected URL. This is because
|
||||
URLs that process POST often respond with a redirection to a regular
|
||||
page, which does not desire or accept POST. It is not completely
|
||||
clear that this behavior is optimal; if it doesn't work out, it might
|
||||
be changed in the future.
|
||||
Note: As of version 1.15 if Wget is redirected after the POST request is
|
||||
completed, its behaviour will depend on the response code returned by the
|
||||
server. In case of a 301 Moved Permanently, 302 Moved Temporarily or
|
||||
307 Temporary Redirect, Wget will, in accordance with RFC2616, continue
|
||||
to send a POST request.
|
||||
In case a server wants the client to change the Request method upon
|
||||
redirection, it should send a 303 See Other response code.
|
||||
|
||||
This example shows how to log to a server using POST and then proceed to
|
||||
This example shows how to log in to a server using POST and then proceed to
|
||||
download the desired pages, presumably only accessible to authorized
|
||||
users:
|
||||
|
||||
@@ -1498,6 +1513,37 @@ them (and neither will browsers) and the @file{cookies.txt} file will
|
||||
be empty. In that case use @samp{--keep-session-cookies} along with
|
||||
@samp{--save-cookies} to force saving of session cookies.
|
||||
|
||||
@cindex Other HTTP Methods
|
||||
@item --method=@var{HTTP-Method}
|
||||
For the purpose of RESTful scripting, Wget allows sending of other HTTP Methods
|
||||
without the need to explicitly set them using @samp{--header=Header-Line}.
|
||||
Wget will use whatever string is passed to it after @samp{--method} as the HTTP
|
||||
Method to the server.
|
||||
|
||||
@item --body-data=@var{Data-String}
|
||||
@itemx --body-file=@var{Data-File}
|
||||
Must be set when additional data needs to be sent to the server along with the
|
||||
Method specified using @samp{--method}. @samp{--body-data} sends @var{string} as
|
||||
data, whereas @samp{--body-file} sends the contents of @var{file}. Other than that,
|
||||
they work in exactly the same way.
|
||||
|
||||
Currently, @samp{--body-file} is @emph{not} for transmitting files as a whole.
|
||||
Wget does not currently support @code{multipart/form-data} for transmitting data;
|
||||
only @code{application/x-www-form-urlencoded}. In the future, this may be changed
|
||||
so that wget sends the @samp{--body-file} as a complete file instead of sending its
|
||||
contents to the server. Please be aware that Wget needs to know the contents of
|
||||
BODY Data in advance, and hence the argument to @samp{--body-file} should be a
|
||||
regular file. See @samp{--post-file} for a more detailed explanation.
|
||||
Only one of @samp{--body-data} and @samp{--body-file} should be specified.
|
||||
|
||||
If Wget is redirected after the request is completed, Wget will
|
||||
suspend the current method and send a GET request till the redirection
|
||||
is completed. This is true for all redirection response codes except
|
||||
307 Temporary Redirect which is used to explicitly specify that the
|
||||
request method should @emph{not} change. Another exception is when
|
||||
the method is set to @code{POST}, in which case the redirection rules
|
||||
specified under @samp{--post-data} are followed.
|
||||
|
||||
@cindex Content-Disposition
|
||||
@item --content-disposition
|
||||
|
||||
@@ -1549,16 +1595,24 @@ without SSL support, none of these options are available.
|
||||
@cindex SSL protocol, choose
|
||||
@item --secure-protocol=@var{protocol}
|
||||
Choose the secure protocol to be used. Legal values are @samp{auto},
|
||||
@samp{SSLv2}, @samp{SSLv3}, and @samp{TLSv1}. If @samp{auto} is used,
|
||||
the SSL library is given the liberty of choosing the appropriate
|
||||
@samp{SSLv2}, @samp{SSLv3}, @samp{TLSv1} and @samp{PFS}. If @samp{auto}
|
||||
is used, the SSL library is given the liberty of choosing the appropriate
|
||||
protocol automatically, which is achieved by sending an SSLv2 greeting
|
||||
and announcing support for SSLv3 and TLSv1. This is the default.
|
||||
|
||||
Specifying @samp{SSLv2}, @samp{SSLv3}, or @samp{TLSv1} forces the use
|
||||
of the corresponding protocol. This is useful when talking to old and
|
||||
buggy SSL server implementations that make it hard for OpenSSL to
|
||||
choose the correct protocol version. Fortunately, such servers are
|
||||
quite rare.
|
||||
buggy SSL server implementations that make it hard for the underlying
|
||||
SSL library to choose the correct protocol version. Fortunately, such
|
||||
servers are quite rare.
|
||||
|
||||
Specifying @samp{PFS} enforces the use of the so-called Perfect Forward
|
||||
Security cipher suites. In short, PFS adds security by creating a one-time
|
||||
key for each SSL connection. It has a bit more CPU impact on client and server.
|
||||
We use known to be secure ciphers (e.g. no MD4) and the TLS protocol.
|
||||
|
||||
@item --https-only
|
||||
When in recursive mode, only HTTPS links are followed.
|
||||
|
||||
@cindex SSL certificate, check
|
||||
@item --no-check-certificate
|
||||
@@ -1777,6 +1831,10 @@ in some rare firewall configurations, active FTP actually works when
|
||||
passive FTP doesn't. If you suspect this to be the case, use this
|
||||
option, or set @code{passive_ftp=off} in your init file.
|
||||
|
||||
@cindex file permissions
|
||||
@item --preserve-permissions
|
||||
Preserve remote file permissions instead of permissions set by umask.
|
||||
|
||||
@cindex symbolic links, retrieving
|
||||
@item --retr-symlinks
|
||||
Usually, when retrieving @sc{ftp} directories recursively and a symbolic
|
||||
@@ -2013,6 +2071,17 @@ accept or reject (@pxref{Types of Files}). Note that if
|
||||
any of the wildcard characters, @samp{*}, @samp{?}, @samp{[} or
|
||||
@samp{]}, appear in an element of @var{acclist} or @var{rejlist},
|
||||
it will be treated as a pattern, rather than a suffix.
|
||||
In this case, you have to enclose the pattern into quotes to prevent
|
||||
your shell from expanding it, like in @samp{-A "*.mp3"} or @samp{-A '*.mp3'}.
|
||||
|
||||
@item --accept-regex @var{urlregex}
|
||||
@itemx --reject-regex @var{urlregex}
|
||||
Specify a regular expression to accept or reject the complete URL.
|
||||
|
||||
@item --regex-type @var{regextype}
|
||||
Specify the regular expression type. Possible types are @samp{posix} or
|
||||
@samp{pcre}. Note that to be able to use @samp{pcre} type, wget has to be
|
||||
compiled with libpcre support.
|
||||
|
||||
@item -D @var{domain-list}
|
||||
@itemx --domains=@var{domain-list}
|
||||
@@ -2061,8 +2130,10 @@ dedicated @samp{--page-requisites} option.
|
||||
Ignore case when matching files and directories. This influences the
|
||||
behavior of -R, -A, -I, and -X options, as well as globbing
|
||||
implemented when downloading from FTP sites. For example, with this
|
||||
option, @samp{-A *.txt} will match @samp{file1.txt}, but also
|
||||
option, @samp{-A "*.txt"} will match @samp{file1.txt}, but also
|
||||
@samp{file2.TXT}, @samp{file3.TxT}, and so on.
|
||||
The quotes in the example are to prevent the shell from expanding the
|
||||
pattern.
|
||||
|
||||
@item -H
|
||||
@itemx --span-hosts
|
||||
@@ -2830,9 +2901,11 @@ enables it).
|
||||
Enable/disable saving pre-converted files with the suffix
|
||||
@samp{.orig}---the same as @samp{-K} (which enables it).
|
||||
|
||||
@c @item backups = @var{number}
|
||||
@c #### Document me!
|
||||
@c
|
||||
@item backups = @var{number}
|
||||
Use up to @var{number} backups for a file. Backups are rotated by
|
||||
adding an incremental counter that starts at @samp{1}. The default is
|
||||
@samp{0}.
|
||||
|
||||
@item base = @var{string}
|
||||
Consider relative @sc{url}s in input files (specified via the
|
||||
@samp{input} command or the @samp{--input-file}/@samp{-i} option,
|
||||
@@ -3094,7 +3167,7 @@ display properly---the same as @samp{-p}.
|
||||
Change setting of passive @sc{ftp}, equivalent to the
|
||||
@samp{--passive-ftp} option.
|
||||
|
||||
@itemx password = @var{string}
|
||||
@item password = @var{string}
|
||||
Specify password @var{string} for both @sc{ftp} and @sc{http} file retrieval.
|
||||
This command can be overridden using the @samp{ftp_password} and
|
||||
@samp{http_password} command for @sc{ftp} and @sc{http} respectively.
|
||||
@@ -3605,7 +3678,7 @@ In addition to the environment variables, proxy location and settings
|
||||
may be specified from within Wget itself.
|
||||
|
||||
@table @samp
|
||||
@itemx --no-proxy
|
||||
@item --no-proxy
|
||||
@itemx proxy = on/off
|
||||
This option and the corresponding command may be used to suppress the
|
||||
use of proxy, even if the appropriate environment variables are set.
|
||||
@@ -4317,7 +4390,7 @@ subscribers of the Wget mailing list.
|
||||
@appendix Copying this manual
|
||||
|
||||
@menu
|
||||
* GNU Free Documentation License:: Licnse for copying this manual.
|
||||
* GNU Free Documentation License:: License for copying this manual.
|
||||
@end menu
|
||||
|
||||
@node GNU Free Documentation License, , Copying this manual, Copying this manual
|
||||
|
||||
1
gnulib
Submodule
1
gnulib
Submodule
Submodule gnulib added at 0ac90c5a98
@@ -51,8 +51,8 @@ dnl /usr/local/include (!), which GCC uses before /usr/include.
|
||||
|
||||
AC_DEFUN([WGET_FNMATCH], [
|
||||
AC_MSG_CHECKING([for working fnmatch.h])
|
||||
AC_COMPILE_IFELSE([#include <fnmatch.h>
|
||||
], [
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <fnmatch.h>
|
||||
])], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_WORKING_FNMATCH_H], 1,
|
||||
[Define if fnmatch.h can be included.])
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
|
||||
# Package source files
|
||||
lib/error.c
|
||||
lib/gai_strerror.c
|
||||
lib/getopt.c
|
||||
lib/quotearg.c
|
||||
lib/spawn-pipe.c
|
||||
lib/w32spawn.h
|
||||
lib/wait-process.c
|
||||
lib/xalloc-die.c
|
||||
src/connect.c
|
||||
src/convert.c
|
||||
@@ -32,3 +36,4 @@ src/retr.c
|
||||
src/spider.c
|
||||
src/url.c
|
||||
src/utils.c
|
||||
src/warc.c
|
||||
|
||||
454
src/ChangeLog
454
src/ChangeLog
@@ -1,3 +1,457 @@
|
||||
2014-01-05 Håkon Vågsether <hauk142@gmail.com> (tiny change)
|
||||
|
||||
* http.c (http_loop): Fix checking the URL length when filename is
|
||||
specified.
|
||||
|
||||
2013-12-29 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* init.c (home_dir): Remove useless 'if'.
|
||||
* warc.c (warc_start_new_file): Likewise.
|
||||
(warc_process_cdx_line): Likewise.
|
||||
(warc_write_response_record): Likewise.
|
||||
|
||||
2013-12-26 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_connect_wget): Fix connect timeout failure
|
||||
|
||||
2013-11-02 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* http.c (gethttp): Increase max header value length to 512.
|
||||
|
||||
2013-01-30 Pavel Mateja <pavel@netsafe.cz> (tiny change)
|
||||
|
||||
* http.c (gethttp): Specify "Host" for CONNECT method.
|
||||
|
||||
2013-10-30 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* http.c (skip_short_body): Remove assert which is always true.
|
||||
Reported by: David Binderman <dcb314@hotmail.com>
|
||||
|
||||
2013-10-17 Andrea Urbani <matfanjol@mail.com>
|
||||
|
||||
* ftp.c (getftp): force "LIST" or "LIST -a"
|
||||
according to the remote system type. If the remote
|
||||
system is not known, it tries, only the first time,
|
||||
"LIST -a", after "LIST" and decides which one to use.
|
||||
For more information look for "__LIST_A_EXPLANATION__"
|
||||
* ftp.h (enum ustype): New ustype enum.
|
||||
* ftp.h (ftp_syst): New enum ustype *unix_type parameter.
|
||||
* ftp.h (ftp_list): Removed enum stype rs parameter, added.
|
||||
bool avoid_list_a, bool avoid_list, bool *list_a_used
|
||||
parameters.
|
||||
* ftp.h (wget_ftp_fstatus): New AVOID_LIST_A, AVOID_LIST,
|
||||
LIST_AFTER_LIST_A_CHECK_DONE values.
|
||||
* ftp-basic.c (ftp_list): it handles the new avoid_list_a,
|
||||
avoid_list and list_a_used parameters.
|
||||
* ftp.h (ftp_syst): it stores information about the "215 UNIX"
|
||||
systems into the new unix_type parameter.
|
||||
|
||||
2013-10-26 Bykov Aleksey <gnfalex@rambler.ru>
|
||||
|
||||
* utils.c (match_tail): Fix cookies reject
|
||||
|
||||
* ftp-ls.c (ftp_parse_unix_ls): Fix parsing month name in uppercase
|
||||
|
||||
2013-09-09 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_connect_wget): changed checking of option "PFS"
|
||||
to be better prepared for some kinds of backports.
|
||||
Reported by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||
|
||||
2013-10-10 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* url.c (url_parse): Try to convert UTF-8 URLs to IDN.
|
||||
* html-url.c (append_url): Parse URLs specifying an IRI structure.
|
||||
|
||||
2013-09-13 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* recur.c (download_child_p): fix compile error when
|
||||
configured using --without-ssl.
|
||||
|
||||
2013-09-07 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_connect_wget): use gnutls_check_version()
|
||||
to check if option "PFS" is available
|
||||
Reported by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||
|
||||
2013-09-03 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* main.c: Add new value 'PFS' to --secure-protocol to
|
||||
enforce the so-called Perfect Forward Security.
|
||||
* init.c (cmd_spec_secure_protocol): added secure_protocol_pfs
|
||||
* openssl.c, gnutls.c, options.h: likewise
|
||||
|
||||
2013-08-22 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* main.c: Add new option --https-only.
|
||||
* options.h: Likewise.
|
||||
* recur.c (download_child_p): add check for HTTPS.
|
||||
|
||||
2013-08-09 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_init): Prevent CA files from being loaded twice
|
||||
if possible.
|
||||
* gnutls.c (ssl_check_certificate): Added some error messages
|
||||
* gnutls.c: Fixed some compiler warnings
|
||||
|
||||
2013-08-08 Will Dietz <w@wdtz.org> (tiny change):
|
||||
|
||||
* main.c (format_and_print_line): Wrap correctly long tokens.
|
||||
|
||||
2013-07-16 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* wget.h (err_t): Added new errors, ATTRMISSING and UNKNOWNATTR to
|
||||
handle missing attributes and Unknown attribute values respectively in
|
||||
HTTP Headers.
|
||||
* exits.c (get_status_for_err): ATTRMISSING is a Protocol Error while
|
||||
UNKNOWNATTR is a general error, presumably because of a feature that
|
||||
is not yet implemented.
|
||||
* http.c (gethttp): Call create_authorization_line () separately. In
|
||||
case the auth_err flag has been set with an error, handle it and exit.
|
||||
* http.c (create_authorization_line): Pass a pointer, auth_err to set
|
||||
the flag for different kinds of errors encountered.
|
||||
* http.c (http_loop): Handle the errors raised by the authentication
|
||||
handlers.
|
||||
* http.c (digest_authentication_encode): Pass pointer auth_err to set
|
||||
the error flags.
|
||||
Set qop to NULL in case the value of the qop / algorithm attribute is
|
||||
unknown to Wget. Set an appropriate error too.
|
||||
|
||||
2013-07-13 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* http.c (digest_authentication_encode): Fix a crash when the algorithm
|
||||
is not specified in the server response. Free dynamic memory used by
|
||||
the function when the function exits.
|
||||
* http-ntlm.c [HAVE_NETTLE]: Include <nettle/md4.h> and <nettle/des.h>.
|
||||
(setup_des_key) [HAVE_NETTLE]: New function to deal with
|
||||
libnettle.
|
||||
(calc_resp) [HAVE_NETTLE]: Add support for libnettle.
|
||||
(mkhash) [HAVE_NETTLE]: Likewise.
|
||||
Reported by: Tim Ruehsen <tim.ruehsen@gmx.de>.
|
||||
|
||||
2013-07-13 Steven M. Schweda <sms@antinode.info>
|
||||
|
||||
* warc.c (warc_tempfile): Fix a portability issue on VMS.
|
||||
|
||||
2013-07-10 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* http.c (read_response_body) [ALLOW_CLOBBER]: Move definition to..
|
||||
* options.h (struct options): Make `backups' an int.
|
||||
* url.h [ALLOW_CLOBBER]: .. Here. Do not clobber when backups are used.
|
||||
* url.c (url_file_name): Use the ALLOW_CLOBBER macro instead of
|
||||
repeating the code.
|
||||
|
||||
2013-07-08 Steven M. Schweda <sms@antinode.info>
|
||||
|
||||
* retr.c (rotate_backups): Support for VMS files.
|
||||
|
||||
2013-07-12 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* http.c (digest_authentication_encode): Set default value of
|
||||
`algorithm' to "MD5". Check if `qop' is not-NULL before access it.
|
||||
|
||||
2013-07-11 Karsten Hopp <karsten@redhat.com>
|
||||
|
||||
* openssl.c (struct openssl_read_args, struct scwt_context): New struct.
|
||||
(openssl_read, ssl_connect_with_timeout_callback): New function.
|
||||
(ssl_connect_wget): respect connect timeout.
|
||||
|
||||
2013-07-11 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_connect_wget): respect connect timeout.
|
||||
|
||||
2013-07-11 Tomas Hozza <thozza@redhat.com>
|
||||
|
||||
* ftp.c (ftp_loop): Use ftp_retrieve_glob() also in case
|
||||
--preserve-permissions was specified.
|
||||
|
||||
2013-03-20 Tomas Hozza <thozza@redhat.com>
|
||||
|
||||
* http.c (gethttp): Set "sock" to -1 if it's not and we have no
|
||||
persistent connection
|
||||
|
||||
2013-04-26 Tomas Hozza <thozza@redhat.com> (tiny change)
|
||||
|
||||
* log.c (redirect_output): Use DEFAULT_LOGFILE in diagnostic message
|
||||
when `logfile' is NULL.
|
||||
* utils.c (unique_create): Ensure `logfile' has always a value.
|
||||
|
||||
2013-06-26 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* http.c (gethttp): Reverse change by commit 90896 that prevented
|
||||
downloading response body data to non-GET Request methods.
|
||||
|
||||
2013-06-19 Ciprian Vieru <devel.php@gmail.com> (tiny change)
|
||||
|
||||
* html-url.c: Define TAG_TD, TAG_TH, TAG_VIDEO, TAG_AUDIO, TAG_SOURCE.
|
||||
(tag_url_attributes, known_tags): Likewise.
|
||||
|
||||
2013-06-22 Ángel González <keisial@gmail.com>
|
||||
|
||||
* init.c (cmd_string_uppercase): Rewrite function.
|
||||
|
||||
2013-06-19 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* connect.c (socket_ip_address): zero out ip address structure to
|
||||
avoid access to uninitialized values by inet_ntop().
|
||||
* ftp.c (ftp_loop_internal): fix segfault caused by warc_tmp NULL pointer.
|
||||
|
||||
2013-05-21 Ray Satiro <raysatiro@yahoo.com>
|
||||
|
||||
* url.c (url_file_name): Use MAX_PATH in Windows.
|
||||
|
||||
2013-06-13 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* http.c (gethttp): Follow RFC 2616 and httpbis specifications when
|
||||
handling redirections. Do not suspend the method on 301/302 redirects.
|
||||
(gethttp): If method if not GET, we do not intend to download
|
||||
anything.
|
||||
* main.c (main): Set spider mode when opt.method is HEAD. This will
|
||||
prevent Wget from downloading any file.
|
||||
* retr.c (SUSPEND_METHOD): Rename macro SUSPEND_POST_DATA to
|
||||
SUSPEND_METHOD to more accurately reflect its use. Similarly rename
|
||||
related variables.
|
||||
|
||||
2013-05-14 Bykov Aleksey <gnfalex@rambler.ru>
|
||||
|
||||
* warc.c (warc_tempfile): For fix "Could not open temporary WARC manifest
|
||||
file." issue in Win system force to use `mkostemp(filename, O_TEMPORARY)'
|
||||
instead of `mkstemp(filename)'. Thank to Angel Gonzalez for help.
|
||||
|
||||
2013-05-14 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* cookies.c (cookie_jar_load): Replaced read_whole_file() by getline().
|
||||
* init.c (run_wgetrc): Likewise.
|
||||
* netrc.c (parse_netrc): Likewise.
|
||||
* utils.c: Likewise.
|
||||
* ftp.c (getftp): Likewise.
|
||||
* ftp-ls.c (ftp_parse_unix_ls, ftp_parse_winnt_ls, ftp_parse_vms_ls): Likewise.
|
||||
* ftp-ls.c (clean_line): Accept the string length as parameter.
|
||||
* ftp-ls.c: Replaced indent tabs by spaces.
|
||||
* ftp.c: Likewise.
|
||||
* utils.c: Removed read_whole_file() definition.
|
||||
* netrc.c: Removed read_whole_file() definition for STANDALONE.
|
||||
* utils.h: Removed read_whole_file() declaration.
|
||||
|
||||
2013-05-09 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* utils.c (acceptable): use standard string functions instead of
|
||||
self-written code.
|
||||
(match_tail): Likewise.
|
||||
(suffix): Likewise.
|
||||
(has_wildcards_p): Likewise.
|
||||
(test_subdir_p): Fix some warnings.
|
||||
(test_dir_matches_p): Likewise.
|
||||
|
||||
2013-05-05 mancha <mancha1@hush.com> (tiny change)
|
||||
|
||||
* gnutls.c (ssl_connect_wget): Don't abort on non-fatal alerts
|
||||
received during handshake. For example, when connecting to servers
|
||||
using TSL-SNI that send warning-level unrecognized_name alerts.
|
||||
|
||||
2013-05-04 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* init.c (cmd_string_uppercase): Fix issue that cased invalid headers
|
||||
when converting to uppercase.
|
||||
|
||||
2013-05-01 Gijs van Tulder <gvtulder@gmail.com>
|
||||
|
||||
* retr.c (retrieve_url): New variable `saved_method'.
|
||||
(SUSPEND_POST_DATA): Save the method to `saved_method'.
|
||||
(RESTORE_POST_DATA): Restore the method from `saved_method'.
|
||||
|
||||
2013-05-01 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* init.c: Declare `cmd_string_uppercase'.
|
||||
(commands): Now `method' uses cmd_string_uppercase.
|
||||
(cmd_string_uppercase): New method
|
||||
* http.c (gethttp): Do not transform opt.method to uppercase.
|
||||
Reported by: Stefano Lattarini <stefano.lattarini@gmail.com>
|
||||
|
||||
2013-04-24 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* http.c (gethttp): Remove check for opt.post_data and
|
||||
opt.post_file_name.
|
||||
* main.c (main): Change location in code where --post-data and
|
||||
--post-file options are converted to --body-data --body-file.
|
||||
|
||||
2013-04-21 Gijs van Tulder <gvtulder@gmail.com>
|
||||
|
||||
* http.c: Copy opt.body_data to the WARC file, instead of
|
||||
opt.post_data (the old option).
|
||||
|
||||
2013-04-12 Gijs van Tulder <gvtulder@gmail.com>
|
||||
|
||||
* warc.c: Generate unique UUIDs for the manifest and the record
|
||||
holding the command-line arguments.
|
||||
Write the manifest to a "metadata" record to follow the WARC
|
||||
implementation guidelines.
|
||||
* warc.h: Declare new function warc_write_metadata_record.
|
||||
|
||||
2013-03-15 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* http.c (post_file): Rename function to body_file_send to more
|
||||
accurately reflect its use.
|
||||
* http.c (gethttp): Add support for --method, --body-data and
|
||||
--body-file
|
||||
* init.c (commands): Same.
|
||||
* options.h (options): Same.
|
||||
* main.c (option_data): Same.
|
||||
* main.c (print_help): Add --method command.
|
||||
* main.c (main): Make old --post-{data,file} commands aliases to
|
||||
--method.
|
||||
Add sanity checks for --method, --body-data and --body-file.
|
||||
* retr.c (SUSPEND_POST_DATA): Edit Macro Definition to use body_data.
|
||||
* retr.c (RESTORE_POST_DATA): Same.
|
||||
|
||||
2013-03-31 Gijs van Tulder <gvtulder@gmail.com>
|
||||
|
||||
* warc.c: Correctly write the field length in the skip length field
|
||||
of .warc.gz files. (Following the GZIP spec in RFC 1952.)
|
||||
|
||||
2013-03-12 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* http.c (gethttp): Make wget return FILEBADFILE error and abort if
|
||||
post-file does not exist.
|
||||
|
||||
* http.c (http_loop): Handle FILEBADFILE as a valid err.
|
||||
|
||||
* exits.c (get_status_for_err): Mark FILEBADFILE as an IO error.
|
||||
|
||||
2013-02-15 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* cookies.c (cookie_handle_set_cookie): Set cookie->discard_requested
|
||||
to true on domain mismatch.
|
||||
|
||||
2012-12-20 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_connect_wget): added +VERS-SSL3.0 to fix
|
||||
--secure-protocol=SSLv2/SSLv3.
|
||||
|
||||
2012-12-09 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* main.c (main): Keep looking for "config" until there are
|
||||
arguments to parse.
|
||||
Reported by: Adrien Dumont <adr.dum@hotmail.fr>
|
||||
|
||||
* test.c: Include "wget.h".
|
||||
|
||||
2012-12-08 Michael Stapelberg <michael@stapelberg.de> (tiny change)
|
||||
|
||||
* retr.c (retrieve_url): Set iri->orig_url to NULL after it is
|
||||
freed.
|
||||
|
||||
2012-11-26 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* wget.h (MAX_INT_TO_STRING_LEN): Define macro.
|
||||
* warc.c (warc_write_block_from_file): Use `MAX_INT_TO_STRING_LEN'
|
||||
to find the buffer size.
|
||||
(warc_write_cdx_record): Likewise.
|
||||
|
||||
2012-09-03 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* http.c (digest_authentication_encode): Add support for RFC 2617
|
||||
MD5-sess authentication algorithm.
|
||||
Feature request and testing by: Avinash <pavinash@gmail.com>
|
||||
|
||||
2012-11-14 Ángel González <keisial@gmail.com>
|
||||
|
||||
* warc.c (warc_sha1_stream_with_payload): Fix compilation under
|
||||
gcc -std=c89.
|
||||
|
||||
2012-11-24 Gijs van Tulder <gvtulder@gmail.com>
|
||||
|
||||
* warc.c (warc_write_cdx_record): Use `number_to_string' to
|
||||
convert the offset to a string.
|
||||
|
||||
2012-11-24 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* warc.c (warc_write_block_from_file): Use `number_to_string' to
|
||||
convert the content-length to a string.
|
||||
|
||||
2012-11-15 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* retr.c (write_data): Fix comment.
|
||||
|
||||
2012-11-13 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* retr.c (fd_read_body): Correctly check the return code from
|
||||
write_data.
|
||||
Reported by: Torsten Scheck <torsten.scheck@gmx.de>
|
||||
|
||||
2012-08-29 Rohit Mathulla <rohit_mathulla@yahoo.com> (tiny change)
|
||||
|
||||
* html-url.c (get_urls_file): Convert shorthand URLs.
|
||||
|
||||
2012-10-07 Ray Satiro <raysatiro@yahoo.com>
|
||||
|
||||
* url.c: Change the functions of a growable string object to null
|
||||
terminate the string.
|
||||
* url.c (append_null): New function to null terminate a growable
|
||||
string object.
|
||||
* url.c (shorten_length): New function to shorten the length of a
|
||||
growable string object.
|
||||
|
||||
2012-10-03 Merinov Nikolay <kim.roader@gmail.com>
|
||||
|
||||
* ftp.c (ftp_loop_internal): Ignore --no-clobber option when
|
||||
receiving directory listing.
|
||||
|
||||
2012-10-07 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* utils.c (get_max_length): If `pathconf' is not available
|
||||
fallback to PATH_MAX.
|
||||
|
||||
2012-10-06 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* http.c (http_loop): Send a HEAD request when -c and
|
||||
--content-disposition are used together.
|
||||
|
||||
2012-09-29 Merinov Nikolay <kim.roader@gmail.com>
|
||||
|
||||
* ftp-ls.c (ftp_parse_winnt_ls): Support filename extracting with
|
||||
new listing format.
|
||||
|
||||
2012-09-29 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* url.h (CHOMP_BUFFER): Add definition.
|
||||
* url.c (url_file_name): New local variables `fname_len_check' and
|
||||
`max_length'. Check that the length of the file name is acceptable.
|
||||
* utils.h (get_max_length): Declare function.
|
||||
* utils.c (get_max_length): New function.
|
||||
|
||||
2012-09-28 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
||||
* src/recur.c (retrieve_tree): Combine duplicated code.
|
||||
|
||||
2012-09-02 Nguyễn Thái Ngọc Duy <pclouds@gmail.com> (tiny change)
|
||||
|
||||
* src/main.c (main): mark more strings for translation.
|
||||
* src/mswindows.c (fork_to_background): Likewise.
|
||||
* src/recur.c (download_child_p): Likewise.
|
||||
|
||||
2012-08-28 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* gnutls.c (ssl_check_certificate): deinit gnutls_x509_crt_t.
|
||||
* gnutls.c (ssl_init): don't error if CA directory is empty.
|
||||
|
||||
2012-07-07 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* html-url.c (cleanup_html_url): Remove "static" modifier.
|
||||
* init.c (cleanup_html_url): Likewise.
|
||||
Reported by: Mike Frysinger <vapier@gentoo.org>.
|
||||
|
||||
2012-08-25 Hrvoje Niksic <hniksic@gmail.com>
|
||||
|
||||
* warc.c (warc_find_duplicate_cdx_record): Use hash_table_get
|
||||
instead of hash_table_get_pair.
|
||||
|
||||
2012-08-21 <y-iida@secom.co.jp> (tiny change)
|
||||
|
||||
* connect.c (connect_to_ip) [ENABLE_IPV6]: Attempt to use IPv6.
|
||||
* http.c (gethttp): Likewise.
|
||||
|
||||
2012-07-03 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
||||
* init.c: Include warc.h for warc_close in cleanup function.
|
||||
|
||||
@@ -294,8 +294,10 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
|
||||
{
|
||||
if (ip->family == AF_INET)
|
||||
logprintf (LOG_VERBOSE, _("Connecting to %s:%d... "), txt_addr, port);
|
||||
#ifdef ENABLE_IPV6
|
||||
else if (ip->family == AF_INET6)
|
||||
logprintf (LOG_VERBOSE, _("Connecting to [%s]:%d... "), txt_addr, port);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,6 +559,7 @@ socket_ip_address (int sock, ip_address *ip, int endpoint)
|
||||
if (ret < 0)
|
||||
return false;
|
||||
|
||||
memset(ip, 0, sizeof(ip_address));
|
||||
ip->family = sockaddr->sa_family;
|
||||
switch (sockaddr->sa_family)
|
||||
{
|
||||
|
||||
@@ -673,9 +673,6 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
|
||||
|
||||
if (!cookie->domain)
|
||||
{
|
||||
copy_domain:
|
||||
/* If the domain was not provided, we use the one we're talking
|
||||
to, and set exact match. */
|
||||
cookie->domain = xstrdup (host);
|
||||
cookie->domain_exact = 1;
|
||||
/* Set the port, but only if it's non-default. */
|
||||
@@ -687,11 +684,12 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
|
||||
if (!check_domain_match (cookie->domain, host))
|
||||
{
|
||||
logprintf (LOG_NOTQUIET,
|
||||
_("Cookie coming from %s attempted to set domain to %s\n"),
|
||||
quotearg_style (escape_quoting_style, host),
|
||||
_("Cookie coming from %s attempted to set domain to "),
|
||||
quotearg_style (escape_quoting_style, host));
|
||||
logprintf (LOG_NOTQUIET,
|
||||
_("%s\n"),
|
||||
quotearg_style (escape_quoting_style, cookie->domain));
|
||||
xfree (cookie->domain);
|
||||
goto copy_domain;
|
||||
cookie->discard_requested = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1131,7 +1129,9 @@ domain_port (const char *domain_b, const char *domain_e,
|
||||
void
|
||||
cookie_jar_load (struct cookie_jar *jar, const char *file)
|
||||
{
|
||||
char *line;
|
||||
char *line = NULL;
|
||||
size_t bufsize = 0;
|
||||
|
||||
FILE *fp = fopen (file, "r");
|
||||
if (!fp)
|
||||
{
|
||||
@@ -1139,9 +1139,10 @@ cookie_jar_load (struct cookie_jar *jar, const char *file)
|
||||
quote (file), strerror (errno));
|
||||
return;
|
||||
}
|
||||
|
||||
cookies_now = time (NULL);
|
||||
|
||||
for (; ((line = read_whole_line (fp)) != NULL); xfree (line))
|
||||
while (getline (&line, &bufsize, fp) > 0)
|
||||
{
|
||||
struct cookie *cookie;
|
||||
char *p = line;
|
||||
@@ -1235,6 +1236,8 @@ cookie_jar_load (struct cookie_jar *jar, const char *file)
|
||||
abort_cookie:
|
||||
delete_cookie (cookie);
|
||||
}
|
||||
|
||||
xfree(line);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ get_status_for_err (uerr_t err)
|
||||
case RETROK:
|
||||
return WGET_EXIT_SUCCESS;
|
||||
case FOPENERR: case FOPEN_EXCL_ERR: case FWRITEERR: case WRITEFAILED:
|
||||
case UNLINKERR: case CLOSEFAILED:
|
||||
case UNLINKERR: case CLOSEFAILED: case FILEBADFILE:
|
||||
return WGET_EXIT_IO_FAIL;
|
||||
case NOCONERROR: case HOSTERR: case CONSOCKERR: case CONERROR:
|
||||
case CONSSLERR: case CONIMPOSSIBLE: case FTPRERR: case FTPINVPASV:
|
||||
@@ -68,7 +68,7 @@ get_status_for_err (uerr_t err)
|
||||
return WGET_EXIT_SSL_AUTH_FAIL;
|
||||
case FTPLOGINC: case FTPLOGREFUSED: case AUTHFAILED:
|
||||
return WGET_EXIT_SERVER_AUTH_FAIL;
|
||||
case HEOF: case HERR:
|
||||
case HEOF: case HERR: case ATTRMISSING:
|
||||
return WGET_EXIT_PROTOCOL_ERROR;
|
||||
case WRONGCODE: case FTPPORTERR: case FTPSYSERR:
|
||||
case FTPNSFOD: case FTPUNKNOWNTYPE: case FTPSRVERR:
|
||||
@@ -76,7 +76,7 @@ get_status_for_err (uerr_t err)
|
||||
case CONTNOTSUPPORTED: case RANGEERR: case RETRBADPATTERN:
|
||||
case PROXERR:
|
||||
return WGET_EXIT_SERVER_ERROR;
|
||||
case URLERROR: case QUOTEXC: case SSLINITFAILED:
|
||||
case URLERROR: case QUOTEXC: case SSLINITFAILED: case UNKNOWNATTR:
|
||||
default:
|
||||
return WGET_EXIT_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -960,23 +960,32 @@ ftp_retr (int csock, const char *file)
|
||||
/* Sends the LIST command to the server. If FILE is NULL, send just
|
||||
`LIST' (no space). */
|
||||
uerr_t
|
||||
ftp_list (int csock, const char *file, enum stype rs)
|
||||
ftp_list (int csock, const char *file, bool avoid_list_a, bool avoid_list,
|
||||
bool *list_a_used)
|
||||
{
|
||||
char *request, *respline;
|
||||
int nwritten;
|
||||
uerr_t err;
|
||||
bool ok = false;
|
||||
size_t i = 0;
|
||||
/* Try `LIST -a' first and revert to `LIST' in case of failure. */
|
||||
|
||||
*list_a_used = false;
|
||||
|
||||
/* 2013-10-12 Andrea Urbani (matfanjol)
|
||||
For more information about LIST and "LIST -a" please look at ftp.c,
|
||||
function getftp, text "__LIST_A_EXPLANATION__".
|
||||
|
||||
If somebody changes the following commands, please, checks also the
|
||||
later "i" variable. */
|
||||
const char *list_commands[] = { "LIST -a",
|
||||
"LIST" };
|
||||
|
||||
/* 2008-01-29 SMS. For a VMS FTP server, where "LIST -a" may not
|
||||
fail, but will never do what is desired here, skip directly to the
|
||||
simple "LIST" command (assumed to be the last one in the list).
|
||||
*/
|
||||
if (rs == ST_VMS)
|
||||
i = countof (list_commands)- 1;
|
||||
if (avoid_list_a)
|
||||
{
|
||||
i = countof (list_commands)- 1;
|
||||
DEBUGP (("(skipping \"LIST -a\")"));
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
/* Send request. */
|
||||
@@ -1000,6 +1009,8 @@ ftp_list (int csock, const char *file, enum stype rs)
|
||||
{
|
||||
err = FTPOK;
|
||||
ok = true;
|
||||
/* Which list command was used? */
|
||||
*list_a_used = (i == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1008,6 +1019,12 @@ ftp_list (int csock, const char *file, enum stype rs)
|
||||
xfree (respline);
|
||||
}
|
||||
++i;
|
||||
if ((avoid_list) && (i == 1))
|
||||
{
|
||||
/* I skip LIST */
|
||||
++i;
|
||||
DEBUGP (("(skipping \"LIST\")"));
|
||||
}
|
||||
} while (i < countof (list_commands) && !ok);
|
||||
|
||||
return err;
|
||||
@@ -1015,7 +1032,7 @@ ftp_list (int csock, const char *file, enum stype rs)
|
||||
|
||||
/* Sends the SYST command to the server. */
|
||||
uerr_t
|
||||
ftp_syst (int csock, enum stype *server_type)
|
||||
ftp_syst (int csock, enum stype *server_type, enum ustype *unix_type)
|
||||
{
|
||||
char *request, *respline;
|
||||
int nwritten;
|
||||
@@ -1048,12 +1065,23 @@ ftp_syst (int csock, enum stype *server_type)
|
||||
first word of the server response)? */
|
||||
request = strtok (NULL, " ");
|
||||
|
||||
*unix_type = UST_OTHER;
|
||||
|
||||
if (request == NULL)
|
||||
*server_type = ST_OTHER;
|
||||
else if (!strcasecmp (request, "VMS"))
|
||||
*server_type = ST_VMS;
|
||||
else if (!strcasecmp (request, "UNIX"))
|
||||
*server_type = ST_UNIX;
|
||||
{
|
||||
*server_type = ST_UNIX;
|
||||
/* 2013-10-17 Andrea Urbani (matfanjol)
|
||||
I check more in depth the system type */
|
||||
if (!strncasecmp (ftp_last_respline, "215 UNIX Type: L8", 17))
|
||||
*unix_type = UST_TYPE_L8;
|
||||
else if (!strncasecmp (ftp_last_respline,
|
||||
"215 UNIX MultiNet Unix Emulation V5.3(93)", 41))
|
||||
*unix_type = UST_MULTINET;
|
||||
}
|
||||
else if (!strcasecmp (request, "WINDOWS_NT")
|
||||
|| !strcasecmp (request, "WINDOWS2000"))
|
||||
*server_type = ST_WINNT;
|
||||
|
||||
185
src/ftp-ls.c
185
src/ftp-ls.c
@@ -68,16 +68,17 @@ symperms (const char *s)
|
||||
replaces all <TAB> character with <SPACE>. Returns the length of the
|
||||
modified line. */
|
||||
static int
|
||||
clean_line(char *line)
|
||||
clean_line (char *line, int len)
|
||||
{
|
||||
int len = strlen (line);
|
||||
if (!len) return 0;
|
||||
if (line[len - 1] == '\n')
|
||||
if (len <= 0) return 0;
|
||||
|
||||
while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r'))
|
||||
line[--len] = '\0';
|
||||
|
||||
if (!len) return 0;
|
||||
if (line[len - 1] == '\r')
|
||||
line[--len] = '\0';
|
||||
|
||||
for ( ; *line ; line++ ) if (*line == '\t') *line = ' ';
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -102,8 +103,9 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
int hour, min, sec, ptype;
|
||||
struct tm timestruct, *tnow;
|
||||
time_t timenow;
|
||||
size_t bufsize = 0;
|
||||
|
||||
char *line, *tok, *ptok; /* tokenizer */
|
||||
char *line = NULL, *tok, *ptok; /* tokenizer */
|
||||
struct fileinfo *dir, *l, cur; /* list creation */
|
||||
|
||||
fp = fopen (file, "rb");
|
||||
@@ -115,22 +117,16 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
dir = l = NULL;
|
||||
|
||||
/* Line loop to end of file: */
|
||||
while ((line = read_whole_line (fp)) != NULL)
|
||||
while ((len = getline (&line, &bufsize, fp)) > 0)
|
||||
{
|
||||
len = clean_line (line);
|
||||
len = clean_line (line, len);
|
||||
/* Skip if total... */
|
||||
if (!strncasecmp (line, "total", 5))
|
||||
{
|
||||
xfree (line);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
/* Get the first token (permissions). */
|
||||
tok = strtok (line, " ");
|
||||
if (!tok)
|
||||
{
|
||||
xfree (line);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
cur.name = NULL;
|
||||
cur.linkto = NULL;
|
||||
@@ -203,7 +199,7 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
if (next < 0) /* a month name was not encountered */
|
||||
{
|
||||
for (i = 0; i < 12; i++)
|
||||
if (!strcmp (tok, months[i]))
|
||||
if (!strcasecmp (tok, months[i]))
|
||||
break;
|
||||
/* If we got a month, it means the token before it is the
|
||||
size, and the filename is three tokens away. */
|
||||
@@ -368,7 +364,6 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
DEBUGP (("Skipping.\n"));
|
||||
xfree_null (cur.name);
|
||||
xfree_null (cur.linkto);
|
||||
xfree (line);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -416,10 +411,9 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
timestruct.tm_isdst = -1;
|
||||
l->tstamp = mktime (×truct); /* store the time-stamp */
|
||||
l->ptype = ptype;
|
||||
|
||||
xfree (line);
|
||||
}
|
||||
|
||||
xfree (line);
|
||||
fclose (fp);
|
||||
return dir;
|
||||
}
|
||||
@@ -431,9 +425,11 @@ ftp_parse_winnt_ls (const char *file)
|
||||
int len;
|
||||
int year, month, day; /* for time analysis */
|
||||
int hour, min;
|
||||
size_t bufsize = 0;
|
||||
struct tm timestruct;
|
||||
|
||||
char *line, *tok; /* tokenizer */
|
||||
char *line = NULL, *tok; /* tokenizer */
|
||||
char *filename;
|
||||
struct fileinfo *dir, *l, cur; /* list creation */
|
||||
|
||||
fp = fopen (file, "rb");
|
||||
@@ -445,43 +441,53 @@ ftp_parse_winnt_ls (const char *file)
|
||||
dir = l = NULL;
|
||||
|
||||
/* Line loop to end of file: */
|
||||
while ((line = read_whole_line (fp)) != NULL)
|
||||
while ((len = getline (&line, &bufsize, fp)) > 0)
|
||||
{
|
||||
len = clean_line (line);
|
||||
len = clean_line (line, len);
|
||||
|
||||
/* Extracting name is a bit of black magic and we have to do it
|
||||
before `strtok' inserted extra \0 characters in the line
|
||||
string. For the moment let us just suppose that the name starts at
|
||||
column 39 of the listing. This way we could also recognize
|
||||
filenames that begin with a series of space characters (but who
|
||||
really wants to use such filenames anyway?). */
|
||||
if (len < 40) goto continue_loop;
|
||||
tok = line + 39;
|
||||
cur.name = xstrdup(tok);
|
||||
DEBUGP (("Name: '%s'\n", cur.name));
|
||||
/* Name begins at 39 column of the listing if date presented in `mm-dd-yy'
|
||||
format or at 41 column if date presented in `mm-dd-yyyy' format. Thus,
|
||||
we cannot extract name before we parse date. Using this information we
|
||||
also can recognize filenames that begin with a series of space
|
||||
characters (but who really wants to use such filenames anyway?). */
|
||||
if (len < 40) continue;
|
||||
filename = line + 39;
|
||||
|
||||
/* First column: mm-dd-yy. Should atoi() on the month fail, january
|
||||
will be assumed. */
|
||||
/* First column: mm-dd-yy or mm-dd-yyyy. Should atoi() on the month fail,
|
||||
january will be assumed. */
|
||||
tok = strtok(line, "-");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
month = atoi(tok) - 1;
|
||||
if (month < 0) month = 0;
|
||||
tok = strtok(NULL, "-");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
day = atoi(tok);
|
||||
tok = strtok(NULL, " ");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
year = atoi(tok);
|
||||
/* Assuming the epoch starting at 1.1.1970 */
|
||||
if (year <= 70) year += 100;
|
||||
if (year <= 70)
|
||||
{
|
||||
year += 100;
|
||||
}
|
||||
else if (year >= 1900)
|
||||
{
|
||||
year -= 1900;
|
||||
filename += 2;
|
||||
}
|
||||
/* Now it is possible to determine the position of the first symbol in
|
||||
filename. */
|
||||
cur.name = xstrdup(filename);
|
||||
DEBUGP (("Name: '%s'\n", cur.name));
|
||||
|
||||
|
||||
/* Second column: hh:mm[AP]M, listing does not contain value for
|
||||
seconds */
|
||||
tok = strtok(NULL, ":");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
hour = atoi(tok);
|
||||
tok = strtok(NULL, "M");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
min = atoi(tok);
|
||||
/* Adjust hour from AM/PM. Just for the record, the sequence goes
|
||||
11:00AM, 12:00PM, 01:00PM ... 11:00PM, 12:00AM, 01:00AM . */
|
||||
@@ -512,9 +518,9 @@ ftp_parse_winnt_ls (const char *file)
|
||||
directories as the listing does not give us a clue) and filetype
|
||||
here. */
|
||||
tok = strtok(NULL, " ");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
while ((tok != NULL) && (*tok == '\0')) tok = strtok(NULL, " ");
|
||||
if (tok == NULL) goto continue_loop;
|
||||
if (tok == NULL) continue;
|
||||
if (*tok == '<')
|
||||
{
|
||||
cur.type = FT_DIRECTORY;
|
||||
@@ -553,11 +559,9 @@ ftp_parse_winnt_ls (const char *file)
|
||||
memcpy (l, &cur, sizeof (cur));
|
||||
l->next = NULL;
|
||||
}
|
||||
|
||||
continue_loop:
|
||||
xfree (line);
|
||||
}
|
||||
|
||||
xfree (line);
|
||||
fclose(fp);
|
||||
return dir;
|
||||
}
|
||||
@@ -678,11 +682,12 @@ ftp_parse_vms_ls (const char *file)
|
||||
FILE *fp;
|
||||
int dt, i, j, len;
|
||||
int perms;
|
||||
size_t bufsize = 0;
|
||||
time_t timenow;
|
||||
struct tm *timestruct;
|
||||
char date_str[ 32];
|
||||
|
||||
char *line, *tok; /* tokenizer */
|
||||
char *line = NULL, *tok; /* tokenizer */
|
||||
struct fileinfo *dir, *l, cur; /* list creation */
|
||||
|
||||
fp = fopen (file, "r");
|
||||
@@ -695,52 +700,34 @@ ftp_parse_vms_ls (const char *file)
|
||||
|
||||
/* Skip blank lines, Directory heading, and more blank lines. */
|
||||
|
||||
j = 0; /* Expecting initial blank line(s). */
|
||||
while (1)
|
||||
for (j = 0; (i = getline (&line, &bufsize, fp)) > 0; )
|
||||
{
|
||||
line = read_whole_line (fp);
|
||||
if (line == NULL)
|
||||
i = clean_line (line, i);
|
||||
if (i <= 0)
|
||||
continue; /* Ignore blank line. */
|
||||
|
||||
if ((j == 0) && (line[i - 1] == ']'))
|
||||
{
|
||||
break;
|
||||
/* Found Directory heading line. Next non-blank line
|
||||
is significant. */
|
||||
j = 1;
|
||||
}
|
||||
else if (!strncmp (line, "Total of ", 9))
|
||||
{
|
||||
/* Found "Total of ..." footing line. No valid data
|
||||
will follow (empty directory). */
|
||||
i = 0; /* Arrange for early exit. */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = clean_line (line);
|
||||
if (i <= 0)
|
||||
{
|
||||
xfree (line); /* Free useless line storage. */
|
||||
continue; /* Blank line. Keep looking. */
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((j == 0) && (line[ i- 1] == ']'))
|
||||
{
|
||||
/* Found Directory heading line. Next non-blank line
|
||||
is significant.
|
||||
*/
|
||||
j = 1;
|
||||
}
|
||||
else if (!strncmp (line, "Total of ", 9))
|
||||
{
|
||||
/* Found "Total of ..." footing line. No valid data
|
||||
will follow (empty directory).
|
||||
*/
|
||||
xfree (line); /* Free useless line storage. */
|
||||
line = NULL; /* Arrange for early exit. */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break; /* Must be significant data. */
|
||||
}
|
||||
}
|
||||
xfree (line); /* Free useless line storage. */
|
||||
break; /* Must be significant data. */
|
||||
}
|
||||
}
|
||||
|
||||
/* Read remainder of file until the next blank line or EOF. */
|
||||
|
||||
while (line != NULL)
|
||||
while (i > 0)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -831,9 +818,8 @@ ftp_parse_vms_ls (const char *file)
|
||||
if (tok == NULL)
|
||||
{
|
||||
DEBUGP (("Getting additional line.\n"));
|
||||
xfree (line);
|
||||
line = read_whole_line (fp);
|
||||
if (!line)
|
||||
i = getline (&line, &bufsize, fp);
|
||||
if (i <= 0)
|
||||
{
|
||||
DEBUGP (("EOF. Leaving listing parser.\n"));
|
||||
break;
|
||||
@@ -842,14 +828,14 @@ ftp_parse_vms_ls (const char *file)
|
||||
/* Second line must begin with " ". Otherwise, it's a first
|
||||
line (and we may be confused).
|
||||
*/
|
||||
i = clean_line (line, i);
|
||||
if (i <= 0)
|
||||
{
|
||||
/* Blank line. End of significant file listing. */
|
||||
DEBUGP (("Blank line. Leaving listing parser.\n"));
|
||||
xfree (line); /* Free useless line storage. */
|
||||
break;
|
||||
}
|
||||
else if (line[ 0] != ' ')
|
||||
else if (line[0] != ' ')
|
||||
{
|
||||
DEBUGP (("Non-blank in column 1. Must be a new file name?\n"));
|
||||
continue;
|
||||
@@ -861,7 +847,6 @@ ftp_parse_vms_ls (const char *file)
|
||||
{
|
||||
/* Unexpected non-empty but apparently blank line. */
|
||||
DEBUGP (("Null token. Leaving listing parser.\n"));
|
||||
xfree (line); /* Free useless line storage. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -900,7 +885,7 @@ ftp_parse_vms_ls (const char *file)
|
||||
(sizeof( date_str)- strlen (date_str) - 1));
|
||||
DEBUGP (("Date time: >%s<\n", date_str));
|
||||
}
|
||||
else if (strchr ( tok, '[') != NULL)
|
||||
else if (strchr (tok, '[') != NULL)
|
||||
{
|
||||
/* Owner. (Ignore.) */
|
||||
DEBUGP (("Owner.\n"));
|
||||
@@ -910,7 +895,7 @@ ftp_parse_vms_ls (const char *file)
|
||||
/* Protections (permissions). */
|
||||
perms = 0;
|
||||
j = 0;
|
||||
for (i = 0; i < strlen( tok); i++)
|
||||
for (i = 0; i < strlen(tok); i++)
|
||||
{
|
||||
switch (tok[ i])
|
||||
{
|
||||
@@ -1004,21 +989,19 @@ ftp_parse_vms_ls (const char *file)
|
||||
l->next = NULL;
|
||||
}
|
||||
|
||||
/* Free old line storage. Read a new line. */
|
||||
xfree (line);
|
||||
line = read_whole_line (fp);
|
||||
if (line != NULL)
|
||||
i = getline (&line, &bufsize, fp);
|
||||
if (i > 0)
|
||||
{
|
||||
i = clean_line (line);
|
||||
i = clean_line (line, i);
|
||||
if (i <= 0)
|
||||
{
|
||||
{
|
||||
/* Blank line. End of significant file listing. */
|
||||
xfree (line); /* Free useless line storage. */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xfree (line);
|
||||
fclose (fp);
|
||||
return dir;
|
||||
}
|
||||
|
||||
335
src/ftp.c
335
src/ftp.c
@@ -70,6 +70,7 @@ typedef struct
|
||||
int csock; /* control connection socket */
|
||||
double dltime; /* time of the download in msecs */
|
||||
enum stype rs; /* remote system reported by ftp server */
|
||||
enum ustype rsu; /* when rs is ST_UNIX, here there are more details */
|
||||
char *id; /* initial directory */
|
||||
char *target; /* target file name */
|
||||
struct url *proxy; /* FTWK-style proxy */
|
||||
@@ -255,8 +256,10 @@ getftp (struct url *u, wgint passed_expected_bytes, wgint *qtyread,
|
||||
bool got_expected_bytes = false;
|
||||
bool rest_failed = false;
|
||||
int flags;
|
||||
wgint rd_size;
|
||||
wgint rd_size, previous_rd_size = 0;
|
||||
char type_char;
|
||||
bool try_again;
|
||||
bool list_a_used = false;
|
||||
|
||||
assert (con != NULL);
|
||||
assert (con->target != NULL);
|
||||
@@ -365,7 +368,7 @@ Error in server response, closing control connection.\n"));
|
||||
/* Third: Get the system type */
|
||||
if (!opt.server_response)
|
||||
logprintf (LOG_VERBOSE, "==> SYST ... ");
|
||||
err = ftp_syst (csock, &con->rs);
|
||||
err = ftp_syst (csock, &con->rs, &con->rsu);
|
||||
/* FTPRERR */
|
||||
switch (err)
|
||||
{
|
||||
@@ -390,6 +393,44 @@ Error in server response, closing control connection.\n"));
|
||||
if (!opt.server_response && err != FTPSRVERR)
|
||||
logputs (LOG_VERBOSE, _("done. "));
|
||||
|
||||
/* 2013-10-17 Andrea Urbani (matfanjol)
|
||||
According to the system type I choose which
|
||||
list command will be used.
|
||||
If I don't know that system, I will try, the
|
||||
first time of each session, "LIST -a" and
|
||||
"LIST". (see __LIST_A_EXPLANATION__ below) */
|
||||
switch (con->rs)
|
||||
{
|
||||
case ST_VMS:
|
||||
/* About ST_VMS there is an old note:
|
||||
2008-01-29 SMS. For a VMS FTP server, where "LIST -a" may not
|
||||
fail, but will never do what is desired here,
|
||||
skip directly to the simple "LIST" command
|
||||
(assumed to be the last one in the list). */
|
||||
DEBUGP (("\nVMS: I know it and I will use \"LIST\" as standard list command\n"));
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
con->st |= AVOID_LIST_A;
|
||||
break;
|
||||
case ST_UNIX:
|
||||
if (con->rsu == UST_MULTINET)
|
||||
{
|
||||
DEBUGP (("\nUNIX MultiNet: I know it and I will use \"LIST\" "
|
||||
"as standard list command\n"));
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
con->st |= AVOID_LIST_A;
|
||||
}
|
||||
else if (con->rsu == UST_TYPE_L8)
|
||||
{
|
||||
DEBUGP (("\nUNIX TYPE L8: I know it and I will use \"LIST -a\" "
|
||||
"as standard list command\n"));
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
con->st |= AVOID_LIST;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Fourth: Find the initial ftp directory */
|
||||
|
||||
if (!opt.server_response)
|
||||
@@ -616,16 +657,16 @@ Error in server response, closing control connection.\n"));
|
||||
The VMS restriction may be relaxed when the squirrely code
|
||||
above is reformed.
|
||||
*/
|
||||
if ((con->rs == ST_VMS) && (target[0] != '/'))
|
||||
{
|
||||
cwd_start = 0;
|
||||
DEBUGP (("Using two-step CWD for relative path.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((con->rs == ST_VMS) && (target[0] != '/'))
|
||||
{
|
||||
cwd_start = 0;
|
||||
DEBUGP (("Using two-step CWD for relative path.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Go straight to the target. */
|
||||
cwd_start = 1;
|
||||
}
|
||||
cwd_start = 1;
|
||||
}
|
||||
|
||||
/* At least one VMS FTP server (TCPware V5.6-2) can switch to
|
||||
a UNIX emulation mode when given a UNIX-like directory
|
||||
@@ -643,10 +684,10 @@ Error in server response, closing control connection.\n"));
|
||||
Unlike the rest of this block, this particular behavior
|
||||
_is_ VMS-specific, so it gets its own VMS test.
|
||||
*/
|
||||
if ((con->rs == ST_VMS) && (strchr( target, '/') != NULL))
|
||||
if ((con->rs == ST_VMS) && (strchr( target, '/') != NULL))
|
||||
{
|
||||
cwd_end = 3;
|
||||
DEBUGP (("Using extra \"CWD []\" step for VMS server.\n"));
|
||||
DEBUGP (("Using extra \"CWD []\" step for VMS server.\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -656,22 +697,22 @@ Error in server response, closing control connection.\n"));
|
||||
/* 2004-09-20 SMS. */
|
||||
/* Sorry about the deviant indenting. Laziness. */
|
||||
|
||||
for (cwd_count = cwd_start; cwd_count < cwd_end; cwd_count++)
|
||||
{
|
||||
for (cwd_count = cwd_start; cwd_count < cwd_end; cwd_count++)
|
||||
{
|
||||
switch (cwd_count)
|
||||
{
|
||||
case 0:
|
||||
/* Step one (optional): Go to the initial directory,
|
||||
exactly as reported by the server.
|
||||
*/
|
||||
targ = con->id;
|
||||
/* Step one (optional): Go to the initial directory,
|
||||
exactly as reported by the server.
|
||||
*/
|
||||
targ = con->id;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* Step two: Go to the target directory. (Absolute or
|
||||
relative will work now.)
|
||||
*/
|
||||
targ = target;
|
||||
/* Step two: Go to the target directory. (Absolute or
|
||||
relative will work now.)
|
||||
*/
|
||||
targ = target;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -684,7 +725,7 @@ Error in server response, closing control connection.\n"));
|
||||
default:
|
||||
/* Can't happen. */
|
||||
assert (1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!opt.server_response)
|
||||
logprintf (LOG_VERBOSE, "==> CWD (%d) %s ... ", cwd_count,
|
||||
@@ -775,6 +816,9 @@ Error in server response, closing control connection.\n"));
|
||||
return RETRFINISHED;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
try_again = false;
|
||||
/* If anything is to be retrieved, PORT (or PASV) must be sent. */
|
||||
if (cmd & (DO_LIST | DO_RETR))
|
||||
{
|
||||
@@ -938,42 +982,42 @@ Error in server response, closing control connection.\n"));
|
||||
if (cmd & DO_RETR)
|
||||
{
|
||||
/* If we're in spider mode, don't really retrieve anything except
|
||||
the directory listing and verify whether the given "file" exists. */
|
||||
the directory listing and verify whether the given "file" exists. */
|
||||
if (opt.spider)
|
||||
{
|
||||
bool exists = false;
|
||||
uerr_t res;
|
||||
struct fileinfo *f;
|
||||
res = ftp_get_listing (u, con, &f);
|
||||
/* Set the DO_RETR command flag again, because it gets unset when
|
||||
calling ftp_get_listing() and would otherwise cause an assertion
|
||||
failure earlier on when this function gets repeatedly called
|
||||
(e.g., when recursing). */
|
||||
con->cmd |= DO_RETR;
|
||||
if (res == RETROK)
|
||||
{
|
||||
while (f)
|
||||
{
|
||||
if (!strcmp (f->name, u->file))
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
f = f->next;
|
||||
}
|
||||
bool exists = false;
|
||||
uerr_t res;
|
||||
struct fileinfo *f;
|
||||
res = ftp_get_listing (u, con, &f);
|
||||
/* Set the DO_RETR command flag again, because it gets unset when
|
||||
calling ftp_get_listing() and would otherwise cause an assertion
|
||||
failure earlier on when this function gets repeatedly called
|
||||
(e.g., when recursing). */
|
||||
con->cmd |= DO_RETR;
|
||||
if (res == RETROK)
|
||||
{
|
||||
while (f)
|
||||
{
|
||||
if (!strcmp (f->name, u->file))
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
f = f->next;
|
||||
}
|
||||
if (exists)
|
||||
{
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("File %s exists.\n"),
|
||||
quote (u->file));
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("No such file %s.\n"),
|
||||
quote (u->file));
|
||||
}
|
||||
}
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("No such file %s.\n"),
|
||||
quote (u->file));
|
||||
}
|
||||
}
|
||||
fd_close (csock);
|
||||
con->csock = -1;
|
||||
fd_close (dtsock);
|
||||
@@ -1041,7 +1085,8 @@ Error in server response, closing control connection.\n"));
|
||||
/* As Maciej W. Rozycki (macro@ds2.pg.gda.pl) says, `LIST'
|
||||
without arguments is better than `LIST .'; confirmed by
|
||||
RFC959. */
|
||||
err = ftp_list (csock, NULL, con->rs);
|
||||
err = ftp_list (csock, NULL, con->st&AVOID_LIST_A, con->st&AVOID_LIST, &list_a_used);
|
||||
|
||||
/* FTPRERR, WRITEFAILED */
|
||||
switch (err)
|
||||
{
|
||||
@@ -1184,20 +1229,20 @@ Error in server response, closing control connection.\n"));
|
||||
else if (opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct
|
||||
|| opt.output_document || count > 0)
|
||||
{
|
||||
if (opt.unlink && file_exists_p (con->target))
|
||||
{
|
||||
int res = unlink (con->target);
|
||||
if (res < 0)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, "%s: %s\n", con->target,
|
||||
strerror (errno));
|
||||
fd_close (csock);
|
||||
con->csock = -1;
|
||||
fd_close (dtsock);
|
||||
fd_close (local_sock);
|
||||
return UNLINKERR;
|
||||
}
|
||||
}
|
||||
if (opt.unlink && file_exists_p (con->target))
|
||||
{
|
||||
int res = unlink (con->target);
|
||||
if (res < 0)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, "%s: %s\n", con->target,
|
||||
strerror (errno));
|
||||
fd_close (csock);
|
||||
con->csock = -1;
|
||||
fd_close (dtsock);
|
||||
fd_close (local_sock);
|
||||
return UNLINKERR;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __VMS
|
||||
int open_id;
|
||||
@@ -1343,8 +1388,10 @@ Error in server response, closing control connection.\n"));
|
||||
}
|
||||
/* If it was a listing, and opt.server_response is true,
|
||||
print it out. */
|
||||
if (opt.server_response && (con->cmd & DO_LIST))
|
||||
if (con->cmd & DO_LIST)
|
||||
{
|
||||
if (opt.server_response)
|
||||
{
|
||||
/* 2005-02-25 SMS.
|
||||
Much of this work may already have been done, but repeating it should
|
||||
do no damage beyond wasting time.
|
||||
@@ -1367,22 +1414,115 @@ Error in server response, closing control connection.\n"));
|
||||
logprintf (LOG_ALWAYS, "%s: %s\n", con->target, strerror (errno));
|
||||
else
|
||||
{
|
||||
char *line;
|
||||
/* The lines are being read with read_whole_line because of
|
||||
char *line = NULL;
|
||||
size_t bufsize = 0;
|
||||
ssize_t len;
|
||||
|
||||
/* The lines are being read with getline because of
|
||||
no-buffering on opt.lfile. */
|
||||
while ((line = read_whole_line (fp)) != NULL)
|
||||
while ((len = getline (&line, &bufsize, fp)) > 0)
|
||||
{
|
||||
char *p = strchr (line, '\0');
|
||||
while (p > line && (p[-1] == '\n' || p[-1] == '\r'))
|
||||
*--p = '\0';
|
||||
while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r'))
|
||||
line[--len] = '\0';
|
||||
logprintf (LOG_ALWAYS, "%s\n",
|
||||
quotearg_style (escape_quoting_style, line));
|
||||
xfree (line);
|
||||
}
|
||||
xfree (line);
|
||||
fclose (fp);
|
||||
}
|
||||
} /* con->cmd & DO_LIST && server_response */
|
||||
} /* server_response */
|
||||
|
||||
/* 2013-10-17 Andrea Urbani (matfanjol)
|
||||
< __LIST_A_EXPLANATION__ >
|
||||
After the SYST command, looks if it knows that system.
|
||||
If yes, wget will force the use of "LIST" or "LIST -a".
|
||||
If no, wget will try, only the first time of each session, before the
|
||||
"LIST -a" command and after the "LIST".
|
||||
If "LIST -a" works and returns more or equal data of the "LIST",
|
||||
"LIST -a" will be the standard list command for all the session.
|
||||
If "LIST -a" fails or returns less data than "LIST" (think on the case
|
||||
of an existing file called "-a"), "LIST" will be the standard list
|
||||
command for all the session.
|
||||
("LIST -a" is used to get also the hidden files)
|
||||
|
||||
*/
|
||||
if (!(con->st & LIST_AFTER_LIST_A_CHECK_DONE))
|
||||
{
|
||||
/* We still have to check "LIST" after the first "LIST -a" to see
|
||||
if with "LIST" we get more data than "LIST -a", that means
|
||||
"LIST -a" returned files/folders with "-a" name. */
|
||||
if (con->st & AVOID_LIST_A)
|
||||
{
|
||||
/* LIST was used in this cycle.
|
||||
Let's see the result. */
|
||||
if (rd_size > previous_rd_size)
|
||||
{
|
||||
/* LIST returns more data than "LIST -a".
|
||||
"LIST" is the official command to use. */
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
DEBUGP (("LIST returned more data than \"LIST -a\": "
|
||||
"I will use \"LIST\" as standard list command\n"));
|
||||
}
|
||||
else if (previous_rd_size > rd_size)
|
||||
{
|
||||
/* "LIST -a" returned more data then LIST.
|
||||
"LIST -a" is the official command to use. */
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
con->st |= AVOID_LIST;
|
||||
con->st &= ~AVOID_LIST_A;
|
||||
/* Sorry, please, download again the "LIST -a"... */
|
||||
try_again = true;
|
||||
DEBUGP (("LIST returned less data than \"LIST -a\": I will "
|
||||
"use \"LIST -a\" as standard list command\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LIST and "LIST -a" return the same data. */
|
||||
if (rd_size == 0)
|
||||
{
|
||||
/* Same empty data. We will check both again because
|
||||
we cannot check if "LIST -a" has returned an empty
|
||||
folder instead of a folder content. */
|
||||
con->st &= ~AVOID_LIST_A;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Same data, so, better to take "LIST -a" that
|
||||
shows also hidden files/folders (when present) */
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
con->st |= AVOID_LIST;
|
||||
con->st &= ~AVOID_LIST_A;
|
||||
DEBUGP (("LIST returned the same amount of data of "
|
||||
"\"LIST -a\": I will use \"LIST -a\" as standard "
|
||||
"list command\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In this cycle "LIST -a" should being used. Is it true? */
|
||||
if (list_a_used)
|
||||
{
|
||||
/* Yes, it is.
|
||||
OK, let's save the amount of data and try again
|
||||
with LIST */
|
||||
previous_rd_size = rd_size;
|
||||
try_again = true;
|
||||
con->st |= AVOID_LIST_A;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No: something happens and LIST was used.
|
||||
This means "LIST -a" raises an error. */
|
||||
con->st |= LIST_AFTER_LIST_A_CHECK_DONE;
|
||||
con->st |= AVOID_LIST_A;
|
||||
DEBUGP (("\"LIST -a\" failed: I will use \"LIST\" "
|
||||
"as standard list command\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (try_again);
|
||||
return RETRFINISHED;
|
||||
}
|
||||
|
||||
@@ -1424,7 +1564,12 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
|
||||
|
||||
/* If the output_document was given, then this check was already done and
|
||||
the file didn't exist. Hence the !opt.output_document */
|
||||
if (opt.noclobber && !opt.output_document && file_exists_p (con->target))
|
||||
|
||||
/* If we receive .listing file it is necessary to determine system type of the ftp
|
||||
server even if opn.noclobber is given. Thus we must ignore opt.noclobber in
|
||||
order to establish connection with the server and get system type. */
|
||||
if (opt.noclobber && !opt.output_document && file_exists_p (con->target)
|
||||
&& !((con->cmd & DO_LIST) && !(con->cmd & DO_RETR)))
|
||||
{
|
||||
logprintf (LOG_VERBOSE,
|
||||
_("File %s already there; not retrieving.\n"), quote (con->target));
|
||||
@@ -1442,21 +1587,6 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
|
||||
|
||||
orig_lp = con->cmd & LEAVE_PENDING ? 1 : 0;
|
||||
|
||||
/* For file RETR requests, we can write a WARC record.
|
||||
We record the file contents to a temporary file. */
|
||||
if (warc_enabled && (con->cmd & DO_RETR))
|
||||
{
|
||||
warc_tmp = warc_tempfile ();
|
||||
if (warc_tmp == NULL)
|
||||
return WARC_TMP_FOPENERR;
|
||||
|
||||
if (!con->proxy && con->csock != -1)
|
||||
{
|
||||
warc_ip = (ip_address *) alloca (sizeof (ip_address));
|
||||
socket_ip_address (con->csock, warc_ip, ENDPOINT_PEER);
|
||||
}
|
||||
}
|
||||
|
||||
/* THE loop. */
|
||||
do
|
||||
{
|
||||
@@ -1484,6 +1614,21 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
|
||||
con->cmd |= DO_CWD;
|
||||
}
|
||||
|
||||
/* For file RETR requests, we can write a WARC record.
|
||||
We record the file contents to a temporary file. */
|
||||
if (warc_enabled && (con->cmd & DO_RETR) && warc_tmp == NULL)
|
||||
{
|
||||
warc_tmp = warc_tempfile ();
|
||||
if (warc_tmp == NULL)
|
||||
return WARC_TMP_FOPENERR;
|
||||
|
||||
if (!con->proxy && con->csock != -1)
|
||||
{
|
||||
warc_ip = (ip_address *) alloca (sizeof (ip_address));
|
||||
socket_ip_address (con->csock, warc_ip, ENDPOINT_PEER);
|
||||
}
|
||||
}
|
||||
|
||||
/* Decide whether or not to restart. */
|
||||
if (con->cmd & DO_LIST)
|
||||
restval = 0;
|
||||
@@ -1619,7 +1764,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
|
||||
/* warc_write_resource_record has also closed warc_tmp. */
|
||||
}
|
||||
|
||||
if ((con->cmd & DO_LIST))
|
||||
if (con->cmd & DO_LIST)
|
||||
/* This is a directory listing file. */
|
||||
{
|
||||
if (!opt.remove_listing)
|
||||
@@ -2278,11 +2423,11 @@ ftp_loop (struct url *u, char **local_file, int *dt, struct url *proxy,
|
||||
file_part = u->path;
|
||||
ispattern = has_wildcards_p (file_part);
|
||||
}
|
||||
if (ispattern || recursive || opt.timestamping)
|
||||
if (ispattern || recursive || opt.timestamping || opt.preserve_perm)
|
||||
{
|
||||
/* ftp_retrieve_glob is a catch-all function that gets called
|
||||
if we need globbing, time-stamping or recursion. Its
|
||||
third argument is just what we really need. */
|
||||
if we need globbing, time-stamping, recursion or preserve
|
||||
permissions. Its third argument is just what we really need. */
|
||||
res = ftp_retrieve_glob (u, &con,
|
||||
ispattern ? GLOB_GLOBALL : GLOB_GETONE);
|
||||
}
|
||||
|
||||
29
src/ftp.h
29
src/ftp.h
@@ -45,6 +45,14 @@ enum stype
|
||||
ST_OTHER
|
||||
};
|
||||
|
||||
/* Extensions of the ST_UNIX */
|
||||
enum ustype
|
||||
{
|
||||
UST_TYPE_L8,
|
||||
UST_MULTINET,
|
||||
UST_OTHER
|
||||
};
|
||||
|
||||
extern char ftp_last_respline[];
|
||||
|
||||
uerr_t ftp_response (int, char **);
|
||||
@@ -61,8 +69,8 @@ uerr_t ftp_type (int, int);
|
||||
uerr_t ftp_cwd (int, const char *);
|
||||
uerr_t ftp_retr (int, const char *);
|
||||
uerr_t ftp_rest (int, wgint);
|
||||
uerr_t ftp_list (int, const char *, enum stype);
|
||||
uerr_t ftp_syst (int, enum stype *);
|
||||
uerr_t ftp_list (int, const char *, bool, bool, bool *);
|
||||
uerr_t ftp_syst (int, enum stype *, enum ustype *);
|
||||
uerr_t ftp_pwd (int, char **);
|
||||
uerr_t ftp_size (int, const char *, wgint *);
|
||||
|
||||
@@ -124,8 +132,23 @@ enum wget_ftp_fstatus
|
||||
NOTHING = 0x0000, /* Nothing done yet. */
|
||||
ON_YOUR_OWN = 0x0001, /* The ftp_loop_internal sets the
|
||||
defaults. */
|
||||
DONE_CWD = 0x0002 /* The current working directory is
|
||||
DONE_CWD = 0x0002, /* The current working directory is
|
||||
correct. */
|
||||
|
||||
/* 2013-10-17 Andrea Urbani (matfanjol)
|
||||
For more information about the following entries, please,
|
||||
look at ftp.c, function getftp, text "__LIST_A_EXPLANATION__". */
|
||||
AVOID_LIST_A = 0x0004, /* It tells us if during this
|
||||
session we have to avoid the use
|
||||
of "LIST -a".*/
|
||||
AVOID_LIST = 0x0008, /* It tells us if during this
|
||||
session we have to avoid to use
|
||||
"LIST". */
|
||||
LIST_AFTER_LIST_A_CHECK_DONE = 0x0010
|
||||
/* It tells us if we have already
|
||||
checked "LIST" after the first
|
||||
"LIST -a" to handle the case of
|
||||
file/folders named "-a". */
|
||||
};
|
||||
|
||||
struct fileinfo *ftp_parse_ls (const char *, const enum stype);
|
||||
|
||||
243
src/gnutls.c
243
src/gnutls.c
@@ -46,6 +46,7 @@ as that of the covered work. */
|
||||
#include "connect.h"
|
||||
#include "url.h"
|
||||
#include "ptimer.h"
|
||||
#include "hash.h"
|
||||
#include "ssl.h"
|
||||
|
||||
#include <sys/fcntl.h>
|
||||
@@ -81,49 +82,76 @@ ssl_init (void)
|
||||
{
|
||||
/* Becomes true if GnuTLS is initialized. */
|
||||
static bool ssl_initialized = false;
|
||||
const char *ca_directory;
|
||||
DIR *dir;
|
||||
int ncerts = -1;
|
||||
|
||||
/* GnuTLS should be initialized only once. */
|
||||
if (ssl_initialized)
|
||||
return true;
|
||||
|
||||
const char *ca_directory;
|
||||
DIR *dir;
|
||||
|
||||
gnutls_global_init ();
|
||||
gnutls_certificate_allocate_credentials (&credentials);
|
||||
gnutls_certificate_set_verify_flags(credentials,
|
||||
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
|
||||
gnutls_certificate_set_verify_flags (credentials,
|
||||
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
|
||||
|
||||
ca_directory = opt.ca_directory ? opt.ca_directory : "/etc/ssl/certs";
|
||||
#if GNUTLS_VERSION_MAJOR >= 3
|
||||
if (!opt.ca_directory)
|
||||
ncerts = gnutls_certificate_set_x509_system_trust (credentials);
|
||||
#endif
|
||||
|
||||
dir = opendir (ca_directory);
|
||||
if (dir == NULL)
|
||||
/* If GnuTLS version is too old or CA loading failed, fallback to old behaviour.
|
||||
* Also use old behaviour if the CA directory is user-provided. */
|
||||
if (ncerts <= 0)
|
||||
{
|
||||
if (opt.ca_directory)
|
||||
logprintf (LOG_NOTQUIET, _("ERROR: Cannot open directory %s.\n"),
|
||||
opt.ca_directory);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct dirent *dent;
|
||||
while ((dent = readdir (dir)) != NULL)
|
||||
ca_directory = opt.ca_directory ? opt.ca_directory : "/etc/ssl/certs";
|
||||
if ((dir = opendir (ca_directory)) == NULL)
|
||||
{
|
||||
struct stat st;
|
||||
char *ca_file;
|
||||
asprintf (&ca_file, "%s/%s", ca_directory, dent->d_name);
|
||||
|
||||
stat (ca_file, &st);
|
||||
|
||||
if (S_ISREG (st.st_mode))
|
||||
gnutls_certificate_set_x509_trust_file (credentials, ca_file,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
|
||||
free (ca_file);
|
||||
if (opt.ca_directory && *opt.ca_directory)
|
||||
logprintf (LOG_NOTQUIET, _("ERROR: Cannot open directory %s.\n"),
|
||||
opt.ca_directory);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hash_table *inode_map = hash_table_new (196, NULL, NULL);
|
||||
struct dirent *dent;
|
||||
size_t dirlen = strlen(ca_directory);
|
||||
int rc;
|
||||
|
||||
closedir (dir);
|
||||
ncerts = 0;
|
||||
|
||||
while ((dent = readdir (dir)) != NULL)
|
||||
{
|
||||
struct stat st;
|
||||
char ca_file[dirlen + strlen(dent->d_name) + 2];
|
||||
|
||||
snprintf (ca_file, sizeof(ca_file), "%s/%s", ca_directory, dent->d_name);
|
||||
if (stat (ca_file, &st) != 0)
|
||||
continue;
|
||||
|
||||
if (! S_ISREG (st.st_mode))
|
||||
continue;
|
||||
|
||||
/* avoid loading the same file twice by checking the inode. */
|
||||
if (hash_table_contains (inode_map, (void *)(intptr_t) st.st_ino))
|
||||
continue;
|
||||
|
||||
hash_table_put (inode_map, (void *)(intptr_t) st.st_ino, NULL);
|
||||
if ((rc = gnutls_certificate_set_x509_trust_file (credentials, ca_file,
|
||||
GNUTLS_X509_FMT_PEM)) <= 0)
|
||||
logprintf (LOG_NOTQUIET, _("ERROR: Failed to open cert %s: (%d).\n"),
|
||||
ca_file, rc);
|
||||
else
|
||||
ncerts += rc;
|
||||
}
|
||||
|
||||
hash_table_destroy (inode_map);
|
||||
closedir (dir);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGP (("Certificates loaded: %d\n", ncerts));
|
||||
|
||||
/* Use the private key from the cert file unless otherwise specified. */
|
||||
if (opt.cert_file && !opt.private_key)
|
||||
{
|
||||
@@ -141,17 +169,17 @@ ssl_init (void)
|
||||
{
|
||||
int type;
|
||||
if (opt.private_key_type != opt.cert_type)
|
||||
{
|
||||
/* GnuTLS can't handle this */
|
||||
logprintf (LOG_NOTQUIET, _("ERROR: GnuTLS requires the key and the \
|
||||
{
|
||||
/* GnuTLS can't handle this */
|
||||
logprintf (LOG_NOTQUIET, _("ERROR: GnuTLS requires the key and the \
|
||||
cert to be of the same type.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
type = key_type_to_gnutls_type (opt.private_key_type);
|
||||
|
||||
gnutls_certificate_set_x509_key_file (credentials, opt.cert_file,
|
||||
opt.private_key,
|
||||
type);
|
||||
opt.private_key,
|
||||
type);
|
||||
}
|
||||
|
||||
if (opt.ca_cert)
|
||||
@@ -278,7 +306,7 @@ wgnutls_read (int fd, char *buf, int bufsize, void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
wgnutls_write (int fd, char *buf, int bufsize, void *arg)
|
||||
wgnutls_write (int fd _GL_UNUSED, char *buf, int bufsize, void *arg)
|
||||
{
|
||||
int ret;
|
||||
struct wgnutls_transport_context *ctx = arg;
|
||||
@@ -315,7 +343,7 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg)
|
||||
return offset;
|
||||
}
|
||||
|
||||
if (bufsize > sizeof ctx->peekbuf)
|
||||
if (bufsize > (int) sizeof ctx->peekbuf)
|
||||
bufsize = sizeof ctx->peekbuf;
|
||||
|
||||
if (bufsize > offset)
|
||||
@@ -346,7 +374,7 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg)
|
||||
}
|
||||
|
||||
static const char *
|
||||
wgnutls_errstr (int fd, void *arg)
|
||||
wgnutls_errstr (int fd _GL_UNUSED, void *arg)
|
||||
{
|
||||
struct wgnutls_transport_context *ctx = arg;
|
||||
return gnutls_strerror (ctx->last_error);
|
||||
@@ -374,16 +402,20 @@ static struct transport_implementation wgnutls_transport =
|
||||
bool
|
||||
ssl_connect_wget (int fd, const char *hostname)
|
||||
{
|
||||
#ifdef F_GETFL
|
||||
int flags = 0;
|
||||
#endif
|
||||
struct wgnutls_transport_context *ctx;
|
||||
gnutls_session_t session;
|
||||
int err;
|
||||
int err,alert;
|
||||
gnutls_init (&session, GNUTLS_CLIENT);
|
||||
const char *str;
|
||||
|
||||
/* We set the server name but only if it's not an IP address. */
|
||||
if (! is_valid_ip_address (hostname))
|
||||
{
|
||||
gnutls_server_name_set (session, GNUTLS_NAME_DNS, hostname,
|
||||
strlen (hostname));
|
||||
strlen (hostname));
|
||||
}
|
||||
|
||||
gnutls_set_default_priority (session);
|
||||
@@ -391,7 +423,11 @@ ssl_connect_wget (int fd, const char *hostname)
|
||||
#ifndef FD_TO_SOCKET
|
||||
# define FD_TO_SOCKET(X) (X)
|
||||
#endif
|
||||
#ifdef HAVE_INTPTR_T
|
||||
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (intptr_t) FD_TO_SOCKET (fd));
|
||||
#else
|
||||
gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) FD_TO_SOCKET (fd));
|
||||
#endif
|
||||
|
||||
err = 0;
|
||||
#if HAVE_GNUTLS_PRIORITY_SET_DIRECT
|
||||
@@ -401,11 +437,17 @@ ssl_connect_wget (int fd, const char *hostname)
|
||||
break;
|
||||
case secure_protocol_sslv2:
|
||||
case secure_protocol_sslv3:
|
||||
err = gnutls_priority_set_direct (session, "NORMAL:-VERS-TLS-ALL", NULL);
|
||||
err = gnutls_priority_set_direct (session, "NORMAL:-VERS-TLS-ALL:+VERS-SSL3.0", NULL);
|
||||
break;
|
||||
case secure_protocol_tlsv1:
|
||||
err = gnutls_priority_set_direct (session, "NORMAL:-VERS-SSL3.0", NULL);
|
||||
break;
|
||||
case secure_protocol_pfs:
|
||||
err = gnutls_priority_set_direct (session, "PFS", NULL);
|
||||
if (err != GNUTLS_E_SUCCESS)
|
||||
/* fallback if PFS is not available */
|
||||
err = gnutls_priority_set_direct (session, "NORMAL:-RSA", NULL);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
@@ -440,10 +482,82 @@ ssl_connect_wget (int fd, const char *hostname)
|
||||
return false;
|
||||
}
|
||||
|
||||
err = gnutls_handshake (session);
|
||||
if (opt.connect_timeout)
|
||||
{
|
||||
#ifdef F_GETFL
|
||||
flags = fcntl (fd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
return flags;
|
||||
if (fcntl (fd, F_SETFL, flags | O_NONBLOCK))
|
||||
return -1;
|
||||
#else
|
||||
/* XXX: Assume it was blocking before. */
|
||||
const int one = 1;
|
||||
if (ioctl (fd, FIONBIO, &one) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We don't stop the handshake process for non-fatal errors */
|
||||
do
|
||||
{
|
||||
err = gnutls_handshake (session);
|
||||
|
||||
if (opt.connect_timeout && err == GNUTLS_E_AGAIN)
|
||||
{
|
||||
if (gnutls_record_get_direction (session))
|
||||
{
|
||||
/* wait for writeability */
|
||||
err = select_fd (fd, opt.connect_timeout, WAIT_FOR_WRITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* wait for readability */
|
||||
err = select_fd (fd, opt.connect_timeout, WAIT_FOR_READ);
|
||||
}
|
||||
|
||||
if (err <= 0)
|
||||
{
|
||||
if (err == 0)
|
||||
{
|
||||
errno = ETIMEDOUT;
|
||||
err = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
err = GNUTLS_E_AGAIN;
|
||||
}
|
||||
else if (err < 0)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, "GnuTLS: %s\n", gnutls_strerror (err));
|
||||
if (err == GNUTLS_E_WARNING_ALERT_RECEIVED ||
|
||||
err == GNUTLS_E_FATAL_ALERT_RECEIVED)
|
||||
{
|
||||
alert = gnutls_alert_get (session);
|
||||
str = gnutls_alert_get_name (alert);
|
||||
if (str == NULL)
|
||||
str = "(unknown)";
|
||||
logprintf (LOG_NOTQUIET, "GnuTLS: received alert [%d]: %s\n", alert, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (err && gnutls_error_is_fatal (err) == 0);
|
||||
|
||||
if (opt.connect_timeout)
|
||||
{
|
||||
#ifdef F_GETFL
|
||||
if (fcntl (fd, F_SETFL, flags) < 0)
|
||||
return -1;
|
||||
#else
|
||||
const int zero = 0;
|
||||
if (ioctl (fd, FIONBIO, &zero) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, "GnuTLS: %s\n", gnutls_strerror (err));
|
||||
gnutls_deinit (session);
|
||||
return false;
|
||||
}
|
||||
@@ -454,6 +568,14 @@ ssl_connect_wget (int fd, const char *hostname)
|
||||
return true;
|
||||
}
|
||||
|
||||
#define _CHECK_CERT(flag,msg) \
|
||||
if (status & (flag))\
|
||||
{\
|
||||
logprintf (LOG_NOTQUIET, (msg),\
|
||||
severity, quote (host));\
|
||||
success = false;\
|
||||
}
|
||||
|
||||
bool
|
||||
ssl_check_certificate (int fd, const char *host)
|
||||
{
|
||||
@@ -476,24 +598,13 @@ ssl_check_certificate (int fd, const char *host)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (status & GNUTLS_CERT_INVALID)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("%s: The certificate of %s is not trusted.\n"),
|
||||
severity, quote (host));
|
||||
success = false;
|
||||
}
|
||||
if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("%s: The certificate of %s hasn't got a known issuer.\n"),
|
||||
severity, quote (host));
|
||||
success = false;
|
||||
}
|
||||
if (status & GNUTLS_CERT_REVOKED)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("%s: The certificate of %s has been revoked.\n"),
|
||||
severity, quote (host));
|
||||
success = false;
|
||||
}
|
||||
_CHECK_CERT (GNUTLS_CERT_INVALID, _("%s: The certificate of %s is not trusted.\n"));
|
||||
_CHECK_CERT (GNUTLS_CERT_SIGNER_NOT_FOUND, _("%s: The certificate of %s hasn't got a known issuer.\n"));
|
||||
_CHECK_CERT (GNUTLS_CERT_REVOKED, _("%s: The certificate of %s has been revoked.\n"));
|
||||
_CHECK_CERT (GNUTLS_CERT_SIGNER_NOT_CA, _("%s: The certificate signer of %s was not a CA.\n"));
|
||||
_CHECK_CERT (GNUTLS_CERT_INSECURE_ALGORITHM, _("%s: The certificate of %s was signed using an insecure algorithm.\n"));
|
||||
_CHECK_CERT (GNUTLS_CERT_NOT_ACTIVATED, _("%s: The certificate of %s is not yet activated.\n"));
|
||||
_CHECK_CERT (GNUTLS_CERT_EXPIRED, _("%s: The certificate of %s has expired.\n"));
|
||||
|
||||
if (gnutls_certificate_type_get (ctx->session) == GNUTLS_CRT_X509)
|
||||
{
|
||||
@@ -515,7 +626,7 @@ ssl_check_certificate (int fd, const char *host)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("No certificate found\n"));
|
||||
success = false;
|
||||
goto out;
|
||||
goto crt_deinit;
|
||||
}
|
||||
err = gnutls_x509_crt_import (cert, cert_list, GNUTLS_X509_FMT_DER);
|
||||
if (err < 0)
|
||||
@@ -523,7 +634,7 @@ ssl_check_certificate (int fd, const char *host)
|
||||
logprintf (LOG_NOTQUIET, _("Error parsing certificate: %s\n"),
|
||||
gnutls_strerror (err));
|
||||
success = false;
|
||||
goto out;
|
||||
goto crt_deinit;
|
||||
}
|
||||
if (now < gnutls_x509_crt_get_activation_time (cert))
|
||||
{
|
||||
@@ -542,8 +653,14 @@ ssl_check_certificate (int fd, const char *host)
|
||||
quote (host));
|
||||
success = false;
|
||||
}
|
||||
crt_deinit:
|
||||
gnutls_x509_crt_deinit (cert);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("Certificate must be X.509\n"));
|
||||
success = false;
|
||||
}
|
||||
|
||||
out:
|
||||
return opt.check_cert ? success : true;
|
||||
|
||||
@@ -79,7 +79,10 @@ enum {
|
||||
TAG_SCRIPT,
|
||||
TAG_TABLE,
|
||||
TAG_TD,
|
||||
TAG_TH
|
||||
TAG_TH,
|
||||
TAG_VIDEO,
|
||||
TAG_AUDIO,
|
||||
TAG_SOURCE
|
||||
};
|
||||
|
||||
/* The list of known tags and functions used for handling them. Most
|
||||
@@ -110,7 +113,10 @@ static struct known_tag {
|
||||
{ TAG_SCRIPT, "script", tag_find_urls },
|
||||
{ TAG_TABLE, "table", tag_find_urls },
|
||||
{ TAG_TD, "td", tag_find_urls },
|
||||
{ TAG_TH, "th", tag_find_urls }
|
||||
{ TAG_TH, "th", tag_find_urls },
|
||||
{ TAG_VIDEO, "video", tag_find_urls },
|
||||
{ TAG_AUDIO, "audio", tag_find_urls },
|
||||
{ TAG_SOURCE, "source", tag_find_urls }
|
||||
};
|
||||
|
||||
/* tag_url_attributes documents which attributes of which tags contain
|
||||
@@ -157,7 +163,12 @@ static struct {
|
||||
{ TAG_SCRIPT, "src", ATTR_INLINE },
|
||||
{ TAG_TABLE, "background", ATTR_INLINE },
|
||||
{ TAG_TD, "background", ATTR_INLINE },
|
||||
{ TAG_TH, "background", ATTR_INLINE }
|
||||
{ TAG_TH, "background", ATTR_INLINE },
|
||||
{ TAG_VIDEO, "src", ATTR_INLINE },
|
||||
{ TAG_VIDEO, "poster", ATTR_INLINE },
|
||||
{ TAG_AUDIO, "src", ATTR_INLINE },
|
||||
{ TAG_AUDIO, "poster", ATTR_INLINE },
|
||||
{ TAG_SOURCE, "src", ATTR_INLINE }
|
||||
};
|
||||
|
||||
/* The lists of interesting tags and attributes are built dynamically,
|
||||
@@ -273,6 +284,10 @@ append_url (const char *link_uri, int position, int size,
|
||||
const char *base = ctx->base ? ctx->base : ctx->parent_base;
|
||||
struct url *url;
|
||||
|
||||
struct iri *iri = iri_new ();
|
||||
set_uri_encoding (iri, opt.locale, true);
|
||||
iri->utf8_encode = true;
|
||||
|
||||
if (!base)
|
||||
{
|
||||
DEBUGP (("%s: no base, merge will use \"%s\".\n",
|
||||
@@ -290,7 +305,7 @@ append_url (const char *link_uri, int position, int size,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
url = url_parse (link_uri, NULL, NULL, false);
|
||||
url = url_parse (link_uri, NULL, iri, false);
|
||||
if (!url)
|
||||
{
|
||||
DEBUGP (("%s: link \"%s\" doesn't parse.\n",
|
||||
@@ -312,7 +327,7 @@ append_url (const char *link_uri, int position, int size,
|
||||
quote_n (2, link_uri),
|
||||
quotearg_n_style (3, escape_quoting_style, complete_uri)));
|
||||
|
||||
url = url_parse (complete_uri, NULL, NULL, false);
|
||||
url = url_parse (complete_uri, NULL, iri, false);
|
||||
if (!url)
|
||||
{
|
||||
DEBUGP (("%s: merged link \"%s\" doesn't parse.\n",
|
||||
@@ -323,6 +338,8 @@ append_url (const char *link_uri, int position, int size,
|
||||
xfree (complete_uri);
|
||||
}
|
||||
|
||||
iri_free (iri);
|
||||
|
||||
DEBUGP (("appending %s to urlpos.\n", quote (url->url)));
|
||||
|
||||
newel = xnew0 (struct urlpos);
|
||||
@@ -804,6 +821,13 @@ get_urls_file (const char *file)
|
||||
url_text = merged;
|
||||
}
|
||||
|
||||
char *new_url = rewrite_shorthand_url (url_text);
|
||||
if (new_url)
|
||||
{
|
||||
xfree (url_text);
|
||||
url_text = new_url;
|
||||
}
|
||||
|
||||
url = url_parse (url_text, &up_error_code, NULL, false);
|
||||
if (!url)
|
||||
{
|
||||
@@ -830,7 +854,7 @@ get_urls_file (const char *file)
|
||||
return head;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cleanup_html_url (void)
|
||||
{
|
||||
/* Destroy the hash tables. The hash table keys and values are not
|
||||
|
||||
@@ -42,27 +42,33 @@ as that of the covered work. */
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/md4.h>
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "http-ntlm.h"
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x00907001L
|
||||
#define DES_key_schedule des_key_schedule
|
||||
#define DES_cblock des_cblock
|
||||
#define DES_set_odd_parity des_set_odd_parity
|
||||
#define DES_set_key des_set_key
|
||||
#define DES_ecb_encrypt des_ecb_encrypt
|
||||
#ifdef HAVE_NETTLE
|
||||
# include <nettle/md4.h>
|
||||
# include <nettle/des.h>
|
||||
#else
|
||||
# include <openssl/des.h>
|
||||
# include <openssl/md4.h>
|
||||
# include <openssl/opensslv.h>
|
||||
|
||||
# if OPENSSL_VERSION_NUMBER < 0x00907001L
|
||||
# define DES_key_schedule des_key_schedule
|
||||
# define DES_cblock des_cblock
|
||||
# define DES_set_odd_parity des_set_odd_parity
|
||||
# define DES_set_key des_set_key
|
||||
# define DES_ecb_encrypt des_ecb_encrypt
|
||||
|
||||
/* This is how things were done in the old days */
|
||||
#define DESKEY(x) x
|
||||
#define DESKEYARG(x) x
|
||||
#else
|
||||
# define DESKEY(x) x
|
||||
# define DESKEYARG(x) x
|
||||
# else
|
||||
/* Modern version */
|
||||
#define DESKEYARG(x) *x
|
||||
#define DESKEY(x) &x
|
||||
# define DESKEYARG(x) *x
|
||||
# define DESKEY(x) &x
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Define this to make the type-3 message include the NT response message */
|
||||
@@ -176,6 +182,25 @@ ntlm_input (struct ntlmdata *ntlm, const char *header)
|
||||
* Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The
|
||||
* key schedule ks is also set.
|
||||
*/
|
||||
#ifdef HAVE_NETTLE
|
||||
static void
|
||||
setup_des_key(unsigned char *key_56,
|
||||
struct des_ctx *des)
|
||||
{
|
||||
unsigned char key[8];
|
||||
|
||||
key[0] = key_56[0];
|
||||
key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1);
|
||||
key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2);
|
||||
key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3);
|
||||
key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4);
|
||||
key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5);
|
||||
key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6);
|
||||
key[7] = (key_56[6] << 1) & 0xFF;
|
||||
|
||||
nettle_des_set_key(des, key);
|
||||
}
|
||||
#else
|
||||
static void
|
||||
setup_des_key(unsigned char *key_56,
|
||||
DES_key_schedule DESKEYARG(ks))
|
||||
@@ -194,6 +219,7 @@ setup_des_key(unsigned char *key_56,
|
||||
DES_set_odd_parity(&key);
|
||||
DES_set_key(&key, ks);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* takes a 21 byte array and treats it as 3 56-bit DES keys. The
|
||||
@@ -203,6 +229,18 @@ setup_des_key(unsigned char *key_56,
|
||||
static void
|
||||
calc_resp(unsigned char *keys, unsigned char *plaintext, unsigned char *results)
|
||||
{
|
||||
#ifdef HAVE_NETTLE
|
||||
struct des_ctx des;
|
||||
|
||||
setup_des_key(keys, &des);
|
||||
nettle_des_encrypt(&des, 8, results, plaintext);
|
||||
|
||||
setup_des_key(keys + 7, &des);
|
||||
nettle_des_encrypt(&des, 8, results + 8, plaintext);
|
||||
|
||||
setup_des_key(keys + 14, &des);
|
||||
nettle_des_encrypt(&des, 8, results + 16, plaintext);
|
||||
#else
|
||||
DES_key_schedule ks;
|
||||
|
||||
setup_des_key(keys, DESKEY(ks));
|
||||
@@ -216,6 +254,7 @@ calc_resp(unsigned char *keys, unsigned char *plaintext, unsigned char *results)
|
||||
setup_des_key(keys+14, DESKEY(ks));
|
||||
DES_ecb_encrypt((DES_cblock*) plaintext, (DES_cblock*) (results+16),
|
||||
DESKEY(ks), DES_ENCRYPT);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -255,6 +294,15 @@ mkhash(const char *password,
|
||||
|
||||
{
|
||||
/* create LanManager hashed password */
|
||||
#ifdef HAVE_NETTLE
|
||||
struct des_ctx des;
|
||||
|
||||
setup_des_key(pw, &des);
|
||||
nettle_des_encrypt(&des, 8, lmbuffer, magic);
|
||||
|
||||
setup_des_key(pw + 7, &des);
|
||||
nettle_des_encrypt(&des, 8, lmbuffer + 8, magic);
|
||||
#else
|
||||
DES_key_schedule ks;
|
||||
|
||||
setup_des_key(pw, DESKEY(ks));
|
||||
@@ -264,6 +312,7 @@ mkhash(const char *password,
|
||||
setup_des_key(pw+7, DESKEY(ks));
|
||||
DES_ecb_encrypt((DES_cblock *)magic, (DES_cblock *)(lmbuffer+8),
|
||||
DESKEY(ks), DES_ENCRYPT);
|
||||
#endif
|
||||
|
||||
memset(lmbuffer+16, 0, 5);
|
||||
}
|
||||
@@ -272,8 +321,11 @@ mkhash(const char *password,
|
||||
|
||||
#ifdef USE_NTRESPONSES
|
||||
{
|
||||
/* create NT hashed password */
|
||||
#ifdef HAVE_NETTLE
|
||||
struct md4_ctx MD4;
|
||||
#else
|
||||
MD4_CTX MD4;
|
||||
#endif
|
||||
|
||||
len = strlen(password);
|
||||
|
||||
@@ -282,9 +334,16 @@ mkhash(const char *password,
|
||||
pw[2*i+1] = 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_NETTLE
|
||||
nettle_md4_init(&MD4);
|
||||
nettle_md4_update(&MD4, 2*len, pw);
|
||||
nettle_md4_digest(&MD4, MD4_DIGEST_SIZE, ntbuffer);
|
||||
#else
|
||||
/* create NT hashed password */
|
||||
MD4_Init(&MD4);
|
||||
MD4_Update(&MD4, pw, 2*len);
|
||||
MD4_Final(ntbuffer, &MD4);
|
||||
#endif
|
||||
|
||||
memset(ntbuffer+16, 0, 5);
|
||||
}
|
||||
|
||||
313
src/http.c
313
src/http.c
@@ -74,7 +74,7 @@ extern char *version_string;
|
||||
struct http_stat;
|
||||
static char *create_authorization_line (const char *, const char *,
|
||||
const char *, const char *,
|
||||
const char *, bool *);
|
||||
const char *, bool *, uerr_t *);
|
||||
static char *basic_authentication_encode (const char *, const char *);
|
||||
static bool known_authentication_scheme_p (const char *, const char *);
|
||||
static void ensure_extension (struct http_stat *, const char *, int *);
|
||||
@@ -147,27 +147,20 @@ struct request {
|
||||
|
||||
extern int numurls;
|
||||
|
||||
/* Create a new, empty request. At least request_set_method must be
|
||||
called before the request can be used. */
|
||||
/* Create a new, empty request. Set the request's method and its
|
||||
arguments. METHOD should be a literal string (or it should outlive
|
||||
the request) because it will not be freed. ARG will be freed by
|
||||
request_free. */
|
||||
|
||||
static struct request *
|
||||
request_new (void)
|
||||
request_new (const char *method, char *arg)
|
||||
{
|
||||
struct request *req = xnew0 (struct request);
|
||||
req->hcapacity = 8;
|
||||
req->headers = xnew_array (struct request_header, req->hcapacity);
|
||||
return req;
|
||||
}
|
||||
|
||||
/* Set the request's method and its arguments. METH should be a
|
||||
literal string (or it should outlive the request) because it will
|
||||
not be freed. ARG will be freed by request_free. */
|
||||
|
||||
static void
|
||||
request_set_method (struct request *req, const char *meth, char *arg)
|
||||
{
|
||||
req->method = meth;
|
||||
req->method = method;
|
||||
req->arg = arg;
|
||||
return req;
|
||||
}
|
||||
|
||||
/* Return the method string passed with the last call to
|
||||
@@ -459,14 +452,14 @@ register_basic_auth_host (const char *hostname)
|
||||
also be written to that file. */
|
||||
|
||||
static int
|
||||
post_file (int sock, const char *file_name, wgint promised_size, FILE *warc_tmp)
|
||||
body_file_send (int sock, const char *file_name, wgint promised_size, FILE *warc_tmp)
|
||||
{
|
||||
static char chunk[8192];
|
||||
wgint written = 0;
|
||||
int write_error;
|
||||
FILE *fp;
|
||||
|
||||
DEBUGP (("[writing POST file %s ... ", file_name));
|
||||
DEBUGP (("[writing BODY file %s ... ", file_name));
|
||||
|
||||
fp = fopen (file_name, "rb");
|
||||
if (!fp)
|
||||
@@ -931,8 +924,6 @@ skip_short_body (int fd, wgint contlen, bool chunked)
|
||||
char dlbuf[SKIP_SIZE + 1];
|
||||
dlbuf[SKIP_SIZE] = '\0'; /* so DEBUGP can safely print it */
|
||||
|
||||
assert (contlen != -1 || contlen);
|
||||
|
||||
/* If the body is too large, it makes more sense to simply close the
|
||||
connection than to try to read the body. */
|
||||
if (contlen > SKIP_THRESHOLD)
|
||||
@@ -1648,12 +1639,6 @@ read_response_body (struct http_stat *hs, int sock, FILE *fp, wgint contlen,
|
||||
} while (0)
|
||||
#endif /* def __VMS [else] */
|
||||
|
||||
/* The flags that allow clobbering the file (opening with "wb").
|
||||
Defined here to avoid repetition later. #### This will require
|
||||
rework. */
|
||||
#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
|
||||
|| opt.dirstruct || opt.output_document)
|
||||
|
||||
/* Retrieve a document through HTTP protocol. It recognizes status
|
||||
code, and correctly handles redirections. It closes the network
|
||||
socket. If it receives an error from the functions below it, it
|
||||
@@ -1703,7 +1688,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
|
||||
char *head;
|
||||
struct response *resp;
|
||||
char hdrval[256];
|
||||
char hdrval[512];
|
||||
char *message;
|
||||
|
||||
/* Declare WARC variables. */
|
||||
@@ -1726,7 +1711,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
!opt.http_keep_alive || opt.ignore_length;
|
||||
|
||||
/* Headers sent when using POST. */
|
||||
wgint post_data_size = 0;
|
||||
wgint body_data_size = 0;
|
||||
|
||||
bool host_lookup_failed = false;
|
||||
|
||||
@@ -1758,15 +1743,13 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
conn = u;
|
||||
|
||||
/* Prepare the request to send. */
|
||||
|
||||
req = request_new ();
|
||||
{
|
||||
char *meth_arg;
|
||||
const char *meth = "GET";
|
||||
if (head_only)
|
||||
meth = "HEAD";
|
||||
else if (opt.post_file_name || opt.post_data)
|
||||
meth = "POST";
|
||||
else if (opt.method)
|
||||
meth = opt.method;
|
||||
/* Use the full path, i.e. one that includes the leading slash and
|
||||
the query string. E.g. if u->path is "foo/bar" and u->query is
|
||||
"param=value", full_path will be "/foo/bar?param=value". */
|
||||
@@ -1781,7 +1764,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
meth_arg = xstrdup (u->url);
|
||||
else
|
||||
meth_arg = url_full_path (u);
|
||||
request_set_method (req, meth, meth_arg);
|
||||
req = request_new (meth, meth_arg);
|
||||
}
|
||||
|
||||
request_set_header (req, "Referer", (char *) hs->referer, rel_none);
|
||||
@@ -1852,25 +1835,30 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
}
|
||||
}
|
||||
|
||||
if (opt.post_data || opt.post_file_name)
|
||||
if (opt.method)
|
||||
{
|
||||
request_set_header (req, "Content-Type",
|
||||
"application/x-www-form-urlencoded", rel_none);
|
||||
if (opt.post_data)
|
||||
post_data_size = strlen (opt.post_data);
|
||||
else
|
||||
|
||||
if (opt.body_data || opt.body_file)
|
||||
{
|
||||
post_data_size = file_size (opt.post_file_name);
|
||||
if (post_data_size == -1)
|
||||
request_set_header (req, "Content-Type",
|
||||
"application/x-www-form-urlencoded", rel_none);
|
||||
|
||||
if (opt.body_data)
|
||||
body_data_size = strlen (opt.body_data);
|
||||
else
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("POST data file %s missing: %s\n"),
|
||||
quote (opt.post_file_name), strerror (errno));
|
||||
post_data_size = 0;
|
||||
body_data_size = file_size (opt.body_file);
|
||||
if (body_data_size == -1)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("BODY data file %s missing: %s\n"),
|
||||
quote (opt.body_file), strerror (errno));
|
||||
return FILEBADFILE;
|
||||
}
|
||||
}
|
||||
request_set_header (req, "Content-Length",
|
||||
xstrdup (number_to_static_string (body_data_size)),
|
||||
rel_value);
|
||||
}
|
||||
request_set_header (req, "Content-Length",
|
||||
xstrdup (number_to_static_string (post_data_size)),
|
||||
rel_value);
|
||||
}
|
||||
|
||||
retry_with_auth:
|
||||
@@ -1962,11 +1950,13 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
int family = socket_family (pconn.socket, ENDPOINT_PEER);
|
||||
sock = pconn.socket;
|
||||
using_ssl = pconn.ssl;
|
||||
#if ENABLE_IPV6
|
||||
if (family == AF_INET6)
|
||||
logprintf (LOG_VERBOSE, _("Reusing existing connection to [%s]:%d.\n"),
|
||||
quotearg_style (escape_quoting_style, pconn.host),
|
||||
pconn.port);
|
||||
else
|
||||
#endif
|
||||
logprintf (LOG_VERBOSE, _("Reusing existing connection to %s:%d.\n"),
|
||||
quotearg_style (escape_quoting_style, pconn.host),
|
||||
pconn.port);
|
||||
@@ -1985,6 +1975,10 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
exec_name, quote (relevant->host));
|
||||
return HOSTERR;
|
||||
}
|
||||
else if (sock != -1)
|
||||
{
|
||||
sock = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sock < 0)
|
||||
@@ -2007,8 +2001,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
{
|
||||
/* When requesting SSL URLs through proxies, use the
|
||||
CONNECT method to request passthrough. */
|
||||
struct request *connreq = request_new ();
|
||||
request_set_method (connreq, "CONNECT",
|
||||
struct request *connreq = request_new ("CONNECT",
|
||||
aprintf ("%s:%d", u->host, u->port));
|
||||
SET_USER_AGENT (connreq);
|
||||
if (proxyauth)
|
||||
@@ -2020,10 +2013,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
the regular request below. */
|
||||
proxyauth = NULL;
|
||||
}
|
||||
/* Examples in rfc2817 use the Host header in CONNECT
|
||||
requests. I don't see how that gains anything, given
|
||||
that the contents of Host would be exactly the same as
|
||||
the contents of CONNECT. */
|
||||
request_set_header (connreq, "Host",
|
||||
aprintf ("%s:%d", u->host, u->port),
|
||||
rel_value);
|
||||
|
||||
write_error = request_send (connreq, sock, 0);
|
||||
request_free (connreq);
|
||||
@@ -2126,28 +2118,28 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
|
||||
if (write_error >= 0)
|
||||
{
|
||||
if (opt.post_data)
|
||||
if (opt.body_data)
|
||||
{
|
||||
DEBUGP (("[POST data: %s]\n", opt.post_data));
|
||||
write_error = fd_write (sock, opt.post_data, post_data_size, -1);
|
||||
DEBUGP (("[BODY data: %s]\n", opt.body_data));
|
||||
write_error = fd_write (sock, opt.body_data, body_data_size, -1);
|
||||
if (write_error >= 0 && warc_tmp != NULL)
|
||||
{
|
||||
/* Remember end of headers / start of payload. */
|
||||
warc_payload_offset = ftello (warc_tmp);
|
||||
|
||||
/* Write a copy of the data to the WARC record. */
|
||||
int warc_tmp_written = fwrite (opt.post_data, 1, post_data_size, warc_tmp);
|
||||
if (warc_tmp_written != post_data_size)
|
||||
int warc_tmp_written = fwrite (opt.body_data, 1, body_data_size, warc_tmp);
|
||||
if (warc_tmp_written != body_data_size)
|
||||
write_error = -2;
|
||||
}
|
||||
}
|
||||
else if (opt.post_file_name && post_data_size != 0)
|
||||
}
|
||||
else if (opt.body_file && body_data_size != 0)
|
||||
{
|
||||
if (warc_tmp != NULL)
|
||||
/* Remember end of headers / start of payload. */
|
||||
/* Remember end of headers / start of payload */
|
||||
warc_payload_offset = ftello (warc_tmp);
|
||||
|
||||
write_error = post_file (sock, opt.post_file_name, post_data_size, warc_tmp);
|
||||
write_error = body_file_send (sock, opt.body_file, body_data_size, warc_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2355,6 +2347,7 @@ read_header:
|
||||
}
|
||||
|
||||
pconn.authorized = false;
|
||||
uerr_t auth_err = RETROK;
|
||||
if (!auth_finished && (user && passwd))
|
||||
{
|
||||
/* IIS sends multiple copies of WWW-Authenticate, one with
|
||||
@@ -2382,28 +2375,44 @@ read_header:
|
||||
else if (!basic_auth_finished
|
||||
|| !BEGINS_WITH (www_authenticate, "Basic"))
|
||||
{
|
||||
char *pth;
|
||||
pth = url_full_path (u);
|
||||
request_set_header (req, "Authorization",
|
||||
create_authorization_line (www_authenticate,
|
||||
user, passwd,
|
||||
request_method (req),
|
||||
pth,
|
||||
&auth_finished),
|
||||
rel_value);
|
||||
if (BEGINS_WITH (www_authenticate, "NTLM"))
|
||||
ntlm_seen = true;
|
||||
else if (!u->user && BEGINS_WITH (www_authenticate, "Basic"))
|
||||
char *pth = url_full_path (u);
|
||||
const char *value;
|
||||
uerr_t *auth_stat;
|
||||
auth_stat = xmalloc (sizeof (uerr_t));
|
||||
*auth_stat = RETROK;
|
||||
|
||||
value = create_authorization_line (www_authenticate,
|
||||
user, passwd,
|
||||
request_method (req),
|
||||
pth,
|
||||
&auth_finished,
|
||||
auth_stat);
|
||||
|
||||
auth_err = *auth_stat;
|
||||
if (auth_err == RETROK)
|
||||
{
|
||||
/* Need to register this host as using basic auth,
|
||||
* so we automatically send creds next time. */
|
||||
register_basic_auth_host (u->host);
|
||||
request_set_header (req, "Authorization", value, rel_value);
|
||||
|
||||
if (BEGINS_WITH (www_authenticate, "NTLM"))
|
||||
ntlm_seen = true;
|
||||
else if (!u->user && BEGINS_WITH (www_authenticate, "Basic"))
|
||||
{
|
||||
/* Need to register this host as using basic auth,
|
||||
* so we automatically send creds next time. */
|
||||
register_basic_auth_host (u->host);
|
||||
}
|
||||
|
||||
xfree (pth);
|
||||
xfree_null (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
xfree (auth_stat);
|
||||
goto retry_with_auth;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Creating the Authorization header went wrong */
|
||||
}
|
||||
xfree (pth);
|
||||
xfree_null (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
goto retry_with_auth;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2411,12 +2420,14 @@ read_header:
|
||||
* give up. */
|
||||
}
|
||||
}
|
||||
logputs (LOG_NOTQUIET, _("Authorization failed.\n"));
|
||||
request_free (req);
|
||||
xfree_null (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
return AUTHFAILED;
|
||||
if (auth_err == RETROK)
|
||||
return AUTHFAILED;
|
||||
else
|
||||
return auth_err;
|
||||
}
|
||||
else /* statcode != HTTP_STATUS_UNAUTHORIZED */
|
||||
{
|
||||
@@ -2644,12 +2655,35 @@ read_header:
|
||||
/* From RFC2616: The status codes 303 and 307 have
|
||||
been added for servers that wish to make unambiguously
|
||||
clear which kind of reaction is expected of the client.
|
||||
|
||||
|
||||
A 307 should be redirected using the same method,
|
||||
in other words, a POST should be preserved and not
|
||||
converted to a GET in that case. */
|
||||
if (statcode == HTTP_STATUS_TEMPORARY_REDIRECT)
|
||||
return NEWLOCATION_KEEP_POST;
|
||||
converted to a GET in that case.
|
||||
|
||||
With strict adherence to RFC2616, POST requests are not
|
||||
converted to a GET request on 301 Permanent Redirect
|
||||
or 302 Temporary Redirect.
|
||||
|
||||
A switch may be provided later based on the HTTPbis draft
|
||||
that allows clients to convert POST requests to GET
|
||||
requests on 301 and 302 response codes. */
|
||||
switch (statcode)
|
||||
{
|
||||
case HTTP_STATUS_TEMPORARY_REDIRECT:
|
||||
return NEWLOCATION_KEEP_POST;
|
||||
break;
|
||||
case HTTP_STATUS_MOVED_PERMANENTLY:
|
||||
if (opt.method && strcasecmp (opt.method, "post") != 0)
|
||||
return NEWLOCATION_KEEP_POST;
|
||||
break;
|
||||
case HTTP_STATUS_MOVED_TEMPORARILY:
|
||||
if (opt.method && strcasecmp (opt.method, "post") != 0)
|
||||
return NEWLOCATION_KEEP_POST;
|
||||
break;
|
||||
default:
|
||||
return NEWLOCATION;
|
||||
break;
|
||||
}
|
||||
return NEWLOCATION;
|
||||
}
|
||||
}
|
||||
@@ -3002,9 +3036,17 @@ http_loop (struct url *u, struct url *original_url, char **newloc,
|
||||
if (!opt.spider)
|
||||
send_head_first = false;
|
||||
|
||||
/* Send preliminary HEAD request if --content-disposition and -c are used
|
||||
together. */
|
||||
if (opt.content_disposition && opt.always_rest)
|
||||
send_head_first = true;
|
||||
|
||||
/* Send preliminary HEAD request if -N is given and we have an existing
|
||||
* destination file. */
|
||||
file_name = url_file_name (opt.trustservernames ? u : original_url, NULL);
|
||||
if (!opt.output_document)
|
||||
file_name = url_file_name (opt.trustservernames ? u : original_url, NULL);
|
||||
else
|
||||
file_name = xstrdup (opt.output_document);
|
||||
if (opt.timestamping && (file_exists_p (file_name)
|
||||
|| opt.content_disposition))
|
||||
send_head_first = true;
|
||||
@@ -3110,11 +3152,23 @@ Spider mode enabled. Check if remote file exists.\n"));
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("Cannot write to %s (%s).\n"),
|
||||
quote (hstat.local_file), strerror (errno));
|
||||
case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED:
|
||||
case SSLINITFAILED: case CONTNOTSUPPORTED: case VERIFCERTERR:
|
||||
case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case SSLINITFAILED:
|
||||
case CONTNOTSUPPORTED: case VERIFCERTERR: case FILEBADFILE:
|
||||
case UNKNOWNATTR:
|
||||
/* Fatal errors just return from the function. */
|
||||
ret = err;
|
||||
goto exit;
|
||||
case ATTRMISSING:
|
||||
/* A missing attribute in a Header is a fatal Protocol error. */
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("Required attribute missing from Header received.\n"));
|
||||
ret = err;
|
||||
goto exit;
|
||||
case AUTHFAILED:
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
logprintf (LOG_NOTQUIET, _("Username/Password Authentication Failed.\n"));
|
||||
ret = err;
|
||||
goto exit;
|
||||
case WARC_ERR:
|
||||
/* A fatal WARC error. */
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
@@ -3653,9 +3707,9 @@ dump_hash (char *buf, const unsigned char *hash)
|
||||
static char *
|
||||
digest_authentication_encode (const char *au, const char *user,
|
||||
const char *passwd, const char *method,
|
||||
const char *path)
|
||||
const char *path, uerr_t *auth_err)
|
||||
{
|
||||
static char *realm, *opaque, *nonce, *qop;
|
||||
static char *realm, *opaque, *nonce, *qop, *algorithm;
|
||||
static struct {
|
||||
const char *name;
|
||||
char **variable;
|
||||
@@ -3663,15 +3717,17 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
{ "realm", &realm },
|
||||
{ "opaque", &opaque },
|
||||
{ "nonce", &nonce },
|
||||
{ "qop", &qop }
|
||||
{ "qop", &qop },
|
||||
{ "algorithm", &algorithm }
|
||||
};
|
||||
char cnonce[16] = "";
|
||||
char *res;
|
||||
int res_len;
|
||||
size_t res_size;
|
||||
param_token name, value;
|
||||
|
||||
|
||||
realm = opaque = nonce = qop = NULL;
|
||||
realm = opaque = nonce = algorithm = qop = NULL;
|
||||
|
||||
au += 6; /* skip over `Digest' */
|
||||
while (extract_param (&au, &name, &value, ','))
|
||||
@@ -3691,15 +3747,27 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
if (qop != NULL && strcmp(qop,"auth"))
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("Unsupported quality of protection '%s'.\n"), qop);
|
||||
user = NULL; /* force freeing mem and return */
|
||||
xfree_null (qop); /* force freeing mem and return */
|
||||
qop = NULL;
|
||||
}
|
||||
else if (algorithm != NULL && strcmp (algorithm,"MD5") && strcmp (algorithm,"MD5-sess"))
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("Unsupported algorithm '%s'.\n"), algorithm);
|
||||
xfree_null (qop); /* force freeing mem and return */
|
||||
qop = NULL;
|
||||
}
|
||||
|
||||
if (!realm || !nonce || !user || !passwd || !path || !method)
|
||||
if (!realm || !nonce || !user || !passwd || !path || !method || !qop)
|
||||
{
|
||||
xfree_null (realm);
|
||||
xfree_null (opaque);
|
||||
xfree_null (nonce);
|
||||
xfree_null (qop);
|
||||
xfree_null (algorithm);
|
||||
if (!qop)
|
||||
*auth_err = UNKNOWNATTR;
|
||||
else
|
||||
*auth_err = ATTRMISSING;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3718,8 +3786,26 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
md5_process_bytes ((unsigned char *)":", 1, &ctx);
|
||||
md5_process_bytes ((unsigned char *)passwd, strlen (passwd), &ctx);
|
||||
md5_finish_ctx (&ctx, hash);
|
||||
|
||||
dump_hash (a1buf, hash);
|
||||
|
||||
if (algorithm && !strcmp (algorithm, "MD5-sess"))
|
||||
{
|
||||
/* A1BUF = H( H(user ":" realm ":" password) ":" nonce ":" cnonce ) */
|
||||
snprintf (cnonce, sizeof (cnonce), "%08x", random_number(INT_MAX));
|
||||
|
||||
md5_init_ctx (&ctx);
|
||||
// md5_process_bytes (hash, MD5_DIGEST_SIZE, &ctx);
|
||||
md5_process_bytes (a1buf, MD5_DIGEST_SIZE * 2, &ctx);
|
||||
md5_process_bytes ((unsigned char *)":", 1, &ctx);
|
||||
md5_process_bytes ((unsigned char *)nonce, strlen (nonce), &ctx);
|
||||
md5_process_bytes ((unsigned char *)":", 1, &ctx);
|
||||
md5_process_bytes ((unsigned char *)cnonce, strlen (cnonce), &ctx);
|
||||
md5_finish_ctx (&ctx, hash);
|
||||
|
||||
dump_hash (a1buf, hash);
|
||||
}
|
||||
|
||||
/* A2BUF = H(method ":" path) */
|
||||
md5_init_ctx (&ctx);
|
||||
md5_process_bytes ((unsigned char *)method, strlen (method), &ctx);
|
||||
@@ -3728,11 +3814,12 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
md5_finish_ctx (&ctx, hash);
|
||||
dump_hash (a2buf, hash);
|
||||
|
||||
if (!strcmp(qop,"auth"))
|
||||
if (qop && (!strcmp(qop, "auth") || !strcmp (qop, "auth-int")))
|
||||
{
|
||||
/* RFC 2617 Digest Access Authentication */
|
||||
/* generate random hex string */
|
||||
snprintf(cnonce, sizeof(cnonce), "%08x", random_number(INT_MAX));
|
||||
if (!*cnonce)
|
||||
snprintf(cnonce, sizeof(cnonce), "%08x", random_number(INT_MAX));
|
||||
|
||||
/* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" noncecount ":" clientnonce ":" qop ": " A2BUF) */
|
||||
md5_init_ctx (&ctx);
|
||||
@@ -3765,20 +3852,21 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
dump_hash (response_digest, hash);
|
||||
|
||||
res_size = strlen (user)
|
||||
+ strlen (user)
|
||||
+ strlen (realm)
|
||||
+ strlen (nonce)
|
||||
+ strlen (path)
|
||||
+ 2 * MD5_DIGEST_SIZE /*strlen (response_digest)*/
|
||||
+ (opaque ? strlen (opaque) : 0)
|
||||
+ (algorithm ? strlen (algorithm) : 0)
|
||||
+ (qop ? 128: 0)
|
||||
+ strlen (cnonce)
|
||||
+ 128;
|
||||
|
||||
res = xmalloc (res_size);
|
||||
|
||||
if (!strcmp(qop,"auth"))
|
||||
if (qop && !strcmp (qop, "auth"))
|
||||
{
|
||||
snprintf (res, res_size, "Digest "\
|
||||
res_len = snprintf (res, res_size, "Digest "\
|
||||
"username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\""\
|
||||
", qop=auth, nc=00000001, cnonce=\"%s\"",
|
||||
user, realm, nonce, path, response_digest, cnonce);
|
||||
@@ -3786,19 +3874,28 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (res, res_size, "Digest "\
|
||||
res_len = snprintf (res, res_size, "Digest "\
|
||||
"username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"",
|
||||
user, realm, nonce, path, response_digest);
|
||||
}
|
||||
|
||||
if (opaque)
|
||||
{
|
||||
char *p = res + strlen (res);
|
||||
strcat (p, ", opaque=\"");
|
||||
strcat (p, opaque);
|
||||
strcat (p, "\"");
|
||||
res_len += snprintf(res + res_len, res_size - res_len, ", opaque=\"%s\"", opaque);
|
||||
}
|
||||
|
||||
if (algorithm)
|
||||
{
|
||||
snprintf(res + res_len, res_size - res_len, ", algorithm=\"%s\"", algorithm);
|
||||
}
|
||||
}
|
||||
|
||||
xfree_null (realm);
|
||||
xfree_null (opaque);
|
||||
xfree_null (nonce);
|
||||
xfree_null (qop);
|
||||
xfree_null (algorithm);
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif /* ENABLE_DIGEST */
|
||||
@@ -3840,7 +3937,7 @@ known_authentication_scheme_p (const char *hdrbeg, const char *hdrend)
|
||||
static char *
|
||||
create_authorization_line (const char *au, const char *user,
|
||||
const char *passwd, const char *method,
|
||||
const char *path, bool *finished)
|
||||
const char *path, bool *finished, uerr_t *auth_err)
|
||||
{
|
||||
/* We are called only with known schemes, so we can dispatch on the
|
||||
first letter. */
|
||||
@@ -3852,7 +3949,7 @@ create_authorization_line (const char *au, const char *user,
|
||||
#ifdef ENABLE_DIGEST
|
||||
case 'D': /* Digest */
|
||||
*finished = true;
|
||||
return digest_authentication_encode (au, user, passwd, method, path);
|
||||
return digest_authentication_encode (au, user, passwd, method, path, auth_err);
|
||||
#endif
|
||||
#ifdef ENABLE_NTLM
|
||||
case 'N': /* NTLM */
|
||||
|
||||
42
src/init.c
42
src/init.c
@@ -87,6 +87,7 @@ CMD_DECLARE (cmd_directory_vector);
|
||||
CMD_DECLARE (cmd_number);
|
||||
CMD_DECLARE (cmd_number_inf);
|
||||
CMD_DECLARE (cmd_string);
|
||||
CMD_DECLARE (cmd_string_uppercase);
|
||||
CMD_DECLARE (cmd_file);
|
||||
CMD_DECLARE (cmd_directory);
|
||||
CMD_DECLARE (cmd_time);
|
||||
@@ -136,6 +137,8 @@ static const struct {
|
||||
{ "backups", &opt.backups, cmd_number },
|
||||
{ "base", &opt.base_href, cmd_string },
|
||||
{ "bindaddress", &opt.bind_address, cmd_string },
|
||||
{ "bodydata", &opt.body_data, cmd_string },
|
||||
{ "bodyfile", &opt.body_file, cmd_string },
|
||||
#ifdef HAVE_SSL
|
||||
{ "cacertificate", &opt.ca_cert, cmd_file },
|
||||
#endif
|
||||
@@ -157,7 +160,7 @@ static const struct {
|
||||
#ifdef ENABLE_DEBUG
|
||||
{ "debug", &opt.debug, cmd_boolean },
|
||||
#endif
|
||||
{ "defaultpage", &opt.default_page, cmd_string},
|
||||
{ "defaultpage", &opt.default_page, cmd_string },
|
||||
{ "deleteafter", &opt.delete_after, cmd_boolean },
|
||||
{ "dirprefix", &opt.dir_prefix, cmd_directory },
|
||||
{ "dirstruct", NULL, cmd_spec_dirstruct },
|
||||
@@ -191,6 +194,9 @@ static const struct {
|
||||
{ "httppasswd", &opt.http_passwd, cmd_string }, /* deprecated */
|
||||
{ "httppassword", &opt.http_passwd, cmd_string },
|
||||
{ "httpproxy", &opt.http_proxy, cmd_string },
|
||||
#ifdef HAVE_SSL
|
||||
{ "httpsonly", &opt.https_only, cmd_boolean },
|
||||
#endif
|
||||
{ "httpsproxy", &opt.https_proxy, cmd_string },
|
||||
{ "httpuser", &opt.http_user, cmd_string },
|
||||
{ "ignorecase", &opt.ignore_case, cmd_boolean },
|
||||
@@ -210,6 +216,7 @@ static const struct {
|
||||
{ "logfile", &opt.lfilename, cmd_file },
|
||||
{ "login", &opt.ftp_user, cmd_string },/* deprecated*/
|
||||
{ "maxredirect", &opt.max_redirect, cmd_number },
|
||||
{ "method", &opt.method, cmd_string_uppercase },
|
||||
{ "mirror", NULL, cmd_spec_mirror },
|
||||
{ "netrc", &opt.netrc, cmd_boolean },
|
||||
{ "noclobber", &opt.noclobber, cmd_boolean },
|
||||
@@ -455,8 +462,7 @@ home_dir (void)
|
||||
}
|
||||
|
||||
ret = home ? xstrdup (home) : NULL;
|
||||
if (buf)
|
||||
free (buf);
|
||||
free (buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -570,7 +576,8 @@ bool
|
||||
run_wgetrc (const char *file)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
char *line = NULL;
|
||||
size_t bufsize = 0;
|
||||
int ln;
|
||||
int errcnt = 0;
|
||||
|
||||
@@ -582,7 +589,7 @@ run_wgetrc (const char *file)
|
||||
return true; /* not a fatal error */
|
||||
}
|
||||
ln = 1;
|
||||
while ((line = read_whole_line (fp)) != NULL)
|
||||
while (getline (&line, &bufsize, fp) > 0)
|
||||
{
|
||||
char *com = NULL, *val = NULL;
|
||||
int comind;
|
||||
@@ -616,9 +623,9 @@ run_wgetrc (const char *file)
|
||||
}
|
||||
xfree_null (com);
|
||||
xfree_null (val);
|
||||
xfree (line);
|
||||
++ln;
|
||||
}
|
||||
xfree (line);
|
||||
fclose (fp);
|
||||
|
||||
return errcnt == 0;
|
||||
@@ -956,8 +963,25 @@ cmd_string (const char *com, const char *val, void *place)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Like cmd_string but ensure the string is upper case. */
|
||||
static bool
|
||||
cmd_string_uppercase (const char *com, const char *val, void *place)
|
||||
{
|
||||
char *q, **pstring;
|
||||
pstring = (char **)place;
|
||||
xfree_null (*pstring);
|
||||
|
||||
/* Like the above, but handles tilde-expansion when reading a user's
|
||||
*pstring = xmalloc (strlen (val) + 1);
|
||||
|
||||
for (q = *pstring; *val; val++, q++)
|
||||
*q = c_toupper (*val);
|
||||
|
||||
*q = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Like cmd_string, but handles tilde-expansion when reading a user's
|
||||
`.wgetrc'. In that case, and if VAL begins with `~', the tilde
|
||||
gets expanded to the user's home directory. */
|
||||
static bool
|
||||
@@ -1472,6 +1496,7 @@ cmd_spec_secure_protocol (const char *com, const char *val, void *place)
|
||||
{ "sslv2", secure_protocol_sslv2 },
|
||||
{ "sslv3", secure_protocol_sslv3 },
|
||||
{ "tlsv1", secure_protocol_tlsv1 },
|
||||
{ "pfs", secure_protocol_pfs },
|
||||
};
|
||||
int ok = decode_string (val, choices, countof (choices), place);
|
||||
if (!ok)
|
||||
@@ -1669,6 +1694,7 @@ decode_string (const char *val, const struct decode_item *items, int itemcount,
|
||||
|
||||
|
||||
void cleanup_html_url (void);
|
||||
void spider_cleanup (void);
|
||||
|
||||
|
||||
/* Free the memory allocated by global variables. */
|
||||
@@ -1703,6 +1729,7 @@ cleanup (void)
|
||||
res_cleanup ();
|
||||
http_cleanup ();
|
||||
cleanup_html_url ();
|
||||
spider_cleanup ();
|
||||
host_cleanup ();
|
||||
log_cleanup ();
|
||||
|
||||
@@ -1752,6 +1779,7 @@ cleanup (void)
|
||||
xfree_null (opt.user);
|
||||
xfree_null (opt.passwd);
|
||||
xfree_null (opt.base_href);
|
||||
xfree_null (opt.method);
|
||||
|
||||
#endif /* DEBUG_MALLOC */
|
||||
}
|
||||
|
||||
@@ -871,7 +871,7 @@ redirect_output (void)
|
||||
can do but disable printing completely. */
|
||||
fprintf (stderr, _("\n%s received.\n"), redirect_request_signal_name);
|
||||
fprintf (stderr, _("%s: %s; disabling logging.\n"),
|
||||
logfile, strerror (errno));
|
||||
(logfile) ? logfile : DEFAULT_LOGFILE, strerror (errno));
|
||||
inhibit_logging = true;
|
||||
}
|
||||
save_context_p = false;
|
||||
|
||||
105
src/main.c
105
src/main.c
@@ -167,6 +167,8 @@ static struct cmdline_option option_data[] =
|
||||
{ "backups", 0, OPT_BOOLEAN, "backups", -1 },
|
||||
{ "base", 'B', OPT_VALUE, "base", -1 },
|
||||
{ "bind-address", 0, OPT_VALUE, "bindaddress", -1 },
|
||||
{ "body-data", 0, OPT_VALUE, "bodydata", -1 },
|
||||
{ "body-file", 0, OPT_VALUE, "bodyfile", -1 },
|
||||
{ IF_SSL ("ca-certificate"), 0, OPT_VALUE, "cacertificate", -1 },
|
||||
{ IF_SSL ("ca-directory"), 0, OPT_VALUE, "cadirectory", -1 },
|
||||
{ "cache", 0, OPT_BOOLEAN, "cache", -1 },
|
||||
@@ -215,6 +217,7 @@ static struct cmdline_option option_data[] =
|
||||
{ "http-passwd", 0, OPT_VALUE, "httppassword", -1 }, /* deprecated */
|
||||
{ "http-password", 0, OPT_VALUE, "httppassword", -1 },
|
||||
{ "http-user", 0, OPT_VALUE, "httpuser", -1 },
|
||||
{ IF_SSL ("https-only"), 0, OPT_BOOLEAN, "httpsonly", -1 },
|
||||
{ "ignore-case", 0, OPT_BOOLEAN, "ignorecase", -1 },
|
||||
{ "ignore-length", 0, OPT_BOOLEAN, "ignorelength", -1 },
|
||||
{ "ignore-tags", 0, OPT_VALUE, "ignoretags", -1 },
|
||||
@@ -231,6 +234,7 @@ static struct cmdline_option option_data[] =
|
||||
{ "load-cookies", 0, OPT_VALUE, "loadcookies", -1 },
|
||||
{ "local-encoding", 0, OPT_VALUE, "localencoding", -1 },
|
||||
{ "max-redirect", 0, OPT_VALUE, "maxredirect", -1 },
|
||||
{ "method", 0, OPT_VALUE, "method", -1 },
|
||||
{ "mirror", 'm', OPT_BOOLEAN, "mirror", -1 },
|
||||
{ "no", 'n', OPT__NO, NULL, required_argument },
|
||||
{ "no-clobber", 0, OPT_BOOLEAN, "noclobber", -1 },
|
||||
@@ -609,6 +613,12 @@ HTTP options:\n"),
|
||||
--post-data=STRING use the POST method; send STRING as the data.\n"),
|
||||
N_("\
|
||||
--post-file=FILE use the POST method; send contents of FILE.\n"),
|
||||
N_("\
|
||||
--method=HTTPMethod use method \"HTTPMethod\" in the header.\n"),
|
||||
N_("\
|
||||
--body-data=STRING Send STRING as data. --method MUST be set.\n"),
|
||||
N_("\
|
||||
--body-file=FILE Send contents of FILE. --method MUST be set.\n"),
|
||||
N_("\
|
||||
--content-disposition honor the Content-Disposition header when\n\
|
||||
choosing local file names (EXPERIMENTAL).\n"),
|
||||
@@ -625,7 +635,9 @@ HTTP options:\n"),
|
||||
HTTPS (SSL/TLS) options:\n"),
|
||||
N_("\
|
||||
--secure-protocol=PR choose secure protocol, one of auto, SSLv2,\n\
|
||||
SSLv3, and TLSv1.\n"),
|
||||
SSLv3, TLSv1 and PFS.\n"),
|
||||
N_("\
|
||||
--https-only only follow secure HTTPS links\n"),
|
||||
N_("\
|
||||
--no-check-certificate don't validate the server's certificate.\n"),
|
||||
N_("\
|
||||
@@ -705,6 +717,9 @@ Recursive download:\n"),
|
||||
N_("\
|
||||
-k, --convert-links make links in downloaded HTML or CSS point to\n\
|
||||
local files.\n"),
|
||||
N_("\
|
||||
--backups=N before writing file X, rotate up to N backup files.\n"),
|
||||
|
||||
#ifdef __VMS
|
||||
N_("\
|
||||
-K, --backup-converted before converting file X, back up as X_orig.\n"),
|
||||
@@ -828,15 +843,16 @@ format_and_print_line (const char *prefix, const char *line,
|
||||
|
||||
assert (prefix != NULL);
|
||||
assert (line != NULL);
|
||||
assert (line_length > TABULATION);
|
||||
|
||||
line_dup = xstrdup (line);
|
||||
|
||||
if (line_length <= 0)
|
||||
line_length = MAX_CHARS_PER_LINE - TABULATION;
|
||||
|
||||
if (printf ("%s", prefix) < 0)
|
||||
return -1;
|
||||
remaining_chars = line_length;
|
||||
|
||||
/* Wrap to new line after prefix. */
|
||||
remaining_chars = 0;
|
||||
|
||||
/* We break on spaces. */
|
||||
token = strtok (line_dup, " ");
|
||||
while (token != NULL)
|
||||
@@ -844,7 +860,7 @@ format_and_print_line (const char *prefix, const char *line,
|
||||
/* If however a token is much larger than the maximum
|
||||
line length, all bets are off and we simply print the
|
||||
token on the next line. */
|
||||
if (remaining_chars <= strlen (token))
|
||||
if (remaining_chars <= (int) strlen (token))
|
||||
{
|
||||
if (printf ("\n%*c", TABULATION, ' ') < 0)
|
||||
return -1;
|
||||
@@ -918,7 +934,7 @@ print_version (void)
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
if (format_and_print_line (locale_title,
|
||||
LOCALEDIR,
|
||||
LOCALEDIR,
|
||||
MAX_CHARS_PER_LINE) < 0)
|
||||
exit (3);
|
||||
#endif /* def ENABLE_NLS */
|
||||
@@ -1034,7 +1050,6 @@ main (int argc, char **argv)
|
||||
short_options, long_options, &longindex)) != -1)
|
||||
{
|
||||
int confval;
|
||||
bool userrc_ret = true;
|
||||
struct cmdline_option *config_opt;
|
||||
|
||||
/* There is no short option for "--config". */
|
||||
@@ -1044,16 +1059,17 @@ main (int argc, char **argv)
|
||||
config_opt = &option_data[confval & ~BOOLEAN_NEG_MARKER];
|
||||
if (strcmp (config_opt->long_name, "config") == 0)
|
||||
{
|
||||
bool userrc_ret = true;
|
||||
userrc_ret &= run_wgetrc (optarg);
|
||||
use_userconfig = true;
|
||||
if (userrc_ret)
|
||||
break;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("Exiting due to error in %s\n"), optarg);
|
||||
exit (2);
|
||||
}
|
||||
}
|
||||
if (!userrc_ret)
|
||||
{
|
||||
fprintf (stderr, "Exiting due to error in %s\n", optarg);
|
||||
exit (2);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,6 +1227,7 @@ main (int argc, char **argv)
|
||||
if (opt.verbose == -1)
|
||||
opt.verbose = !opt.quiet;
|
||||
|
||||
|
||||
/* Sanity checks. */
|
||||
if (opt.verbose && opt.quiet)
|
||||
{
|
||||
@@ -1358,6 +1375,64 @@ for details.\n\n"));
|
||||
if (!opt.rejectregex)
|
||||
exit (1);
|
||||
}
|
||||
if (opt.post_data || opt.post_file_name)
|
||||
{
|
||||
if (opt.post_data && opt.post_file_name)
|
||||
{
|
||||
fprintf (stderr, _("You cannot specify both --post-data and --post-file.\n"));
|
||||
exit (1);
|
||||
}
|
||||
else if (opt.method)
|
||||
{
|
||||
fprintf (stderr, _("You cannot use --post-data or --post-file along with --method. "
|
||||
"--method expects data through --body-data and --body-file options"));
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (opt.body_data || opt.body_file)
|
||||
{
|
||||
if (!opt.method)
|
||||
{
|
||||
fprintf (stderr, _("You must specify a method through --method=HTTPMethod "
|
||||
"to use with --body-data or --body-file.\n"));
|
||||
exit (1);
|
||||
}
|
||||
else if (opt.body_data && opt.body_file)
|
||||
{
|
||||
fprintf (stderr, _("You cannot specify both --body-data and --body-file.\n"));
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set various options as required for opt.method. */
|
||||
|
||||
/* When user specifies HEAD as the method, we do not wish to download any
|
||||
files. Hence, set wget to run in spider mode. */
|
||||
if (opt.method && strcasecmp (opt.method, "HEAD") == 0)
|
||||
setoptval ("spider", "1", "spider");
|
||||
|
||||
/* Convert post_data to body-data and post_file_name to body-file options.
|
||||
This is required so as to remove redundant code later on in gethttp().
|
||||
The --post-data and --post-file options may also be removed in
|
||||
the future hence it makes sense to convert them to aliases for
|
||||
the more generic --method options.
|
||||
This MUST occur only after the sanity checks so as to prevent the
|
||||
user from setting both post and body options simultaneously.
|
||||
*/
|
||||
if (opt.post_data || opt.post_file_name)
|
||||
{
|
||||
setoptval ("method", "POST", "method");
|
||||
if (opt.post_data)
|
||||
{
|
||||
setoptval ("bodydata", opt.post_data, "body-data");
|
||||
opt.post_data = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
setoptval ("bodyfile", opt.post_file_name, "body-file");
|
||||
opt.post_file_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IRI
|
||||
if (opt.enable_iri)
|
||||
|
||||
@@ -323,7 +323,7 @@ fork_to_background (void)
|
||||
rv = fake_fork_child ();
|
||||
if (rv < 0)
|
||||
{
|
||||
fprintf (stderr, "fake_fork_child() failed\n");
|
||||
fprintf (stderr, _("fake_fork_child() failed\n"));
|
||||
abort ();
|
||||
}
|
||||
else if (rv == 0)
|
||||
@@ -331,7 +331,7 @@ fork_to_background (void)
|
||||
/* We're the parent. */
|
||||
fake_fork ();
|
||||
/* If fake_fork() returns, it failed. */
|
||||
fprintf (stderr, "fake_fork() failed\n");
|
||||
fprintf (stderr, _("fake_fork() failed\n"));
|
||||
abort ();
|
||||
}
|
||||
/* If we get here, we're the child. */
|
||||
@@ -646,7 +646,7 @@ set_windows_fd_as_blocking_socket (int fd)
|
||||
if(ret)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"ioctl() failed. The socket could not be set as blocking.\n" );
|
||||
_("ioctl() failed. The socket could not be set as blocking.\n") );
|
||||
DEBUGP (("Winsock error: %d\n", WSAGetLastError ()));
|
||||
abort ();
|
||||
}
|
||||
|
||||
50
src/netrc.c
50
src/netrc.c
@@ -164,48 +164,6 @@ search_netrc (const char *host, const char **acc, const char **passwd,
|
||||
|
||||
# define xrealloc realloc
|
||||
|
||||
/* Read a line from FP. The function reallocs the storage as needed
|
||||
to accomodate for any length of the line. Reallocs are done
|
||||
storage exponentially, doubling the storage after each overflow to
|
||||
minimize the number of calls to realloc() and fgets(). The newline
|
||||
character at the end of line is retained.
|
||||
|
||||
After end-of-file is encountered without anything being read, NULL
|
||||
is returned. NULL is also returned on error. To distinguish
|
||||
between these two cases, use the stdio function ferror(). */
|
||||
|
||||
char *
|
||||
read_whole_line (FILE *fp)
|
||||
{
|
||||
int length = 0;
|
||||
int bufsize = 81;
|
||||
char *line = xmalloc (bufsize);
|
||||
|
||||
while (fgets (line + length, bufsize - length, fp))
|
||||
{
|
||||
length += strlen (line + length);
|
||||
assert (length > 0);
|
||||
if (line[length - 1] == '\n')
|
||||
break;
|
||||
/* fgets() guarantees to read the whole line, or to use up the
|
||||
space we've given it. We can double the buffer
|
||||
unconditionally. */
|
||||
bufsize <<= 1;
|
||||
line = xrealloc (line, bufsize);
|
||||
}
|
||||
if (length == 0 || ferror (fp))
|
||||
{
|
||||
xfree (line);
|
||||
return NULL;
|
||||
}
|
||||
if (length + 1 < bufsize)
|
||||
/* Relieve the memory from our exponential greediness. We say
|
||||
`length + 1' because the terminating \0 is not included in
|
||||
LENGTH. We don't need to zero-terminate the string ourselves,
|
||||
though, because fgets() does that. */
|
||||
line = xrealloc (line, length + 1);
|
||||
return line;
|
||||
}
|
||||
#endif /* STANDALONE */
|
||||
|
||||
/* Maybe add NEWENTRY to the account information list, LIST. NEWENTRY is
|
||||
@@ -264,10 +222,11 @@ static acc_t *
|
||||
parse_netrc (const char *path)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line, *p, *tok;
|
||||
char *line = NULL, *p, *tok;
|
||||
const char *premature_token;
|
||||
acc_t *current, *retval;
|
||||
int ln, qmark;
|
||||
size_t bufsize = 0;
|
||||
|
||||
/* The latest token we've seen in the file. */
|
||||
enum
|
||||
@@ -290,7 +249,7 @@ parse_netrc (const char *path)
|
||||
premature_token = NULL;
|
||||
|
||||
/* While there are lines in the file... */
|
||||
while ((line = read_whole_line (fp)) != NULL)
|
||||
while (getline (&line, &bufsize, fp) > 0)
|
||||
{
|
||||
ln ++;
|
||||
|
||||
@@ -423,10 +382,9 @@ parse_netrc (const char *path)
|
||||
exec_name, path, ln, tok);
|
||||
}
|
||||
}
|
||||
|
||||
xfree (line);
|
||||
}
|
||||
|
||||
xfree (line);
|
||||
fclose (fp);
|
||||
|
||||
/* Finalize the last machine entry we found. */
|
||||
|
||||
@@ -194,6 +194,7 @@ ssl_init (void)
|
||||
case secure_protocol_sslv3:
|
||||
meth = SSLv3_client_method ();
|
||||
break;
|
||||
case secure_protocol_pfs:
|
||||
case secure_protocol_tlsv1:
|
||||
meth = TLSv1_client_method ();
|
||||
break;
|
||||
@@ -207,6 +208,12 @@ ssl_init (void)
|
||||
if (!ssl_ctx)
|
||||
goto error;
|
||||
|
||||
/* OpenSSL ciphers: https://www.openssl.org/docs/apps/ciphers.html
|
||||
* Since we want a good protection, we also use HIGH (that excludes MD4 ciphers and some more)
|
||||
*/
|
||||
if (opt.secure_protocol == secure_protocol_pfs)
|
||||
SSL_CTX_set_cipher_list (ssl_ctx, "HIGH:MEDIUM:!RC4:!SRP:!PSK:!RSA:!aNULL@STRENGTH");
|
||||
|
||||
SSL_CTX_set_default_verify_paths (ssl_ctx);
|
||||
SSL_CTX_load_verify_locations (ssl_ctx, opt.ca_cert, opt.ca_directory);
|
||||
|
||||
@@ -251,24 +258,50 @@ ssl_init (void)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct openssl_transport_context {
|
||||
struct openssl_transport_context
|
||||
{
|
||||
SSL *conn; /* SSL connection handle */
|
||||
char *last_error; /* last error printed with openssl_errstr */
|
||||
};
|
||||
|
||||
struct openssl_read_args
|
||||
{
|
||||
int fd;
|
||||
struct openssl_transport_context *ctx;
|
||||
char *buf;
|
||||
int bufsize;
|
||||
int retval;
|
||||
};
|
||||
|
||||
static void openssl_read_callback(void *arg)
|
||||
{
|
||||
struct openssl_read_args *args = (struct openssl_read_args *) arg;
|
||||
struct openssl_transport_context *ctx = args->ctx;
|
||||
SSL *conn = ctx->conn;
|
||||
char *buf = args->buf;
|
||||
int bufsize = args->bufsize;
|
||||
int ret;
|
||||
|
||||
do
|
||||
ret = SSL_read (conn, buf, bufsize);
|
||||
while (ret == -1 && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
|
||||
&& errno == EINTR);
|
||||
args->retval = ret;
|
||||
}
|
||||
|
||||
static int
|
||||
openssl_read (int fd, char *buf, int bufsize, void *arg)
|
||||
{
|
||||
int ret;
|
||||
struct openssl_transport_context *ctx = arg;
|
||||
SSL *conn = ctx->conn;
|
||||
do
|
||||
ret = SSL_read (conn, buf, bufsize);
|
||||
while (ret == -1
|
||||
&& SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
|
||||
&& errno == EINTR);
|
||||
struct openssl_read_args args;
|
||||
args.fd = fd;
|
||||
args.buf = buf;
|
||||
args.bufsize = bufsize;
|
||||
args.ctx = (struct openssl_transport_context*) arg;
|
||||
|
||||
return ret;
|
||||
if (run_with_timeout(opt.read_timeout, openssl_read_callback, &args)) {
|
||||
return -1;
|
||||
}
|
||||
return args.retval;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -386,6 +419,19 @@ static struct transport_implementation openssl_transport = {
|
||||
openssl_peek, openssl_errstr, openssl_close
|
||||
};
|
||||
|
||||
struct scwt_context
|
||||
{
|
||||
SSL *ssl;
|
||||
int result;
|
||||
};
|
||||
|
||||
static void
|
||||
ssl_connect_with_timeout_callback(void *arg)
|
||||
{
|
||||
struct scwt_context *ctx = (struct scwt_context *)arg;
|
||||
ctx->result = SSL_connect(ctx->ssl);
|
||||
}
|
||||
|
||||
/* Perform the SSL handshake on file descriptor FD, which is assumed
|
||||
to be connected to an SSL server. The SSL handle provided by
|
||||
OpenSSL is registered with the file descriptor FD using
|
||||
@@ -398,6 +444,7 @@ bool
|
||||
ssl_connect_wget (int fd, const char *hostname)
|
||||
{
|
||||
SSL *conn;
|
||||
struct scwt_context scwt_ctx;
|
||||
struct openssl_transport_context *ctx;
|
||||
|
||||
DEBUGP (("Initiating SSL handshake.\n"));
|
||||
@@ -425,7 +472,14 @@ ssl_connect_wget (int fd, const char *hostname)
|
||||
if (!SSL_set_fd (conn, FD_TO_SOCKET (fd)))
|
||||
goto error;
|
||||
SSL_set_connect_state (conn);
|
||||
if (SSL_connect (conn) <= 0 || conn->state != SSL_ST_OK)
|
||||
|
||||
scwt_ctx.ssl = conn;
|
||||
if (run_with_timeout(opt.read_timeout, ssl_connect_with_timeout_callback,
|
||||
&scwt_ctx)) {
|
||||
DEBUGP (("SSL handshake timed out.\n"));
|
||||
goto timeout;
|
||||
}
|
||||
if (scwt_ctx.result <= 0 || conn->state != SSL_ST_OK)
|
||||
goto error;
|
||||
|
||||
ctx = xnew0 (struct openssl_transport_context);
|
||||
@@ -441,6 +495,7 @@ ssl_connect_wget (int fd, const char *hostname)
|
||||
error:
|
||||
DEBUGP (("SSL handshake failed.\n"));
|
||||
print_errors ();
|
||||
timeout:
|
||||
if (conn)
|
||||
SSL_free (conn);
|
||||
return false;
|
||||
|
||||
@@ -166,7 +166,7 @@ struct options
|
||||
bool timestamping; /* Whether to use time-stamping. */
|
||||
|
||||
bool backup_converted; /* Do we save pre-converted files as *.orig? */
|
||||
bool backups; /* Are numeric backups made? */
|
||||
int backups; /* Are numeric backups made? */
|
||||
|
||||
char *useragent; /* User-Agent string, which can be set
|
||||
to something other than Wget. */
|
||||
@@ -200,7 +200,8 @@ struct options
|
||||
secure_protocol_auto,
|
||||
secure_protocol_sslv2,
|
||||
secure_protocol_sslv3,
|
||||
secure_protocol_tlsv1
|
||||
secure_protocol_tlsv1,
|
||||
secure_protocol_pfs
|
||||
} secure_protocol; /* type of secure protocol to use. */
|
||||
bool check_cert; /* whether to validate the server's cert */
|
||||
char *cert_file; /* external client certificate to use. */
|
||||
@@ -215,9 +216,9 @@ struct options
|
||||
char *ca_directory; /* CA directory (hash files) */
|
||||
char *ca_cert; /* CA certificate file to use */
|
||||
|
||||
|
||||
char *random_file; /* file with random data to seed the PRNG */
|
||||
char *egd_file; /* file name of the egd daemon socket */
|
||||
bool https_only; /* whether to follow HTTPS only */
|
||||
#endif /* HAVE_SSL */
|
||||
|
||||
bool cookies; /* whether cookies are used. */
|
||||
@@ -228,6 +229,9 @@ struct options
|
||||
|
||||
char *post_data; /* POST query string */
|
||||
char *post_file_name; /* File to post */
|
||||
char *method; /* HTTP Method to use in Header */
|
||||
char *body_data; /* HTTP Method Data String */
|
||||
char *body_file; /* HTTP Method File */
|
||||
|
||||
enum {
|
||||
restrict_unix,
|
||||
|
||||
56
src/recur.c
56
src/recur.c
@@ -1,6 +1,6 @@
|
||||
/* Handling of recursive HTTP retrieving.
|
||||
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
|
||||
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of GNU Wget.
|
||||
@@ -253,26 +253,23 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi)
|
||||
the second time. */
|
||||
if (dl_url_file_map && hash_table_contains (dl_url_file_map, url))
|
||||
{
|
||||
bool is_css_bool;
|
||||
|
||||
file = xstrdup (hash_table_get (dl_url_file_map, url));
|
||||
|
||||
DEBUGP (("Already downloaded \"%s\", reusing it from \"%s\".\n",
|
||||
url, file));
|
||||
|
||||
/* this sucks, needs to be combined! */
|
||||
if (html_allowed
|
||||
&& downloaded_html_set
|
||||
&& string_set_contains (downloaded_html_set, file))
|
||||
{
|
||||
descend = true;
|
||||
is_css = false;
|
||||
}
|
||||
if (css_allowed
|
||||
&& downloaded_css_set
|
||||
&& string_set_contains (downloaded_css_set, file))
|
||||
{
|
||||
descend = true;
|
||||
is_css = true;
|
||||
}
|
||||
if ((is_css_bool = (css_allowed
|
||||
&& downloaded_css_set
|
||||
&& string_set_contains (downloaded_css_set, file)))
|
||||
|| (html_allowed
|
||||
&& downloaded_html_set
|
||||
&& string_set_contains (downloaded_html_set, file)))
|
||||
{
|
||||
descend = true;
|
||||
is_css = is_css_bool;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -508,15 +505,16 @@ download_child_p (const struct urlpos *upos, struct url *parent, int depth,
|
||||
}
|
||||
|
||||
/* Several things to check for:
|
||||
1. if scheme is not http, and we don't load it
|
||||
2. check for relative links (if relative_only is set)
|
||||
3. check for domain
|
||||
4. check for no-parent
|
||||
5. check for excludes && includes
|
||||
6. check for suffix
|
||||
7. check for same host (if spanhost is unset), with possible
|
||||
1. if scheme is not https and https_only requested
|
||||
2. if scheme is not http, and we don't load it
|
||||
3. check for relative links (if relative_only is set)
|
||||
4. check for domain
|
||||
5. check for no-parent
|
||||
6. check for excludes && includes
|
||||
7. check for suffix
|
||||
8. check for same host (if spanhost is unset), with possible
|
||||
gethostbyname baggage
|
||||
8. check for robots.txt
|
||||
9. check for robots.txt
|
||||
|
||||
Addendum: If the URL is FTP, and it is to be loaded, only the
|
||||
domain and suffix settings are "stronger".
|
||||
@@ -528,6 +526,14 @@ download_child_p (const struct urlpos *upos, struct url *parent, int depth,
|
||||
More time- and memory- consuming tests should be put later on
|
||||
the list. */
|
||||
|
||||
#ifdef HAVE_SSL
|
||||
if (opt.https_only && u->scheme != SCHEME_HTTPS)
|
||||
{
|
||||
DEBUGP (("Not following non-HTTPS links.\n"));
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Determine whether URL under consideration has a HTTP-like scheme. */
|
||||
u_scheme_like_http = schemes_are_similar_p (u->scheme, SCHEME_HTTP);
|
||||
|
||||
@@ -641,7 +647,7 @@ download_child_p (const struct urlpos *upos, struct url *parent, int depth,
|
||||
files after downloading or we're just running a spider. */
|
||||
if (opt.delete_after || opt.spider)
|
||||
{
|
||||
logprintf (LOG_VERBOSE, "Removing %s.\n", rfile);
|
||||
logprintf (LOG_VERBOSE, _("Removing %s.\n"), rfile);
|
||||
if (unlink (rfile))
|
||||
logprintf (LOG_NOTQUIET, "unlink: %s\n",
|
||||
strerror (errno));
|
||||
|
||||
85
src/retr.c
85
src/retr.c
@@ -37,6 +37,9 @@ as that of the covered work. */
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef VMS
|
||||
# include <unixio.h> /* For delete(). */
|
||||
#endif
|
||||
|
||||
#include "exits.h"
|
||||
#include "utils.h"
|
||||
@@ -141,8 +144,8 @@ limit_bandwidth (wgint bytes, struct ptimer *timer)
|
||||
amount of data and decrease SKIP. Increment *TOTAL by the amount
|
||||
of data written. If OUT2 is not NULL, also write BUF to OUT2.
|
||||
In case of error writing to OUT, -1 is returned. In case of error
|
||||
writing to OUT2, -2 is returned. In case of any other error,
|
||||
1 is returned. */
|
||||
writing to OUT2, -2 is returned. Return 1 if the whole BUF was
|
||||
skipped. */
|
||||
|
||||
static int
|
||||
write_data (FILE *out, FILE *out2, const char *buf, int bufsize,
|
||||
@@ -376,7 +379,7 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos,
|
||||
{
|
||||
sum_read += ret;
|
||||
int write_res = write_data (out, out2, dlbuf, ret, &skip, &sum_written);
|
||||
if (write_res != 0)
|
||||
if (write_res < 0)
|
||||
{
|
||||
ret = (write_res == -3) ? -3 : -2;
|
||||
goto out;
|
||||
@@ -677,20 +680,23 @@ calc_rate (wgint bytes, double secs, int *units)
|
||||
}
|
||||
|
||||
|
||||
#define SUSPEND_POST_DATA do { \
|
||||
post_data_suspended = true; \
|
||||
saved_post_data = opt.post_data; \
|
||||
saved_post_file_name = opt.post_file_name; \
|
||||
opt.post_data = NULL; \
|
||||
opt.post_file_name = NULL; \
|
||||
#define SUSPEND_METHOD do { \
|
||||
method_suspended = true; \
|
||||
saved_body_data = opt.body_data; \
|
||||
saved_body_file_name = opt.body_file; \
|
||||
saved_method = opt.method; \
|
||||
opt.body_data = NULL; \
|
||||
opt.body_file = NULL; \
|
||||
opt.method = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define RESTORE_POST_DATA do { \
|
||||
if (post_data_suspended) \
|
||||
#define RESTORE_METHOD do { \
|
||||
if (method_suspended) \
|
||||
{ \
|
||||
opt.post_data = saved_post_data; \
|
||||
opt.post_file_name = saved_post_file_name; \
|
||||
post_data_suspended = false; \
|
||||
opt.body_data = saved_body_data; \
|
||||
opt.body_file = saved_body_file_name; \
|
||||
opt.method = saved_method; \
|
||||
method_suspended = false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -718,9 +724,10 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
char *local_file;
|
||||
int redirection_count = 0;
|
||||
|
||||
bool post_data_suspended = false;
|
||||
char *saved_post_data = NULL;
|
||||
char *saved_post_file_name = NULL;
|
||||
bool method_suspended = false;
|
||||
char *saved_body_data = NULL;
|
||||
char *saved_method = NULL;
|
||||
char *saved_body_file_name = NULL;
|
||||
|
||||
/* If dt is NULL, use local storage. */
|
||||
if (!dt)
|
||||
@@ -761,7 +768,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
proxy, error);
|
||||
xfree (url);
|
||||
xfree (error);
|
||||
RESTORE_POST_DATA;
|
||||
RESTORE_METHOD;
|
||||
result = PROXERR;
|
||||
goto bail;
|
||||
}
|
||||
@@ -770,7 +777,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
logprintf (LOG_NOTQUIET, _("Error in proxy URL %s: Must be HTTP.\n"), proxy);
|
||||
url_free (proxy_url);
|
||||
xfree (url);
|
||||
RESTORE_POST_DATA;
|
||||
RESTORE_METHOD;
|
||||
result = PROXERR;
|
||||
goto bail;
|
||||
}
|
||||
@@ -838,6 +845,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
iri->utf8_encode = opt.enable_iri;
|
||||
set_content_encoding (iri, NULL);
|
||||
xfree_null (iri->orig_url);
|
||||
iri->orig_url = NULL;
|
||||
|
||||
/* Now, see if this new location makes sense. */
|
||||
newloc_parsed = url_parse (mynewloc, &up_error_code, iri, true);
|
||||
@@ -853,7 +861,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
xfree (url);
|
||||
xfree (mynewloc);
|
||||
xfree (error);
|
||||
RESTORE_POST_DATA;
|
||||
RESTORE_METHOD;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
@@ -875,7 +883,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
}
|
||||
xfree (url);
|
||||
xfree (mynewloc);
|
||||
RESTORE_POST_DATA;
|
||||
RESTORE_METHOD;
|
||||
result = WRONGCODE;
|
||||
goto bail;
|
||||
}
|
||||
@@ -898,8 +906,8 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
RFC2616 HTTP/1.1 introduces code 307 Temporary Redirect
|
||||
specifically to preserve the method of the request.
|
||||
*/
|
||||
if (result != NEWLOCATION_KEEP_POST && !post_data_suspended)
|
||||
SUSPEND_POST_DATA;
|
||||
if (result != NEWLOCATION_KEEP_POST && !method_suspended)
|
||||
SUSPEND_METHOD;
|
||||
|
||||
goto redirected;
|
||||
}
|
||||
@@ -962,7 +970,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
xfree (url);
|
||||
}
|
||||
|
||||
RESTORE_POST_DATA;
|
||||
RESTORE_METHOD;
|
||||
|
||||
bail:
|
||||
if (register_status)
|
||||
@@ -1177,7 +1185,16 @@ free_urlpos (struct urlpos *l)
|
||||
void
|
||||
rotate_backups(const char *fname)
|
||||
{
|
||||
int maxlen = strlen (fname) + 1 + numdigit (opt.backups) + 1;
|
||||
#ifdef __VMS
|
||||
# define SEP "_"
|
||||
# define AVS ";*" /* All-version suffix. */
|
||||
# define AVSL (sizeof (AVS) - 1)
|
||||
#else
|
||||
# define SEP "."
|
||||
# define AVSL 0
|
||||
#endif
|
||||
|
||||
int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL;
|
||||
char *from = (char *)alloca (maxlen);
|
||||
char *to = (char *)alloca (maxlen);
|
||||
struct_stat sb;
|
||||
@@ -1189,12 +1206,24 @@ rotate_backups(const char *fname)
|
||||
|
||||
for (i = opt.backups; i > 1; i--)
|
||||
{
|
||||
sprintf (from, "%s.%d", fname, i - 1);
|
||||
sprintf (to, "%s.%d", fname, i);
|
||||
#ifdef VMS
|
||||
/* Delete (all versions of) any existing max-suffix file, to avoid
|
||||
* creating multiple versions of it. (On VMS, rename() will
|
||||
* create a new version of an existing destination file, not
|
||||
* destroy/overwrite it.)
|
||||
*/
|
||||
if (i == opt.backups)
|
||||
{
|
||||
sprintf (to, "%s%s%d%s", fname, SEP, i, AVS);
|
||||
delete (to);
|
||||
}
|
||||
#endif
|
||||
sprintf (to, "%s%s%d", fname, SEP, i);
|
||||
sprintf (from, "%s%s%d", fname, SEP, i - 1);
|
||||
rename (from, to);
|
||||
}
|
||||
|
||||
sprintf (to, "%s.%d", fname, 1);
|
||||
sprintf (to, "%s%s%d", fname, SEP, 1);
|
||||
rename(fname, to);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ static struct hash_table *nonexisting_urls_set;
|
||||
|
||||
/* Cleanup the data structures associated with this file. */
|
||||
|
||||
static void
|
||||
void
|
||||
spider_cleanup (void)
|
||||
{
|
||||
if (nonexisting_urls_set)
|
||||
|
||||
@@ -28,6 +28,8 @@ Corresponding Source for a non-source form of such a combination
|
||||
shall include the source code for the parts of OpenSSL used as well
|
||||
as that of the covered work. */
|
||||
|
||||
#include "wget.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
161
src/url.c
161
src/url.c
@@ -701,7 +701,10 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
|
||||
if (!iri->utf8_encode)
|
||||
new_url = NULL;
|
||||
else
|
||||
iri->orig_url = xstrdup (url);
|
||||
{
|
||||
iri->orig_url = xstrdup (url);
|
||||
percent_encode = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX XXX Could that change introduce (security) bugs ??? XXX XXX*/
|
||||
@@ -1245,12 +1248,16 @@ mkalldirs (const char *path)
|
||||
The idea is to have a convenient and efficient way to construct a
|
||||
string by having various functions append data to it. Instead of
|
||||
passing the obligatory BASEVAR, SIZEVAR and TAILPOS to all the
|
||||
functions in questions, we pass the pointer to this struct. */
|
||||
functions in questions, we pass the pointer to this struct.
|
||||
|
||||
Functions that write to the members in this struct must make sure
|
||||
that base remains null terminated by calling append_null().
|
||||
*/
|
||||
|
||||
struct growable {
|
||||
char *base;
|
||||
int size;
|
||||
int tail;
|
||||
int size; /* memory allocated */
|
||||
int tail; /* string length */
|
||||
};
|
||||
|
||||
/* Ensure that the string can accept APPEND_COUNT more characters past
|
||||
@@ -1268,28 +1275,55 @@ struct growable {
|
||||
/* Move the tail position by APPEND_COUNT characters. */
|
||||
#define TAIL_INCR(r, append_count) ((r)->tail += append_count)
|
||||
|
||||
/* Append the string STR to DEST. NOTICE: the string in DEST is not
|
||||
terminated. */
|
||||
|
||||
/* Append NULL to DEST. */
|
||||
static void
|
||||
append_null (struct growable *dest)
|
||||
{
|
||||
GROW (dest, 1);
|
||||
*TAIL (dest) = 0;
|
||||
}
|
||||
|
||||
/* Shorten DEST to LENGTH. */
|
||||
static void
|
||||
shorten_length (size_t length, struct growable *dest)
|
||||
{
|
||||
if (length < dest->tail)
|
||||
dest->tail = length;
|
||||
|
||||
append_null (dest);
|
||||
}
|
||||
|
||||
/* Append CH to DEST. */
|
||||
static void
|
||||
append_char (char ch, struct growable *dest)
|
||||
{
|
||||
if (ch)
|
||||
{
|
||||
GROW (dest, 1);
|
||||
*TAIL (dest) = ch;
|
||||
TAIL_INCR (dest, 1);
|
||||
}
|
||||
|
||||
append_null (dest);
|
||||
}
|
||||
|
||||
/* Append the string STR to DEST. */
|
||||
static void
|
||||
append_string (const char *str, struct growable *dest)
|
||||
{
|
||||
int l = strlen (str);
|
||||
GROW (dest, l);
|
||||
memcpy (TAIL (dest), str, l);
|
||||
TAIL_INCR (dest, l);
|
||||
|
||||
if (l)
|
||||
{
|
||||
GROW (dest, l);
|
||||
memcpy (TAIL (dest), str, l);
|
||||
TAIL_INCR (dest, l);
|
||||
}
|
||||
|
||||
append_null (dest);
|
||||
}
|
||||
|
||||
/* Append CH to DEST. For example, append_char (0, DEST)
|
||||
zero-terminates DEST. */
|
||||
|
||||
static void
|
||||
append_char (char ch, struct growable *dest)
|
||||
{
|
||||
GROW (dest, 1);
|
||||
*TAIL (dest) = ch;
|
||||
TAIL_INCR (dest, 1);
|
||||
}
|
||||
|
||||
enum {
|
||||
filechr_not_unix = 1, /* unusable on Unix, / and \0 */
|
||||
@@ -1361,6 +1395,7 @@ UWC, C, C, C, C, C, C, C, /* NUL SOH STX ETX EOT ENQ ACK BEL */
|
||||
query, normally '?'. Since Windows cannot handle '?' as part of
|
||||
file name, we use '@' instead there. */
|
||||
#define FN_QUERY_SEP (opt.restrict_files_os != restrict_windows ? '?' : '@')
|
||||
#define FN_QUERY_SEP_STR (opt.restrict_files_os != restrict_windows ? "?" : "@")
|
||||
|
||||
/* Quote path element, characters in [b, e), as file name, and append
|
||||
the quoted string to DEST. Each character is quoted as per
|
||||
@@ -1454,6 +1489,7 @@ append_uri_pathel (const char *b, const char *e, bool escaped,
|
||||
}
|
||||
|
||||
TAIL_INCR (dest, outlen);
|
||||
append_null (dest);
|
||||
}
|
||||
|
||||
/* Append to DEST the directory structure that corresponds the
|
||||
@@ -1494,22 +1530,28 @@ append_dir_structure (const struct url *u, struct growable *dest)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a unique file name that matches the given URL as good as
|
||||
/* Return a unique file name that matches the given URL as well as
|
||||
possible. Does not create directories on the file system. */
|
||||
|
||||
char *
|
||||
url_file_name (const struct url *u, char *replaced_filename)
|
||||
{
|
||||
struct growable fnres; /* stands for "file name result" */
|
||||
struct growable temp_fnres;
|
||||
|
||||
const char *u_file;
|
||||
char *fname, *unique;
|
||||
char *fname, *unique, *fname_len_check;
|
||||
const char *index_filename = "index.html"; /* The default index file is index.html */
|
||||
size_t max_length;
|
||||
|
||||
fnres.base = NULL;
|
||||
fnres.size = 0;
|
||||
fnres.tail = 0;
|
||||
|
||||
temp_fnres.base = NULL;
|
||||
temp_fnres.size = 0;
|
||||
temp_fnres.tail = 0;
|
||||
|
||||
/* If an alternative index file was defined, change index_filename */
|
||||
if (opt.default_page)
|
||||
index_filename = opt.default_page;
|
||||
@@ -1555,43 +1597,87 @@ url_file_name (const struct url *u, char *replaced_filename)
|
||||
|
||||
if (!replaced_filename)
|
||||
{
|
||||
/* Add the file name. */
|
||||
if (fnres.tail)
|
||||
append_char ('/', &fnres);
|
||||
/* Create the filename. */
|
||||
u_file = *u->file ? u->file : index_filename;
|
||||
append_uri_pathel (u_file, u_file + strlen (u_file), false, &fnres);
|
||||
|
||||
/* Append "?query" to the file name, even if empty */
|
||||
/* Append "?query" to the file name, even if empty,
|
||||
* and create fname_len_check. */
|
||||
if (u->query)
|
||||
{
|
||||
append_char (FN_QUERY_SEP, &fnres);
|
||||
append_uri_pathel (u->query, u->query + strlen (u->query),
|
||||
true, &fnres);
|
||||
}
|
||||
fname_len_check = concat_strings (u_file, FN_QUERY_SEP_STR, u->query, NULL);
|
||||
else
|
||||
fname_len_check = strdupdelim (u_file, u_file + strlen (u_file));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fnres.tail)
|
||||
append_char ('/', &fnres);
|
||||
u_file = replaced_filename;
|
||||
append_uri_pathel (u_file, u_file + strlen (u_file), false, &fnres);
|
||||
fname_len_check = strdupdelim (u_file, u_file + strlen (u_file));
|
||||
}
|
||||
|
||||
/* Zero-terminate the file name. */
|
||||
append_char ('\0', &fnres);
|
||||
append_uri_pathel (fname_len_check,
|
||||
fname_len_check + strlen (fname_len_check), false, &temp_fnres);
|
||||
|
||||
/* Zero-terminate the temporary file name. */
|
||||
append_char ('\0', &temp_fnres);
|
||||
|
||||
/* Check that the length of the file name is acceptable. */
|
||||
#ifdef WINDOWS
|
||||
if (MAX_PATH > (fnres.tail + CHOMP_BUFFER + 2))
|
||||
{
|
||||
max_length = MAX_PATH - (fnres.tail + CHOMP_BUFFER + 2);
|
||||
/* FIXME: In Windows a filename is usually limited to 255 characters.
|
||||
To really be accurate you could call GetVolumeInformation() to get
|
||||
lpMaximumComponentLength
|
||||
*/
|
||||
if (max_length > 255)
|
||||
{
|
||||
max_length = 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
max_length = 0;
|
||||
}
|
||||
#else
|
||||
max_length = get_max_length (fnres.base, fnres.tail, _PC_NAME_MAX) - CHOMP_BUFFER;
|
||||
#endif
|
||||
if (max_length > 0 && strlen (temp_fnres.base) > max_length)
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, "The name is too long, %lu chars total.\n",
|
||||
(unsigned long) strlen (temp_fnres.base));
|
||||
logprintf (LOG_NOTQUIET, "Trying to shorten...\n");
|
||||
|
||||
/* Shorten the file name. */
|
||||
temp_fnres.base[max_length] = '\0';
|
||||
|
||||
logprintf (LOG_NOTQUIET, "New name is %s.\n", temp_fnres.base);
|
||||
}
|
||||
|
||||
free (fname_len_check);
|
||||
|
||||
/* The filename has already been 'cleaned' by append_uri_pathel() above. So,
|
||||
* just append it. */
|
||||
if (fnres.tail)
|
||||
append_char ('/', &fnres);
|
||||
append_string (temp_fnres.base, &fnres);
|
||||
|
||||
fname = fnres.base;
|
||||
|
||||
/* Make a final check that the path length is acceptable? */
|
||||
/* TODO: check fnres.base for path length problem */
|
||||
|
||||
free (temp_fnres.base);
|
||||
|
||||
/* Check the cases in which the unique extensions are not used:
|
||||
1) Clobbering is turned off (-nc).
|
||||
2) Retrieval with regetting.
|
||||
3) Timestamping is used.
|
||||
4) Hierarchy is built.
|
||||
5) Backups are specified.
|
||||
|
||||
The exception is the case when file does exist and is a
|
||||
directory (see `mkalldirs' for explanation). */
|
||||
|
||||
if ((opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct)
|
||||
if (ALLOW_CLOBBER
|
||||
&& !(file_exists_p (fname) && !file_non_directory_p (fname)))
|
||||
{
|
||||
unique = fname;
|
||||
@@ -2228,7 +2314,6 @@ test_append_uri_pathel()
|
||||
|
||||
append_string (test_array[i].original_url, &dest);
|
||||
append_uri_pathel (p, p + strlen(p), test_array[i].escaped, &dest);
|
||||
append_char ('\0', &dest);
|
||||
|
||||
mu_assert ("test_append_uri_pathel: wrong result",
|
||||
strcmp (dest.base, test_array[i].expected_result) == 0);
|
||||
|
||||
16
src/url.h
16
src/url.h
@@ -37,6 +37,22 @@ as that of the covered work. */
|
||||
#define DEFAULT_FTP_PORT 21
|
||||
#define DEFAULT_HTTPS_PORT 443
|
||||
|
||||
/* This represents how many characters less than the OS max name length a file
|
||||
* should be. More precisely, a file name should be at most
|
||||
* (NAME_MAX - CHOMP_BUFFER) characters in length. This number was arrived at
|
||||
* by adding the lengths of all possible strings that could be appended to a
|
||||
* file name later in the code (e.g. ".orig", ".html", etc.). This is
|
||||
* hopefully plenty of extra characters, but I am not guaranteeing that a file
|
||||
* name will be of the proper length by the time the code wants to open a
|
||||
* file descriptor. */
|
||||
#define CHOMP_BUFFER 19
|
||||
|
||||
/* The flags that allow clobbering the file (opening with "wb").
|
||||
Defined here to avoid repetition later. #### This will require
|
||||
rework. */
|
||||
#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
|
||||
|| opt.dirstruct || opt.output_document || opt.backups > 0)
|
||||
|
||||
/* Specifies how, or whether, user auth information should be included
|
||||
* in URLs regenerated from URL parse structures. */
|
||||
enum url_auth_mode {
|
||||
|
||||
172
src/utils.c
172
src/utils.c
@@ -703,7 +703,7 @@ unique_create (const char *name, bool binary, char **opened_name)
|
||||
xfree (uname);
|
||||
uname = unique_name (name, false);
|
||||
}
|
||||
if (opened_name && fp != NULL)
|
||||
if (opened_name)
|
||||
{
|
||||
if (fp)
|
||||
*opened_name = uname;
|
||||
@@ -900,15 +900,14 @@ static bool in_acclist (const char *const *, const char *, bool);
|
||||
bool
|
||||
acceptable (const char *s)
|
||||
{
|
||||
int l = strlen (s);
|
||||
const char *p;
|
||||
|
||||
if (opt.output_document && strcmp (s, opt.output_document) == 0)
|
||||
return true;
|
||||
|
||||
while (l && s[l] != '/')
|
||||
--l;
|
||||
if (s[l] == '/')
|
||||
s += (l + 1);
|
||||
if ((p = strrchr (s, '/')))
|
||||
s = p + 1;
|
||||
|
||||
if (opt.accepts)
|
||||
{
|
||||
if (opt.rejects)
|
||||
@@ -919,6 +918,7 @@ acceptable (const char *s)
|
||||
}
|
||||
else if (opt.rejects)
|
||||
return !in_acclist ((const char *const *)opt.rejects, s, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1018,29 +1018,15 @@ accdir (const char *directory)
|
||||
bool
|
||||
match_tail (const char *string, const char *tail, bool fold_case)
|
||||
{
|
||||
int i, j;
|
||||
int pos = strlen (string) - strlen (tail);
|
||||
|
||||
/* We want this to be fast, so we code two loops, one with
|
||||
case-folding, one without. */
|
||||
if (pos < 0)
|
||||
return false; /* tail is longer than string. */
|
||||
|
||||
if (!fold_case)
|
||||
{
|
||||
for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--)
|
||||
if (string[i] != tail[j])
|
||||
break;
|
||||
}
|
||||
return !strcmp (string + pos, tail);
|
||||
else
|
||||
{
|
||||
for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--)
|
||||
if (c_tolower (string[i]) != c_tolower (tail[j]))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the tail was exhausted, the match was succesful. */
|
||||
if (j == -1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return !strcasecmp (string + pos, tail);
|
||||
}
|
||||
|
||||
/* Checks whether string S matches each element of ACCEPTS. A list
|
||||
@@ -1089,15 +1075,12 @@ in_acclist (const char *const *accepts, const char *s, bool backward)
|
||||
char *
|
||||
suffix (const char *str)
|
||||
{
|
||||
int i;
|
||||
char *p;
|
||||
|
||||
for (i = strlen (str); i && str[i] != '/' && str[i] != '.'; i--)
|
||||
;
|
||||
if ((p = strrchr (str, '.')) && !strchr (p + 1, '/'))
|
||||
return p + 1;
|
||||
|
||||
if (str[i++] == '.')
|
||||
return (char *)str + i;
|
||||
else
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return true if S contains globbing wildcards (`*', `?', `[' or
|
||||
@@ -1106,10 +1089,7 @@ suffix (const char *str)
|
||||
bool
|
||||
has_wildcards_p (const char *s)
|
||||
{
|
||||
for (; *s; s++)
|
||||
if (*s == '*' || *s == '?' || *s == '[' || *s == ']')
|
||||
return true;
|
||||
return false;
|
||||
return !!strpbrk (s, "*?[]");
|
||||
}
|
||||
|
||||
/* Return true if FNAME ends with a typical HTML suffix. The
|
||||
@@ -1138,56 +1118,6 @@ has_html_suffix_p (const char *fname)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Read a line from FP and return the pointer to freshly allocated
|
||||
storage. The storage space is obtained through malloc() and should
|
||||
be freed with free() when it is no longer needed.
|
||||
|
||||
The length of the line is not limited, except by available memory.
|
||||
The newline character at the end of line is retained. The line is
|
||||
terminated with a zero character.
|
||||
|
||||
After end-of-file is encountered without anything being read, NULL
|
||||
is returned. NULL is also returned on error. To distinguish
|
||||
between these two cases, use the stdio function ferror(). */
|
||||
|
||||
char *
|
||||
read_whole_line (FILE *fp)
|
||||
{
|
||||
int length = 0;
|
||||
int bufsize = 82;
|
||||
char *line = xmalloc (bufsize);
|
||||
|
||||
while (fgets (line + length, bufsize - length, fp))
|
||||
{
|
||||
length += strlen (line + length);
|
||||
if (length == 0)
|
||||
/* Possible for example when reading from a binary file where
|
||||
a line begins with \0. */
|
||||
continue;
|
||||
|
||||
if (line[length - 1] == '\n')
|
||||
break;
|
||||
|
||||
/* fgets() guarantees to read the whole line, or to use up the
|
||||
space we've given it. We can double the buffer
|
||||
unconditionally. */
|
||||
bufsize <<= 1;
|
||||
line = xrealloc (line, bufsize);
|
||||
}
|
||||
if (length == 0 || ferror (fp))
|
||||
{
|
||||
xfree (line);
|
||||
return NULL;
|
||||
}
|
||||
if (length + 1 < bufsize)
|
||||
/* Relieve the memory from our exponential greediness. We say
|
||||
`length + 1' because the terminating \0 is not included in
|
||||
LENGTH. We don't need to zero-terminate the string ourselves,
|
||||
though, because fgets() does that. */
|
||||
line = xrealloc (line, length + 1);
|
||||
return line;
|
||||
}
|
||||
|
||||
/* Read FILE into memory. A pointer to `struct file_memory' are
|
||||
returned; use struct element `content' to access file contents, and
|
||||
the element `length' to know the file length. `content' is *not*
|
||||
@@ -2494,21 +2424,75 @@ print_decimal (double number)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Get the maximum name length for the given path. */
|
||||
/* Return 0 if length is unknown. */
|
||||
size_t
|
||||
get_max_length (const char *path, int length, int name)
|
||||
{
|
||||
long ret;
|
||||
char *p, *d;
|
||||
|
||||
/* Make a copy of the path that we can modify. */
|
||||
p = path ? strdupdelim (path, path + length) : strdup ("");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
errno = 0;
|
||||
/* For an empty path query the current directory. */
|
||||
#if HAVE_PATHCONF
|
||||
ret = pathconf (*p ? p : ".", name);
|
||||
if (!(ret < 0 && errno == ENOENT))
|
||||
break;
|
||||
#else
|
||||
ret = PATH_MAX;
|
||||
#endif
|
||||
|
||||
/* The path does not exist yet, but may be created. */
|
||||
/* Already at current or root directory, give up. */
|
||||
if (!*p || strcmp (p, "/") == 0)
|
||||
break;
|
||||
|
||||
/* Remove one directory level and try again. */
|
||||
d = strrchr (p, '/');
|
||||
if (d == p)
|
||||
p[1] = '\0'; /* check root directory */
|
||||
else if (d)
|
||||
*d = '\0'; /* remove last directory part */
|
||||
else
|
||||
*p = '\0'; /* check current directory */
|
||||
}
|
||||
|
||||
xfree (p);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
/* pathconf() has a message for us. */
|
||||
if (errno != 0)
|
||||
perror ("pathconf");
|
||||
|
||||
/* If (errno == 0) then there is no max length.
|
||||
Even on error return 0 so the caller can continue. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
|
||||
const char *
|
||||
test_subdir_p()
|
||||
{
|
||||
int i;
|
||||
struct {
|
||||
char *d1;
|
||||
char *d2;
|
||||
static struct {
|
||||
const char *d1;
|
||||
const char *d2;
|
||||
bool result;
|
||||
} test_array[] = {
|
||||
{ "/somedir", "/somedir", true },
|
||||
{ "/somedir", "/somedir/d2", true },
|
||||
{ "/somedir/d1", "/somedir", false },
|
||||
};
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < countof(test_array); ++i)
|
||||
{
|
||||
@@ -2524,10 +2508,9 @@ test_subdir_p()
|
||||
const char *
|
||||
test_dir_matches_p()
|
||||
{
|
||||
int i;
|
||||
struct {
|
||||
char *dirlist[3];
|
||||
char *dir;
|
||||
static struct {
|
||||
const char *dirlist[3];
|
||||
const char *dir;
|
||||
bool result;
|
||||
} test_array[] = {
|
||||
{ { "/somedir", "/someotherdir", NULL }, "somedir", true },
|
||||
@@ -2546,6 +2529,7 @@ test_dir_matches_p()
|
||||
{ { "/Tmp/has", NULL, NULL }, "/Tmp/has space", false },
|
||||
{ { "/Tmp/has", NULL, NULL }, "/Tmp/has,comma", false },
|
||||
};
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < countof(test_array); ++i)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,6 @@ bool has_wildcards_p (const char *);
|
||||
|
||||
bool has_html_suffix_p (const char *);
|
||||
|
||||
char *read_whole_line (FILE *);
|
||||
struct file_memory *wget_read_file (const char *);
|
||||
void wget_read_file_free (struct file_memory *);
|
||||
|
||||
@@ -155,6 +154,8 @@ void stable_sort (void *, size_t, size_t, int (*) (const void *, const void *));
|
||||
|
||||
const char *print_decimal (double);
|
||||
|
||||
size_t get_max_length (const char *path, int length, int name);
|
||||
|
||||
extern unsigned char char_prop[];
|
||||
|
||||
#endif /* UTILS_H */
|
||||
|
||||
164
src/warc.c
164
src/warc.c
@@ -51,10 +51,16 @@ as that of the covered work. */
|
||||
|
||||
#ifndef WINDOWS
|
||||
#include <libgen.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "warc.h"
|
||||
|
||||
#ifndef O_TEMPORARY
|
||||
#define O_TEMPORARY 0
|
||||
#endif
|
||||
|
||||
extern char *version_string;
|
||||
|
||||
/* Set by main in main.c */
|
||||
@@ -165,7 +171,7 @@ warc_write_string (const char *str)
|
||||
}
|
||||
|
||||
|
||||
#define EXTRA_GZIP_HEADER_SIZE 12
|
||||
#define EXTRA_GZIP_HEADER_SIZE 14
|
||||
#define GZIP_STATIC_HEADER_SIZE 10
|
||||
#define FLG_FEXTRA 0x04
|
||||
#define OFF_FLG 3
|
||||
@@ -200,7 +206,7 @@ warc_write_start_record (void)
|
||||
In warc_write_end_record we will fill this space
|
||||
with information about the uncompressed and
|
||||
compressed size of the record. */
|
||||
fprintf (warc_current_file, "XXXXXXXXXXXX");
|
||||
fseek (warc_current_file, EXTRA_GZIP_HEADER_SIZE, SEEK_CUR);
|
||||
fflush (warc_current_file);
|
||||
|
||||
/* Start a new GZIP stream. */
|
||||
@@ -245,15 +251,10 @@ static bool
|
||||
warc_write_block_from_file (FILE *data_in)
|
||||
{
|
||||
/* Add the Content-Length header. */
|
||||
char *content_length;
|
||||
char content_length[MAX_INT_TO_STRING_LEN(off_t)];
|
||||
fseeko (data_in, 0L, SEEK_END);
|
||||
if (! asprintf (&content_length, "%ld", ftello (data_in)))
|
||||
{
|
||||
warc_write_ok = false;
|
||||
return false;
|
||||
}
|
||||
number_to_string (content_length, ftello (data_in));
|
||||
warc_write_header ("Content-Length", content_length);
|
||||
free (content_length);
|
||||
|
||||
/* End of the WARC header section. */
|
||||
warc_write_string ("\r\n");
|
||||
@@ -347,16 +348,19 @@ warc_write_end_record (void)
|
||||
/* The extra header field identifier for the WARC skip length. */
|
||||
extra_header[2] = 's';
|
||||
extra_header[3] = 'l';
|
||||
/* The size of the field value (8 bytes). */
|
||||
extra_header[4] = (8 & 255);
|
||||
extra_header[5] = ((8 >> 8) & 255);
|
||||
/* The size of the uncompressed record. */
|
||||
extra_header[4] = (uncompressed_size & 255);
|
||||
extra_header[5] = (uncompressed_size >> 8) & 255;
|
||||
extra_header[6] = (uncompressed_size >> 16) & 255;
|
||||
extra_header[7] = (uncompressed_size >> 24) & 255;
|
||||
extra_header[6] = (uncompressed_size & 255);
|
||||
extra_header[7] = (uncompressed_size >> 8) & 255;
|
||||
extra_header[8] = (uncompressed_size >> 16) & 255;
|
||||
extra_header[9] = (uncompressed_size >> 24) & 255;
|
||||
/* The size of the compressed record. */
|
||||
extra_header[8] = (compressed_size & 255);
|
||||
extra_header[9] = (compressed_size >> 8) & 255;
|
||||
extra_header[10] = (compressed_size >> 16) & 255;
|
||||
extra_header[11] = (compressed_size >> 24) & 255;
|
||||
extra_header[10] = (compressed_size & 255);
|
||||
extra_header[11] = (compressed_size >> 8) & 255;
|
||||
extra_header[12] = (compressed_size >> 16) & 255;
|
||||
extra_header[13] = (compressed_size >> 24) & 255;
|
||||
|
||||
/* Write the extra header after the static header. */
|
||||
fseeko (warc_current_file, warc_current_gzfile_offset
|
||||
@@ -532,7 +536,7 @@ warc_sha1_stream_with_payload (FILE *stream, void *res_block, void *res_payload,
|
||||
static char *
|
||||
warc_base32_sha1_digest (char *sha1_digest)
|
||||
{
|
||||
// length: "sha1:" + digest + "\0"
|
||||
/* length: "sha1:" + digest + "\0" */
|
||||
char *sha1_base32 = malloc (BASE32_LENGTH(SHA1_DIGEST_SIZE) + 1 + 5 );
|
||||
base32_encode (sha1_digest, SHA1_DIGEST_SIZE, sha1_base32 + 5,
|
||||
BASE32_LENGTH(SHA1_DIGEST_SIZE) + 1);
|
||||
@@ -722,10 +726,9 @@ warc_start_new_file (bool meta)
|
||||
|
||||
if (warc_current_file != NULL)
|
||||
fclose (warc_current_file);
|
||||
if (warc_current_warcinfo_uuid_str)
|
||||
free (warc_current_warcinfo_uuid_str);
|
||||
if (warc_current_filename)
|
||||
free (warc_current_filename);
|
||||
|
||||
free (warc_current_warcinfo_uuid_str);
|
||||
free (warc_current_filename);
|
||||
|
||||
warc_current_file_number++;
|
||||
|
||||
@@ -734,8 +737,14 @@ warc_start_new_file (bool meta)
|
||||
char *new_filename = malloc (base_filename_length + 1 + 5 + 8 + 1);
|
||||
warc_current_filename = new_filename;
|
||||
|
||||
#ifdef __VMS
|
||||
# define WARC_GZ "warc-gz"
|
||||
#else /* def __VMS */
|
||||
# define WARC_GZ "warc.gz"
|
||||
#endif /* def __VMS [else] */
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
const char *extension = (opt.warc_compression_enabled ? "warc.gz" : "warc");
|
||||
const char *extension = (opt.warc_compression_enabled ? WARC_GZ : "warc");
|
||||
#else
|
||||
const char *extension = "warc";
|
||||
#endif
|
||||
@@ -908,8 +917,7 @@ warc_process_cdx_line (char *lineptr, int field_num_original_url,
|
||||
else
|
||||
{
|
||||
free (original_url);
|
||||
if (checksum_v != NULL)
|
||||
free (checksum_v);
|
||||
free (checksum_v);
|
||||
free (record_id);
|
||||
}
|
||||
}
|
||||
@@ -1005,12 +1013,10 @@ warc_find_duplicate_cdx_record (char *url, char *sha1_digest_payload)
|
||||
if (warc_cdx_dedup_table == NULL)
|
||||
return NULL;
|
||||
|
||||
char *key;
|
||||
struct warc_cdx_record *rec_existing;
|
||||
int found = hash_table_get_pair (warc_cdx_dedup_table, sha1_digest_payload,
|
||||
&key, &rec_existing);
|
||||
struct warc_cdx_record *rec_existing
|
||||
= hash_table_get (warc_cdx_dedup_table, sha1_digest_payload);
|
||||
|
||||
if (found && strcmp (rec_existing->url, url) == 0)
|
||||
if (rec_existing && strcmp (rec_existing->url, url) == 0)
|
||||
return rec_existing;
|
||||
else
|
||||
return NULL;
|
||||
@@ -1087,7 +1093,7 @@ warc_write_metadata (void)
|
||||
warc_uuid_str (manifest_uuid);
|
||||
|
||||
fflush (warc_manifest_fp);
|
||||
warc_write_resource_record (manifest_uuid,
|
||||
warc_write_metadata_record (manifest_uuid,
|
||||
"metadata://gnu.org/software/wget/warc/MANIFEST.txt",
|
||||
NULL, NULL, NULL, "text/plain",
|
||||
warc_manifest_fp, -1);
|
||||
@@ -1102,9 +1108,9 @@ warc_write_metadata (void)
|
||||
fflush (warc_tmp_fp);
|
||||
fprintf (warc_tmp_fp, "%s\n", program_argstring);
|
||||
|
||||
warc_write_resource_record (manifest_uuid,
|
||||
warc_write_resource_record (NULL,
|
||||
"metadata://gnu.org/software/wget/warc/wget_arguments.txt",
|
||||
NULL, NULL, NULL, "text/plain",
|
||||
NULL, manifest_uuid, NULL, "text/plain",
|
||||
warc_tmp_fp, -1);
|
||||
/* warc_write_resource_record has closed warc_tmp_fp. */
|
||||
|
||||
@@ -1151,14 +1157,32 @@ warc_tempfile (void)
|
||||
if (path_search (filename, 100, opt.warc_tempdir, "wget", true) == -1)
|
||||
return NULL;
|
||||
|
||||
int fd = mkstemp (filename);
|
||||
#ifdef __VMS
|
||||
/* 2013-07-12 SMS.
|
||||
* mkostemp()+unlink()+fdopen() scheme causes trouble on VMS, so use
|
||||
* mktemp() to uniquify the (VMS-style) name, and then use a normal
|
||||
* fopen() with a "create temp file marked for delete" option.
|
||||
*/
|
||||
{
|
||||
char *tfn;
|
||||
|
||||
tfn = mktemp (filename); /* Get unique name from template. */
|
||||
if (tfn == NULL)
|
||||
return NULL;
|
||||
return fopen (tfn, "w+", "fop=tmd"); /* Create auto-delete temp file. */
|
||||
}
|
||||
#else /* def __VMS */
|
||||
int fd = mkostemp (filename, O_TEMPORARY);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
#if !O_TEMPORARY
|
||||
if (unlink (filename) < 0)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
return fdopen (fd, "wb+");
|
||||
#endif /* def __VMS [else] */
|
||||
}
|
||||
|
||||
|
||||
@@ -1232,10 +1256,14 @@ warc_write_cdx_record (const char *url, const char *timestamp_str,
|
||||
if (redirect_location == NULL || strlen(redirect_location) == 0)
|
||||
redirect_location = "-";
|
||||
|
||||
char offset_string[MAX_INT_TO_STRING_LEN(off_t)];
|
||||
number_to_string (offset_string, offset);
|
||||
|
||||
/* Print the CDX line. */
|
||||
fprintf (warc_current_cdx_file, "%s %s %s %s %d %s %s - %ld %s %s\n", url,
|
||||
fprintf (warc_current_cdx_file, "%s %s %s %s %d %s %s - %s %s %s\n", url,
|
||||
timestamp_str_cdx, url, mime_type, response_code, checksum,
|
||||
redirect_location, offset, warc_current_filename, response_uuid);
|
||||
redirect_location, offset_string, warc_current_filename,
|
||||
response_uuid);
|
||||
fflush (warc_current_cdx_file);
|
||||
|
||||
return true;
|
||||
@@ -1387,28 +1415,28 @@ warc_write_response_record (char *url, char *timestamp_str,
|
||||
response_uuid);
|
||||
}
|
||||
|
||||
if (block_digest)
|
||||
free (block_digest);
|
||||
if (payload_digest)
|
||||
free (payload_digest);
|
||||
free (block_digest);
|
||||
free (payload_digest);
|
||||
|
||||
return warc_write_ok;
|
||||
}
|
||||
|
||||
/* Writes a resource record to the WARC file.
|
||||
/* Writes a resource or metadata record to the WARC file.
|
||||
warc_type is either "resource" or "metadata",
|
||||
resource_uuid is the uuid of the resource (or NULL),
|
||||
url is the target uri of the resource,
|
||||
timestamp_str is the timestamp (generated with warc_timestamp),
|
||||
concurrent_to_uuid is the uuid of the request for that generated this
|
||||
concurrent_to_uuid is the uuid of the record that generated this,
|
||||
resource (generated with warc_uuid_str) or NULL,
|
||||
ip is the ip address of the server (or NULL),
|
||||
content_type is the mime type of the body (or NULL),
|
||||
body is a pointer to a file containing the resource data.
|
||||
Calling this function will close body.
|
||||
Returns true on success, false on error. */
|
||||
bool
|
||||
warc_write_resource_record (char *resource_uuid, const char *url,
|
||||
const char *timestamp_str, const char *concurrent_to_uuid,
|
||||
static bool
|
||||
warc_write_record (const char *record_type, char *resource_uuid,
|
||||
const char *url, const char *timestamp_str,
|
||||
const char *concurrent_to_uuid,
|
||||
ip_address *ip, const char *content_type, FILE *body,
|
||||
off_t payload_offset)
|
||||
{
|
||||
@@ -1422,7 +1450,7 @@ warc_write_resource_record (char *resource_uuid, const char *url,
|
||||
content_type = "application/octet-stream";
|
||||
|
||||
warc_write_start_record ();
|
||||
warc_write_header ("WARC-Type", "resource");
|
||||
warc_write_header ("WARC-Type", record_type);
|
||||
warc_write_header ("WARC-Record-ID", resource_uuid);
|
||||
warc_write_header ("WARC-Warcinfo-ID", warc_current_warcinfo_uuid_str);
|
||||
warc_write_header ("WARC-Concurrent-To", concurrent_to_uuid);
|
||||
@@ -1438,3 +1466,47 @@ warc_write_resource_record (char *resource_uuid, const char *url,
|
||||
|
||||
return warc_write_ok;
|
||||
}
|
||||
|
||||
/* Writes a resource record to the WARC file.
|
||||
resource_uuid is the uuid of the resource (or NULL),
|
||||
url is the target uri of the resource,
|
||||
timestamp_str is the timestamp (generated with warc_timestamp),
|
||||
concurrent_to_uuid is the uuid of the record that generated this,
|
||||
resource (generated with warc_uuid_str) or NULL,
|
||||
ip is the ip address of the server (or NULL),
|
||||
content_type is the mime type of the body (or NULL),
|
||||
body is a pointer to a file containing the resource data.
|
||||
Calling this function will close body.
|
||||
Returns true on success, false on error. */
|
||||
bool
|
||||
warc_write_resource_record (char *resource_uuid, const char *url,
|
||||
const char *timestamp_str, const char *concurrent_to_uuid,
|
||||
ip_address *ip, const char *content_type, FILE *body,
|
||||
off_t payload_offset)
|
||||
{
|
||||
return warc_write_record ("resource",
|
||||
resource_uuid, url, timestamp_str, concurrent_to_uuid,
|
||||
ip, content_type, body, payload_offset);
|
||||
}
|
||||
|
||||
/* Writes a metadata record to the WARC file.
|
||||
record_uuid is the uuid of the record (or NULL),
|
||||
url is the target uri of the record,
|
||||
timestamp_str is the timestamp (generated with warc_timestamp),
|
||||
concurrent_to_uuid is the uuid of the record that generated this,
|
||||
record (generated with warc_uuid_str) or NULL,
|
||||
ip is the ip address of the server (or NULL),
|
||||
content_type is the mime type of the body (or NULL),
|
||||
body is a pointer to a file containing the record data.
|
||||
Calling this function will close body.
|
||||
Returns true on success, false on error. */
|
||||
bool
|
||||
warc_write_metadata_record (char *record_uuid, const char *url,
|
||||
const char *timestamp_str, const char *concurrent_to_uuid,
|
||||
ip_address *ip, const char *content_type, FILE *body,
|
||||
off_t payload_offset)
|
||||
{
|
||||
return warc_write_record ("metadata",
|
||||
record_uuid, url, timestamp_str, concurrent_to_uuid,
|
||||
ip, content_type, body, payload_offset);
|
||||
}
|
||||
|
||||
@@ -19,5 +19,8 @@ bool warc_write_response_record (char *url, char *timestamp_str,
|
||||
bool warc_write_resource_record (char *resource_uuid, const char *url,
|
||||
const char *timestamp_str, const char *concurrent_to_uuid, ip_address *ip,
|
||||
const char *content_type, FILE *body, off_t payload_offset);
|
||||
bool warc_write_metadata_record (char *record_uuid, const char *url,
|
||||
const char *timestamp_str, const char *concurrent_to_uuid, ip_address *ip,
|
||||
const char *content_type, FILE *body, off_t payload_offset);
|
||||
|
||||
#endif /* WARC_H */
|
||||
|
||||
@@ -314,6 +314,10 @@ typedef double SUM_SIZE_INT;
|
||||
0-pad the address.) */
|
||||
#define PTR_FORMAT(p) (int) (2 * sizeof (void *)), (unsigned long) (p)
|
||||
|
||||
/* Find the maximum buffer length needed to print an integer of type `x'
|
||||
in base 10. 24082 / 10000 = 8*log_{10}(2). */
|
||||
#define MAX_INT_TO_STRING_LEN(x) ((sizeof(x) * 24082 / 10000) + 2)
|
||||
|
||||
extern const char *exec_name;
|
||||
|
||||
/* Document type ("dt") flags */
|
||||
@@ -353,7 +357,7 @@ typedef enum
|
||||
PROXERR,
|
||||
/* 50 */
|
||||
AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED, VERIFCERTERR,
|
||||
UNLINKERR, NEWLOCATION_KEEP_POST, CLOSEFAILED,
|
||||
UNLINKERR, NEWLOCATION_KEEP_POST, CLOSEFAILED, ATTRMISSING, UNKNOWNATTR,
|
||||
|
||||
WARC_ERR, WARC_TMP_FOPENERR, WARC_TMP_FWRITEERR
|
||||
} uerr_t;
|
||||
|
||||
@@ -1,3 +1,65 @@
|
||||
2013-11-04 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* Makefile.am: Add new tests introduced in last commit to
|
||||
EXTRA_DIST.
|
||||
Reported by: Andrea Urbani <matfanjol@mail.com>
|
||||
|
||||
2013-10-17 Andrea Urbani <matfanjol@mail.com>
|
||||
|
||||
* FTPServer.pm (GetBehavior): new routine.
|
||||
* FTPServer.pm (get_list): new parameter to skip hidden files
|
||||
* Test-ftp-list-Multinet.px: Test LIST on a "UNIX MultiNet
|
||||
Unix Emulation" system that returns an empty content when
|
||||
"LIST -a" is requested (probably because no "-a" files
|
||||
exist)
|
||||
* Test-ftp-list-Unknown.px: Test LIST on a "Unknown ftp
|
||||
service" system that returns an empty content when
|
||||
"LIST -a" is requested (probably because no "-a" files
|
||||
exist)
|
||||
* Test-ftp-list-Unknown-a.px: Test LIST on a "Unknown ftp
|
||||
service" system that recognises "LIST -a" as "give me the
|
||||
-a file" and there is a "-a" file + other two files.
|
||||
"LIST -a" will return only "-a", "LIST" all the three files.
|
||||
* Test-ftp-list-Unknown-hidden.px: Test LIST on a "Unknown ftp
|
||||
service" system that recognises "LIST -a" as an "UNIX Type:
|
||||
L8" system (show me also the hidden files) and there is an
|
||||
hidden file.
|
||||
* Test-ftp-list-Unknown-list-a-fails.px: Test LIST on a
|
||||
"Unknown ftp service" system that raises an error on
|
||||
"LIST -a" command.
|
||||
* Test-ftp-list-UNIX-hidden.px: Test LIST on a "UNIX Type:
|
||||
L8" system that recognises "LIST -a" as "show me also the
|
||||
hidden files" and there is an hidden file.
|
||||
|
||||
2013-10-10 Giuseppe Scrivano <gscrivan@redhat.com>
|
||||
|
||||
* Test-idn-robots-utf8.px: Remove -H.
|
||||
* Test-idn-cmd.px: Likewise.
|
||||
* Test-idn-cmd-utf8.px: Likewise.
|
||||
Suggested by: Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
2013-10-07 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* Test-idn-robots.px: added punycoded and escaped URLs to follow
|
||||
removed -H
|
||||
|
||||
2013-08-22 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add Test--httpsonly-r.px.
|
||||
* run-px (tests): Likewise.
|
||||
* Test--httpsonly-r.px: New file.
|
||||
|
||||
2013-03-12 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add Test--post-file.px.
|
||||
* run-px (tests): Likewise.
|
||||
* Test--post-file.px: New file.
|
||||
|
||||
2012-11-09 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* HTTPServer.pm: added check for must-not-match request-header
|
||||
* Test-cookies.px: check cookie deletion and cookie domain matching
|
||||
|
||||
2012-06-16 Giuseppe Scrivano <gscrivano@gnu.org>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add Test-stdouterr.px.
|
||||
|
||||
@@ -81,10 +81,25 @@ sub _LIST_command
|
||||
my ($conn, $cmd, $path) = @_;
|
||||
my $paths = $conn->{'paths'};
|
||||
|
||||
# This is something of a hack. Some clients expect a Unix server
|
||||
# to respond to flags on the 'ls command line'. Remove these flags
|
||||
# and ignore them. This is particularly an issue with ncftp 2.4.3.
|
||||
$path =~ s/^-[a-zA-Z0-9]+\s?//;
|
||||
my $ReturnEmptyList = ( $paths->GetBehavior('list_empty_if_list_a') &&
|
||||
$path eq '-a');
|
||||
my $SkipHiddenFiles = ( $paths->GetBehavior('list_no_hidden_if_list') &&
|
||||
( ! $path ) );
|
||||
|
||||
if ($paths->GetBehavior('list_fails_if_list_a') && $path eq '-a')
|
||||
{
|
||||
print {$conn->{socket}} "500 Unknown command\r\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!$paths->GetBehavior('list_dont_clean_path'))
|
||||
{
|
||||
# This is something of a hack. Some clients expect a Unix server
|
||||
# to respond to flags on the 'ls command line'. Remove these flags
|
||||
# and ignore them. This is particularly an issue with ncftp 2.4.3.
|
||||
$path =~ s/^-[a-zA-Z0-9]+\s?//;
|
||||
}
|
||||
|
||||
my $dir = $conn->{'dir'};
|
||||
|
||||
@@ -94,12 +109,16 @@ sub _LIST_command
|
||||
# working directory.
|
||||
local $_;
|
||||
|
||||
$dir = FTPPaths::path_merge($dir, $path);
|
||||
my $listing = $paths->get_list($dir);
|
||||
unless ($listing) {
|
||||
print {$conn->{socket}} "550 File or directory not found.\r\n";
|
||||
return;
|
||||
}
|
||||
my $listing;
|
||||
if (!$ReturnEmptyList)
|
||||
{
|
||||
$dir = FTPPaths::path_merge($dir, $path);
|
||||
$listing = $paths->get_list($dir,$SkipHiddenFiles);
|
||||
unless ($listing) {
|
||||
print {$conn->{socket}} "550 File or directory not found.\r\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print STDERR "_LIST_command - dir is: $dir\n" if $log;
|
||||
|
||||
@@ -112,9 +131,12 @@ sub _LIST_command
|
||||
return;
|
||||
}
|
||||
|
||||
for my $item (@$listing) {
|
||||
print $sock "$item\r\n";
|
||||
}
|
||||
if (!$ReturnEmptyList)
|
||||
{
|
||||
for my $item (@$listing) {
|
||||
print $sock "$item\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
unless ($sock->close) {
|
||||
print {$conn->{socket}} "550 Error closing data connection: $!\r\n";
|
||||
@@ -372,7 +394,14 @@ sub _SYST_command
|
||||
{
|
||||
my ($conn, $cmd, $dummy) = @_;
|
||||
|
||||
print {$conn->{socket}} "215 UNIX Type: L8\r\n";
|
||||
if ($conn->{'paths'}->GetBehavior('syst_response'))
|
||||
{
|
||||
print {$conn->{socket}} $conn->{'paths'}->GetBehavior('syst_response') . "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print {$conn->{socket}} "215 UNIX Type: L8\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub _TYPE_command
|
||||
@@ -780,7 +809,7 @@ sub _format_for_list {
|
||||
}
|
||||
|
||||
sub get_list {
|
||||
my ($self, $path) = @_;
|
||||
my ($self, $path, $no_hidden) = @_;
|
||||
my $info = $self->get_info($path);
|
||||
return undef unless defined $info;
|
||||
my $list = [];
|
||||
@@ -788,7 +817,19 @@ sub get_list {
|
||||
if ($info->{'_type'} eq 'd') {
|
||||
for my $item (keys %$info) {
|
||||
next if $item =~ /^_/;
|
||||
push @$list, $self->_format_for_list($item, $info->{$item});
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# I skip the hidden files if requested
|
||||
if (($no_hidden) &&
|
||||
(defined($info->{$item}->{'attr'})) &&
|
||||
(index($info->{$item}->{'attr'}, "H")>=0))
|
||||
{
|
||||
# This is an hidden file and I don't want to see it!
|
||||
print STDERR "get_list: Skipped hidden file [$item]\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
push @$list, $self->_format_for_list($item, $info->{$item});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
push @$list, $self->_format_for_list(final_component($path), $info);
|
||||
@@ -797,6 +838,29 @@ sub get_list {
|
||||
return $list;
|
||||
}
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# It returns the behavior of the given name.
|
||||
# In this file I handle also the following behaviors:
|
||||
# list_dont_clean_path : if defined, the command
|
||||
# $path =~ s/^-[a-zA-Z0-9]+\s?//;
|
||||
# is not runt and the given path
|
||||
# remains the original one
|
||||
# list_empty_if_list_a : if defined, "LIST -a" returns an
|
||||
# empty content
|
||||
# list_fails_if_list_a : if defined, "LIST -a" returns an
|
||||
# error
|
||||
# list_no_hidden_if_list: if defined, "LIST" doesn't return
|
||||
# hidden files.
|
||||
# To define an hidden file add
|
||||
# attr => "H"
|
||||
# to the url files
|
||||
# syst_response : if defined, its content is printed
|
||||
# out as SYST response
|
||||
sub GetBehavior {
|
||||
my ($self, $name) = @_;
|
||||
return $self->{'_behavior'}{$name};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# vim: et ts=4 sw=4
|
||||
|
||||
@@ -218,12 +218,24 @@ sub verify_request_headers {
|
||||
|
||||
return 1 unless exists $url_rec->{'request_headers'};
|
||||
for my $hdrname (keys %{$url_rec->{'request_headers'}}) {
|
||||
my $rhdr = $req->header ($hdrname);
|
||||
my $must_not_match;
|
||||
my $ehdr = $url_rec->{'request_headers'}{$hdrname};
|
||||
unless (defined $rhdr && $rhdr =~ $ehdr) {
|
||||
$rhdr = '' unless defined $rhdr;
|
||||
print STDERR "\n*** Mismatch on $hdrname: $rhdr =~ $ehdr\n";
|
||||
return undef;
|
||||
if ($must_not_match = ($hdrname =~ /^!(\w+)/)) {
|
||||
$hdrname = $1;
|
||||
}
|
||||
my $rhdr = $req->header ($hdrname);
|
||||
if ($must_not_match) {
|
||||
if (defined $rhdr && $rhdr =~ $ehdr) {
|
||||
$rhdr = '' unless defined $rhdr;
|
||||
print STDERR "\n*** Match forbidden $hdrname: $rhdr =~ $ehdr\n";
|
||||
return undef;
|
||||
}
|
||||
} else {
|
||||
unless (defined $rhdr && $rhdr =~ $ehdr) {
|
||||
$rhdr = '' unless defined $rhdr;
|
||||
print STDERR "\n*** Mismatch on $hdrname: $rhdr =~ $ehdr\n";
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,12 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
|
||||
Test-ftp-iri-fallback.px \
|
||||
Test-ftp-iri-recursive.px \
|
||||
Test-ftp-iri-disabled.px \
|
||||
Test-ftp-list-Multinet.px \
|
||||
Test-ftp-list-Unknown.px \
|
||||
Test-ftp-list-Unknown-a.px \
|
||||
Test-ftp-list-Unknown-hidden.px \
|
||||
Test-ftp-list-Unknown-list-a-fails.px \
|
||||
Test-ftp-list-UNIX-hidden.px \
|
||||
Test-HTTP-Content-Disposition-1.px \
|
||||
Test-HTTP-Content-Disposition-2.px \
|
||||
Test-HTTP-Content-Disposition.px \
|
||||
@@ -119,6 +125,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
|
||||
Test-O--no-content-disposition-trivial.px \
|
||||
Test-O-nonexisting.px \
|
||||
Test-O.px \
|
||||
Test--post-file.px \
|
||||
Test-proxied-https-auth.px \
|
||||
Test-proxy-auth-basic.px \
|
||||
Test-restrict-ascii.px \
|
||||
@@ -131,6 +138,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
|
||||
Test--spider-r--no-content-disposition.px \
|
||||
Test--spider-r--no-content-disposition-trivial.px \
|
||||
Test--spider-r.px \
|
||||
Test--httpsonly-r.px \
|
||||
run-px certs
|
||||
|
||||
check_PROGRAMS = unit-tests
|
||||
|
||||
79
tests/Test--httpsonly-r.px
Executable file
79
tests/Test--httpsonly-r.px
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use HTTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $mainpage = <<EOF;
|
||||
<html>
|
||||
<head>
|
||||
<title>Main Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
my $secondpage = <<EOF;
|
||||
<html>
|
||||
<head>
|
||||
<title>Second Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Anything.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/index.html' => {
|
||||
code => "200",
|
||||
msg => "Dontcare",
|
||||
headers => {
|
||||
"Content-type" => "text/html",
|
||||
},
|
||||
content => $mainpage,
|
||||
},
|
||||
'/secondpage.html' => {
|
||||
code => "200",
|
||||
msg => "Dontcare",
|
||||
headers => {
|
||||
"Content-type" => "text/html",
|
||||
},
|
||||
content => $secondpage,
|
||||
}
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --https-only -r -nH http://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'index.html' => {
|
||||
content => $mainpage,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = HTTPTest->new (name => "Test--httpsonly-r",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files);
|
||||
print $expected_error_code."\n";
|
||||
|
||||
exit $the_test->run();
|
||||
|
||||
# vim: et ts=4 sw=4
|
||||
|
||||
23
tests/Test--post-file.px
Executable file
23
tests/Test--post-file.px
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use HTTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " -d --post-file=nofile http://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 3;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = HTTPTest->new (name => "Test-missing-file",
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code);
|
||||
exit $the_test->run();
|
||||
|
||||
# vim: et ts=4 sw=4
|
||||
@@ -10,6 +10,10 @@ use HTTPTest;
|
||||
|
||||
my $page1 = "Hello, world!\n";
|
||||
my $page2 = "Goodbye, Sam.\n";
|
||||
my $page3 = "Page three.\n";
|
||||
my $page4 = "Page four.\n";
|
||||
my $page5 = "Page five.\n";
|
||||
my $page6 = "Page six.\n";
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
@@ -30,10 +34,49 @@ my %urls = (
|
||||
"Cookie" => qr|foo=bar|,
|
||||
},
|
||||
},
|
||||
# remove the cookie 'foo'
|
||||
'/three.txt' => {
|
||||
code => "200",
|
||||
msg => "Ok",
|
||||
headers => {
|
||||
"Content-type" => "text/plain",
|
||||
"Set-Cookie" => "foo=; Expires=Sun, 06 Nov 1994 08:49:37 GMT",
|
||||
},
|
||||
content => $page3,
|
||||
},
|
||||
'/four.txt' => {
|
||||
code => "200",
|
||||
msg => "Ok",
|
||||
content => $page4,
|
||||
request_headers => {
|
||||
"!Cookie" => qr|foo=|,
|
||||
},
|
||||
},
|
||||
# try to set a cookie 'foo' with mismatching domain
|
||||
# see RFC 6265 5.3.6: ignore the cookie if it doesn't domain-match
|
||||
'/five.txt' => {
|
||||
code => "200",
|
||||
msg => "Ok",
|
||||
headers => {
|
||||
"Content-type" => "text/plain",
|
||||
"Set-Cookie" => "foo=bar; domain=.example.com",
|
||||
},
|
||||
content => $page5,
|
||||
},
|
||||
'/six.txt' => {
|
||||
code => "200",
|
||||
msg => "Ok",
|
||||
content => $page6,
|
||||
request_headers => {
|
||||
"!Cookie" => qr|foo=bar|,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/one.txt"
|
||||
. " http://localhost:{{port}}/two.txt";
|
||||
. " http://localhost:{{port}}/two.txt" . " http://localhost:{{port}}/three.txt"
|
||||
. " http://localhost:{{port}}/four.txt" . " http://localhost:{{port}}/five.txt"
|
||||
. " http://localhost:{{port}}/six.txt";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
@@ -44,6 +87,18 @@ my %expected_downloaded_files = (
|
||||
'two.txt' => {
|
||||
content => $page2,
|
||||
},
|
||||
'three.txt' => {
|
||||
content => $page3,
|
||||
},
|
||||
'four.txt' => {
|
||||
content => $page4,
|
||||
},
|
||||
'five.txt' => {
|
||||
content => $page5,
|
||||
},
|
||||
'six.txt' => {
|
||||
content => $page6,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
67
tests/Test-ftp-list-Multinet.px
Normal file
67
tests/Test-ftp-list-Multinet.px
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# In this ftp test:
|
||||
# - the response of SYST command is
|
||||
# 215 UNIX MultiNet Unix Emulation V5.3(93)
|
||||
# - the response of "LIST -a" command is an empty
|
||||
# directory.
|
||||
# wget should use directly the "LIST" command to get
|
||||
# the right content, but it will be ok also "LIST -a"
|
||||
# if followed by "LIST" (in the case of future changes).
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $afile = <<EOF;
|
||||
Some text.
|
||||
EOF
|
||||
|
||||
my $bfile = <<EOF;
|
||||
Some more text.
|
||||
EOF
|
||||
|
||||
$afile =~ s/\n/\r\n/g;
|
||||
$bfile =~ s/\n/\r\n/g;
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'/bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 --accept \"?file.txt\" ftp://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-ftp-list-Multinet",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files,
|
||||
server_behavior => {list_empty_if_list_a => 1,
|
||||
syst_response => "215 UNIX MultiNet Unix Emulation V5.3(93)"});
|
||||
exit $the_test->run();
|
||||
|
||||
65
tests/Test-ftp-list-UNIX-hidden.px
Normal file
65
tests/Test-ftp-list-UNIX-hidden.px
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# In this ftp test:
|
||||
# - the response of "LIST -a" command contains
|
||||
# all the files
|
||||
# - the response of "LIST" command contains
|
||||
# the normal files (hidden files are not present)
|
||||
# wget should use only "LIST -a" because it recognise
|
||||
# the system as "UNIX Type: L8" and so it should see
|
||||
# and download the hidden file too.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $normalfile = <<EOF;
|
||||
I'm a normal file
|
||||
EOF
|
||||
|
||||
my $hiddenfile = <<EOF;
|
||||
I'm an hidden file
|
||||
EOF
|
||||
|
||||
$normalfile =~ s/\n/\r\n/g;
|
||||
$hiddenfile =~ s/\n/\r\n/g;
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/normalfile.txt' => {
|
||||
content => $normalfile,
|
||||
},
|
||||
'/hiddenfile.txt' => {
|
||||
content => $hiddenfile,
|
||||
attr => "H",
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 ftp://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'normalfile.txt' => {
|
||||
content => $normalfile,
|
||||
},
|
||||
'hiddenfile.txt' => {
|
||||
content => $hiddenfile,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-ftp-list-UNIX-hidden",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files,
|
||||
server_behavior => {list_no_hidden_if_list => 1});
|
||||
exit $the_test->run();
|
||||
|
||||
77
tests/Test-ftp-list-Unknown-a.px
Normal file
77
tests/Test-ftp-list-Unknown-a.px
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# In this ftp test:
|
||||
# - the response of SYST command is
|
||||
# 215 Unknown ftp service
|
||||
# - the response of "LIST -a" command is a file
|
||||
# called "-a".
|
||||
# wget should use "LIST -a", but also "LIST".
|
||||
# After "LIST", wget will see more data is available.
|
||||
# (See also Test-ftp-list-Unknown-b.px)
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $afile = <<EOF;
|
||||
Some text.
|
||||
EOF
|
||||
|
||||
my $bfile = <<EOF;
|
||||
Some more text.
|
||||
EOF
|
||||
|
||||
|
||||
my $minusafile = <<EOF;
|
||||
The strange situation.
|
||||
EOF
|
||||
|
||||
$afile =~ s/\n/\r\n/g;
|
||||
$bfile =~ s/\n/\r\n/g;
|
||||
$minusafile =~ s/\n/\r\n/g;
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'/bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
'/-a' => {
|
||||
content => $minusafile,
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 ftp://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
'-a' => {
|
||||
content => $minusafile,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-ftp-list-Unknown-a",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files,
|
||||
server_behavior => {list_dont_clean_path => 1,
|
||||
syst_response => "215 Unknown ftp service"});
|
||||
exit $the_test->run();
|
||||
|
||||
69
tests/Test-ftp-list-Unknown-hidden.px
Normal file
69
tests/Test-ftp-list-Unknown-hidden.px
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# In this ftp test:
|
||||
# - the response of SYST command is
|
||||
# 215 Unknown ftp service
|
||||
# - the response of "LIST -a" command contains
|
||||
# all the files
|
||||
# - the response of "LIST" command contains
|
||||
# the normal files (hidden files are not present)
|
||||
# wget should use "LIST -a", but also "LIST".
|
||||
# After "LIST", wget will see more data is available
|
||||
# on "LIST -a", so it should go back to "LIST -a".
|
||||
# (See also Test-ftp-list-Unknown-a.px)
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $normalfile = <<EOF;
|
||||
I'm a normal file
|
||||
EOF
|
||||
|
||||
my $hiddenfile = <<EOF;
|
||||
I'm an hidden file
|
||||
EOF
|
||||
|
||||
$normalfile =~ s/\n/\r\n/g;
|
||||
$hiddenfile =~ s/\n/\r\n/g;
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/normalfile.txt' => {
|
||||
content => $normalfile,
|
||||
},
|
||||
'/hiddenfile.txt' => {
|
||||
content => $hiddenfile,
|
||||
attr => "H",
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 ftp://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'normalfile.txt' => {
|
||||
content => $normalfile,
|
||||
},
|
||||
'hiddenfile.txt' => {
|
||||
content => $hiddenfile,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-ftp-list-Unknown-hidden",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files,
|
||||
server_behavior => {list_no_hidden_if_list => 1,
|
||||
syst_response => "215 Unknown ftp service"});
|
||||
exit $the_test->run();
|
||||
|
||||
62
tests/Test-ftp-list-Unknown-list-a-fails.px
Normal file
62
tests/Test-ftp-list-Unknown-list-a-fails.px
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# In this ftp test:
|
||||
# - the response of "LIST -a" command is a failure
|
||||
# wget should use "LIST -a" then "LIST" to get the right
|
||||
# content.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $afile = <<EOF;
|
||||
Some text.
|
||||
EOF
|
||||
|
||||
my $bfile = <<EOF;
|
||||
Some more text.
|
||||
EOF
|
||||
|
||||
$afile =~ s/\n/\r\n/g;
|
||||
$bfile =~ s/\n/\r\n/g;
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'/bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 --accept \"?file.txt\" ftp://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-ftp-list-Unknown-list-a-fails",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files,
|
||||
server_behavior => {list_fails_if_list_a => 1,
|
||||
syst_response => "215 Unknown ftp service"});
|
||||
exit $the_test->run();
|
||||
|
||||
65
tests/Test-ftp-list-Unknown.px
Normal file
65
tests/Test-ftp-list-Unknown.px
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
|
||||
# 2013-10-17 Andrea Urbani (matfanjol)
|
||||
# In this ftp test:
|
||||
# - the response of SYST command is
|
||||
# 215 Unknown ftp service
|
||||
# - the response of "LIST -a" command is an empty
|
||||
# directory.
|
||||
# wget should use "LIST -a" then "LIST" to get the right
|
||||
# content.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FTPTest;
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $afile = <<EOF;
|
||||
Some text.
|
||||
EOF
|
||||
|
||||
my $bfile = <<EOF;
|
||||
Some more text.
|
||||
EOF
|
||||
|
||||
$afile =~ s/\n/\r\n/g;
|
||||
$bfile =~ s/\n/\r\n/g;
|
||||
|
||||
# code, msg, headers, content
|
||||
my %urls = (
|
||||
'/afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'/bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --no-directories --recursive --level=1 --accept \"?file.txt\" ftp://localhost:{{port}}/";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
my %expected_downloaded_files = (
|
||||
'afile.txt' => {
|
||||
content => $afile,
|
||||
},
|
||||
'bfile.txt' => {
|
||||
content => $bfile,
|
||||
},
|
||||
);
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $the_test = FTPTest->new (name => "Test-ftp-list-Unknown",
|
||||
input => \%urls,
|
||||
cmdline => $cmdline,
|
||||
errcode => $expected_error_code,
|
||||
output => \%expected_downloaded_files,
|
||||
server_behavior => {list_empty_if_list_a => 1,
|
||||
syst_response => "215 Unknown ftp service"});
|
||||
exit $the_test->run();
|
||||
|
||||
@@ -28,7 +28,7 @@ my %urls = (
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -rH"
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -r"
|
||||
. " -e http_proxy=localhost:{{port}} --local-encoding=UTF-8 $utf8_hostname";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ my %urls = (
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -rH"
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -r"
|
||||
. " -e http_proxy=localhost:{{port}} --local-encoding=EUC-JP $euc_jp_hostname";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
||||
@@ -48,7 +48,7 @@ my %urls = (
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -rH"
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -r"
|
||||
. " -e http_proxy=localhost:{{port}} --local-encoding=UTF-8"
|
||||
. " http://$utf8_hostname/";
|
||||
|
||||
|
||||
@@ -9,11 +9,14 @@ use HTTPTest;
|
||||
# " Kon'nichiwa <dot> Japan
|
||||
my $euc_jp_hostname = "\272\243\306\374\244\317.\306\374\313\334";
|
||||
my $punycoded_hostname = 'xn--v9ju72g90p.xn--wgv71a';
|
||||
my $escaped_hostname = "%ba%a3%c6%fc%a4%cf.%c6%fc%cb%dc";
|
||||
|
||||
###############################################################################
|
||||
|
||||
my $starter_file = <<EOF;
|
||||
<a href="http://$euc_jp_hostname/foo.txt">The link</a>
|
||||
<a href="http://$punycoded_hostname/foo2.txt">The second link</a>
|
||||
<a href="http://$escaped_hostname/foo3.txt">The third link</a>
|
||||
EOF
|
||||
|
||||
my $result_file = <<EOF;
|
||||
@@ -38,6 +41,22 @@ my %urls = (
|
||||
},
|
||||
content => $result_file,
|
||||
},
|
||||
"http://$punycoded_hostname/foo2.txt" => {
|
||||
code => "200",
|
||||
msg => "Uh-huh2",
|
||||
headers => {
|
||||
'Content-Type' => 'text/plain',
|
||||
},
|
||||
content => $result_file,
|
||||
},
|
||||
"http://$punycoded_hostname/foo3.txt" => {
|
||||
code => "200",
|
||||
msg => "Uh-huh3",
|
||||
headers => {
|
||||
'Content-Type' => 'text/plain',
|
||||
},
|
||||
content => $result_file,
|
||||
},
|
||||
"http://$punycoded_hostname/robots.txt" => {
|
||||
code => "200",
|
||||
msg => "Uh-huh",
|
||||
@@ -48,7 +67,7 @@ my %urls = (
|
||||
},
|
||||
);
|
||||
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -rH"
|
||||
my $cmdline = $WgetTest::WGETPATH . " --iri -r"
|
||||
. " -e http_proxy=localhost:{{port}} --local-encoding=EUC-JP"
|
||||
. " http://$euc_jp_hostname/";
|
||||
|
||||
@@ -61,6 +80,12 @@ my %expected_downloaded_files = (
|
||||
"$punycoded_hostname/foo.txt" => {
|
||||
content => $result_file,
|
||||
},
|
||||
"$punycoded_hostname/foo2.txt" => {
|
||||
content => $result_file,
|
||||
},
|
||||
"$punycoded_hostname/foo3.txt" => {
|
||||
content => $result_file,
|
||||
},
|
||||
"$punycoded_hostname/robots.txt" => {
|
||||
content => '',
|
||||
},
|
||||
|
||||
@@ -35,6 +35,12 @@ my @tests = (
|
||||
'Test-ftp-iri-fallback.px',
|
||||
'Test-ftp-iri-recursive.px',
|
||||
'Test-ftp-iri-disabled.px',
|
||||
'Test-ftp-list-Multinet.px',
|
||||
'Test-ftp-list-Unknown.px',
|
||||
'Test-ftp-list-Unknown-a.px',
|
||||
'Test-ftp-list-Unknown-hidden.px',
|
||||
'Test-ftp-list-Unknown-list-a-fails.px',
|
||||
'Test-ftp-list-UNIX-hidden.px',
|
||||
'Test-HTTP-Content-Disposition-1.px',
|
||||
'Test-HTTP-Content-Disposition-2.px',
|
||||
'Test-HTTP-Content-Disposition.px',
|
||||
@@ -70,6 +76,7 @@ my @tests = (
|
||||
'Test-O--no-content-disposition-trivial.px',
|
||||
'Test-O-nonexisting.px',
|
||||
'Test-O.px',
|
||||
'Test--post-file.px',
|
||||
'Test-O-nc.px',
|
||||
'Test-restrict-ascii.px',
|
||||
'Test-Restrict-Lowercase.px',
|
||||
@@ -80,6 +87,7 @@ my @tests = (
|
||||
'Test--spider-r--no-content-disposition.px',
|
||||
'Test--spider-r--no-content-disposition-trivial.px',
|
||||
'Test--spider-r.px',
|
||||
'Test--httpsonly-r.px',
|
||||
);
|
||||
|
||||
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
|
||||
|
||||
Reference in New Issue
Block a user