218 Commits

Author SHA1 Message Date
bfcd65c12b Use typedefs for function pointer arguments
* include/wget/wget.h: Add typedefs
* libwget/cookie.c: Use typedefs
* libwget/css.c: Likewise
* libwget/css_url.c: Likewise
* libwget/decompressor.c: Likewise
* libwget/hashmap.c: Likewise
* libwget/hsts.c: Likewise
* libwget/http.c: Likewise
* libwget/init.c: Likewise
* libwget/io.c: Likewise
* libwget/list.c: Likewise
* libwget/logger.c: Likewise
* libwget/metalink.c: Likewise
* libwget/net.c: Likewise
* libwget/netrc.c: Likewise
* libwget/ocsp.c: Likewise
* libwget/private.h: Likewise
* libwget/robots.c: Likewise
* libwget/stringmap.c: Likewise
* libwget/tls_session.c: Likewise
* libwget/vector.c: Likewise
* libwget/xml.c: Likewise
* src/blacklist.c: Likewise
* src/host.c: Likewise
* src/options.c: Likewise
* src/wget.c: Likewise
* tests/stringmap_perf.c: Likewise
* tests/test.c: Likewise
2017-01-23 14:43:17 +01:00
27448004c1 * tests/stringmap_perf.c: Use wget_malloc if mmap not available 2017-01-06 12:14:16 +01:00
5582908092 Remove redundant check for _WIN64 2017-01-05 12:18:56 +01:00
43f30f309e Rename wget_str_[v]asprintf to wget_[v]aprintf
* include/wget/wget.h: Rename wget_str_[v]asprintf to wget_[v]aprintf
* libwget/http.c: Likewise
* libwget/iri.c: Likewise
* libwget/printf.c: Likewise
* libwget/vector.c: Likewise
* src/options.c: Likewise
* tests/test-metalink.c: Likewise
2016-12-21 11:54:36 +01:00
6286482849 * tests/test-bad-chunk.c: Remove WGET_TEST_KEEP_TMPFILES 2016-12-03 23:04:28 +01:00
6162f84c9d Add tests with bad chunk size in the HTTP response
* tests/Makefile.am: Add test-bad-chunk.c
* tests/test-bad-chunk.c: New file with 3 tests
2016-12-02 17:54:09 +01:00
909afd75fc Make the visibiity attribute preceed the prototype
* include/wget/wget.h: Make library symbol export attribute
((__visibility__)) preceed the function prototype to work on Windows
with MSVC
* tests/libtest.h: Same

Reported-by: Gisle Vanem
2016-11-16 12:03:27 +01:00
ecbfea77c0 Rename LIBWGET_EXPORT to WGETAPI
* include/wget/wget.t: Rename LIBWGET_EXPORT to WGETAPI
* tests/libtest.h: Same
2016-11-16 11:45:46 +01:00
8b1a701c21 Use wget_strdup() instead of strdup()
* examples/getstream.c: Use wget_strdup().
* libwget/cookie.c: Likewise.
* libwget/encoding.c: Likewise.
* libwget/http.c: Likewise.
* libwget/iri.c: Likewise.
* libwget/netrc.c: Likewise.
* src/options.c: Likewise.
* src/wget.c: Likewise.
* tests/test.c: Likewise.
2016-11-03 09:58:09 +01:00
b049eb6d3a Fix gcc/clang warnings from the new manywarnings feature
* configure.ac: Suppress -Wunsuffixed-float-constants for gcc,
  add -Wno-disabled-macro-expansion to clang flags
* examples/getstream.c: Removed 'unused' attributes from argc and argv.
* include/wget/wget.h: Fix slot to int for bar functions.
* libwget/bar.c: Fix slot to int for bar functions, cast to int,
  change type of bitfield 'redraw' to unsigned.
* libwget/hsts.c (wget_hsts_new): Fix int to bitfield conversion.
* libwget/http.c: Cast printf %p format to (void *).
* src/wget.c: Cast printf %p format to (void *),
  remove ACTION_DONE from enum actions.
* src/wget_host.h: Fix double declaration of host_remove_job()
* tests/libtest.c (wget_test_check_filesystem): Fix type of 'rc'.
* tests/test-idn-robots.c: Fix comma to semikolon at end of line.
* tests/test.c (test_strcasecmp_ascii): Fix type of loop variable.
2016-11-02 22:19:41 +01:00
0bcf75bb9b * tests/test-iri.c: Fix test to work on non-UTF-8 locales 2016-10-17 11:41:13 +02:00
0bcd506146 * tests/test-iri-percent.c: Fix test to work on non-UTF-8 locales 2016-10-17 11:41:10 +02:00
bcf1455834 * tests/test-restrict-ascii.c: Fix test to work on non-UTF-8 locales 2016-10-17 11:41:07 +02:00
502b751e54 Support --header option
* src/options.c: Add new --header option and a new parse_header()
parsing function for that. Also add self tests for parsing
* src/wget_options.h: Same
* src/wget.c (http_create_request): Add the user added headers to the
HTTP Request
* src/test-wget-1.c: Add a test for the --header option
2016-10-13 22:37:28 +02:00
2da0ad63dd Improved testing on Travis
* .travis.sh: Rewrite for clarity and speed. Testing shows that valgrind
and ASan don't play well together. So split their executions.
* .travis.yml: Enable ccache for builds. Also try to update libc6 if
possible
* .travis.yml: Do not run on OSX with CC=gcc. This is because on OSX,
gcc is only a wrapper around clang.
* .travis_setup.sh: Cosmetic changes only
* Makefile.am (check-coverage): Explcicitly disable valgrind tests when
checking coverage
* tests/libtest.c (wget_test): Use a provided suppressions file for
valgrind. This is required since the valgrind version on Travis seems to
be out of sync with libc. This causes valgrind to report a memory bug
falsely.
* tests/valgrind-suppressions: New file with some valgrind suppressions.
Included suppressions are for a valgrind/libc bug and to suppress
reachable memory messages from within gnutls
2016-10-07 17:51:48 +02:00
e10cf1d1f3 Move window size detection to libwget
* include/wget/wget.h: Declare new function wget_determine_screen_width.
Also change prototype of wget_bar_init to not accept a max_width
parameter
* src/utils.c: Move function determine_screen_width from here ...
* libwget/utils.c: ... to here.
* src/utils.{c,h}: Delete empty file
* src/Makefile.am: Remove source files utils.{c,h}
* src/bar.c: Move detection of screen width from here ...
* libwget/bar.c: ... to here
* tests/test.c: wget_bar_init() no longer takes a max_width parameter
2016-10-04 20:29:30 +02:00
554a34422b Better code coverage for HTML parsing
* tests/test-idn-meta.c: Add HTML5 meta charset
* tests/test-meta-robots.c: Add meta robots 'all' and 'follow'
2016-09-30 16:30:32 +02:00
9568b0c87e Rename include/libwget.h to include/wget/wget.h+wgetver.h 2016-09-30 09:47:32 +02:00
a9c509898b Add tests for CSS parsing
* tests/Makefile.am: Add test-parse-css.c
* tests/test-parse-css.c: New file including two tests
2016-09-29 16:23:32 +02:00
4ac70bf7c3 * tests/test.c: Add wget_bar_* unit test 2016-09-29 11:53:04 +02:00
e3a314d2ab Fix unescaping of '+' in URL
* libwget/iri.c (wget_iri_unescape_inline): Do not touch '+'.
  (wget_iri_parse): Replace '+' by ' ' in query part.
* tests/test.c (test_iri_parse): Add more tests
2016-09-27 11:32:34 +02:00
36b095fd64 Fix Robots Exclusion Standard
* include/libwget.h.in: Add function wget_list_getnext().
* libwget/list.c: Add function wget_list_getnext().
* libwget/robots.c: Fix memory leak.
* src/host.c (host_remove_job): Cleanup queue after downloading and
  scanning robots.txt.
* src/job.h (struct JOB): Add flag 'requested_by_user'.
* src/wget.c (add_url_to_queue): Set 'requested_by_user',
  (add_url): Fix checking for disallowed paths.
* tests/Makefile.am: Add test 'test-robots'.
* tests/test-robots.c: New test to prove robots functionality.

Special handling for automatic robots.txt jobs
==============================================
What can happen with --recursive and --span-hosts is that a document from hostA
has links to hostB. All these links might go into the hostB queue before robots.txt
is downloaded and parsed. To avoid downloading of 'disallowed' documents, the queue
for hostB has to be cleaned up right after downloading and parsing robots.txt.
Any links links that have been explicitly requested by the user are still downloaded.
2016-09-19 15:23:48 +02:00
00f126c585 Fix following relative links
* src/wget.c (html_parse): Add only absolute URLs to 'known_urls'.
* tests/test-base.c: Test that the changes work.

Reported-by: Jaaap@github.com
2016-09-16 16:14:08 +02:00
10d2091795 * tests/test.c: Fix cookie tests for when libpsl not available 2016-08-28 12:30:34 +02:00
667127e193 Support cookie prefixes __Secure- and __Host-
* libwget/cookie.c (_wget_cookie_normalize_cookie): Add checks
  for __Secure- and __Host- prefixes.
* tests/test.c (test_cookies): Add test cases for the prefixes.

This change implements proposals from draft-ietf-httpbis-cookie-prefixes-00
as modern browsers do.
2016-08-28 00:01:19 +02:00
9ca39a7dbd Make compiler happy about using uninitialized vars
* tests/test.c(test_striconv): Explcitly initialize variables to
    NULL to make compiler happy.
2016-07-28 20:57:48 +02:00
83ecee98ce Make ASan happy about dangling memory in test-metalink
* tests/test-metalink.c: Explicitly free() heap allocated memory
2016-07-28 11:36:24 +02:00
2ab2611f4b Fix a ubsan warning due to zero length VLA 2016-07-23 20:38:57 +02:00
35cabe3726 Add new test to check for continue and -O options
* tests/test-wget-1.c: Add new test. If the remote filename
    exists locally, then Wget2 tries to conitnue downloading that file
    despite being given an explicit output document. This test checks
    for such behaviour.
2016-07-22 18:49:24 +02:00
79dd277c12 Refactoring to separate send, receive and HTTP state machine
* examples/websequencediagram.c (main): Call wget_http_request_set_body()
  and wget_http_send_request() instead of wget_http_send_request_with_body().
* include/libwget.h.in: Add WGET_HTTP_USER_DATA, wget_get_timemillis(),
  extend wget_thread_cond_wait(), add body, user_data, body_length to
  wget_http_request_t, remove wget_http_send_request_with_body(),
  add wget_http_request_get_int(), wget_http_request_set_ptr(),
  wget_http_request_get_ptr(), wget_http_request_set_body().
* libwget/http.c: Add wget_http_request_get_int(),
  wget_http_request_set_ptr(), wget_http_request_get_ptr(),
  wget_http_request_set_body(),
  remove wget_http_send_request_with_body(),
  (wget_http_request_to_buffer): add body to request buffer.
* libwget/http_highlevel.c (wget_http_get): Replace
  wget_http_send_request_with_body()
* libwget/iri.c: Use c-ctype.h instead of ctype.h
  (wget_iri_parse): Allow any numbers of / after scheme:
  (wget_iri_parse): Catch URIs without /after scheme:
* libwget/list.c (wget_list_browse): Small code rearrangement
* libwget/metalink.c (_add_mirror): Check mirror.iri for NULL
* libwget/ssl_gnutls.c (send_ocsp_request): Replace
  wget_http_send_request_with_body()
* libwget/thread.c (wget_thread_cond_signal): Add timeout param
* libwget/utils.c: New function wget_get_timemillis()
* src/blacklist.c: Include wget.h instead of log.h
* src/blacklist.h: Fix indentation
* src/host.c: Add queueing stuff
* src/host.h: Reflect changes in host.c
* src/job.c: Remove queueing stuff
* src/job.h: Reflect changes in job.c
* src/log.c: Sync stdout/stderr to correct output order
* src/log.h: Remove shortcuts of print functions
* src/wget.c: Remove download_part() and http_get().
  Add http_send_request(), http_receive_response(), try_connection(),
  establish_connection(), add_statistics(), process_response_header().
  Amend downloader_thread() to reflect the changes.
* src/wget.h: Add shortcut defines for print functions.
* tests/libtest.c (_http_server_thread): Fix compiler warning,
  fix debug message.
  New function _write_msg() to print server messages yellow.
  (wget_test) Add -d to wget command line.
* tests/test-metalink.c (main): Add tests for V3 and V4 metalink
  files read from command line (-i, --force-metalink)
* tests/test.c (test_iri_parse): Add test for slash-less mailto: URI
2016-07-11 14:53:36 +02:00
d393fc4ed5 Fix compiler warnings in test suite
* tests/libtest.c (wget_test_check_filesystem): Fix printf
  format warning
* tests/test-parse-html.c (html_dump): Add switch default case,
  fix printf format warning
2016-06-15 16:42:27 +02:00
9cff7dd096 Fix printf format warnings
* tests/buffer_printf_perf.c: Fix printf format warnings
* tests/stringmap_perf.c: Likewise
* tests/test.c: Likewise
2016-06-14 15:55:53 +02:00
a8d99227e8 Add gnulib module 'manywarnings'
* autogen.sh: Add module manywarnings
* configure.ac: Add ./configure option --enable-gcc-warnings to enable
 many warnings
* examples/Makefile.am: Add WERROR_CFLAGS and WARN_CFLAGS to AM_CFLAGS
* libwget/Makefile.am: Likewise
* src/Makefile.am: Likewise
* tests/Makefile.am: Likewise
2016-06-14 12:22:03 +02:00
4d5aff5ff5 Fix FTP PASV listening in test suite
* tests/libtest.c: Fix FTP PASV listening
2016-06-06 18:52:03 +02:00
37687a2c5b Let test suite survive on case-sensitive filesystems (e.g. HFS+)
* tests/libtest.c: New function wget_test_check_filesystem(),
  (_empty_directory, _remove_directory): Do not print
  errors about missing directories.
* tests/libtest.h: Add define WGET_TEST_FS_CASEMATTERS
* tests/test--accept.c: Renamed files to avoid casing problems
* tests/test-wget-1.c: Skip casing tests on case-sensitive filesystem
2016-05-19 16:55:43 +02:00
f2848ee0d2 Add option --content-on-error
* src/options.c: Add --content-on-error to options and to help text
* src/options.h: Add content_on_error to struct config
* src/wget.c: Check config.content_on_error
* tests/test-wget-1.c: Add tests for --content-on-error
2016-05-14 15:22:52 +02:00
d4ed8ee26a Add EXEEXT to test suite executables
* tests/Makefile.am: Add $(EXEEXT) to executable names
* tests/libtest.c: Add EXEEXT to wget2 executable,
  add support for EMULATOR env variable - e.g. to test with wine
2016-05-08 23:03:51 +02:00
483c304aef Support parsing of UTF-16 HTML documents
* examples/print_html_urls.c (html_parse_localfile):
  Detect BOM (Byte Order Mark), convert UTF-16 to UTF-8 before parsing.
* include/libwget.h.in: Remove wget_charset_transcode(),
  add wget_memiconv() and wget_striconv().
* libwget/encoding.c: Implement wget_memiconv() and wget_striconv()
* src/wget.c (html_parse): Add 'html_len' param,
  convert UTF-16 to UTF-8 before parsing.
* tests/test.c: New test for wget_memiconv().
2016-04-24 15:08:20 +02:00
db2d7ed3c6 Rename --follow-metalink to --metalink
* src/options.c, src/options.h, src/wget.c, tests/test-metalink.c:
  Rename --follow-metalink to --metalink, rename config.follow_metalink
  to config.metalink.
2016-04-02 21:00:24 +02:00
73827d76f8 Add tests for RFC 6249 Metalink in HTTP headers
* tests/test-metalink.c: Add tests
2016-04-02 19:43:18 +02:00
92ca98177a Add tests for Metalink
* tests/Makefile.am: Add test-metalink
* tests/test-metalink.c: New file

This new tests are
- --no-follow-metalink
- metalink v3, without pieces
- metalink v4, without pieces
- metalink v4, with pieces
2016-03-31 22:03:58 +02:00
385e0d52b3 Allow options and URLs in any order
* src/options.c (parse_command_line): Reorder URLs after options
* src/options.h: Fix init() prototype
* src/wget.c, tests/test-parse-html.c, tests/test.c:
  Fix main() argv argument
2016-03-28 21:58:10 +02:00
9b16dc1011 Tune cookie parsing
* include/libwget.h.in: Add sort_age to struct wget_cookie_st
* libwget/cookie.c: Many code enhancements
* libwget/http.c (wget_http_parse_setcookie): Relax parsing,
  (wget_http_parse_setcookie): Allow \n and \r\n as EOL
* libwget/private.h: Add missing #includes
* tests/Makefile.am: Add disabled test-cookies-http_state
* tests/test-cookies-http_state.c: New cookie test

There still 30 out of 220 tests failing, before this commit we had
135 failing. The left over tests are mainly corner cases, but feel free
to work on it. When all tests pass, we enable test-cookies-http_state
in Makefile.am.
2016-03-18 17:01:49 +01:00
c6890e95cd Use wget2 without libtool wrapper for test suite
* src/Makefile.am: Add wget2_noinstall target
* src/wget.c: On exit, only release memory within test suite
* tests/libtest.c: Call wget2_noinstall for testing
2016-03-14 15:59:17 +01:00
0ff0a43600 Add support for HTML5 srcset attribute in IMG tags
* libwget/html_url.c: Add scanning srcset values
* tests/test--page-requisites.c: Add srcset test cases
2016-03-01 11:08:42 +01:00
a582d324d6 Fix / silence some Coverity findings 2016-02-07 12:48:41 +01:00
2c9f5945f5 Honor --disable-threads and support no threading
* include/libwget.h.in: Include <stdbool.h>.
Define wget_thread_support().
* libwget/thread.c: Change condition to check
for threading support.
(wget_thread_support): New function.
(wget_thread_start): [!USE_POSIX_THREADS && !USE_PTH_THREADS]
Invoke directly the function.
* src/wget.c (main): If no threads are supported then set the
number of max threads to 1.  If the queue is not empty, call again the
downloader function.  It will be used only in case no threads are
available.
(downloader_thread): Do not wait for new elements in the queue
when there are no threads.
* tests/libtest.c (wget_test_start_server): Skip the test if
there is no threads support.
2016-02-02 18:45:17 +01:00
dd3c2f63b2 Updated copyright year for all relevant files 2016-01-25 13:06:21 +01:00
41bcd1c85c Switch to Travis-CI valgrind testing
* .travis.sh: Add --enable-valgrind-tests to ./configure,
  export VALGRIND_TESTS=1
* .travis.yml: Install valgridn on Mac OS X
* tests/libtest.c: Add --max-threads=1 --prefer-family=ipv4 to wget2 command
2016-01-24 15:54:23 +01:00
fb840427d2 Add $(LIB_PTHREAD) to makefiles
* examples/Makefile.am, libwget/Makefile.am, src/Makefile.am,
  tests/Makefile.am: Add $(LIB_PTHREAD)
2016-01-23 22:51:43 +01:00