mirror of
https://github.com/xroche/httrack.git
synced 2026-06-29 05:26:32 +03:00
Compare commits
4 Commits
feature/ap
...
fix/copy-h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4549ec3695 | ||
|
|
ac56c31b24 | ||
|
|
ee6beeeb7d | ||
|
|
6788bda380 |
@@ -3702,7 +3702,9 @@ HTSEXT_API int copy_htsopt(const httrackp * from, httrackp * to) {
|
|||||||
if (from->maxsoc > 0)
|
if (from->maxsoc > 0)
|
||||||
to->maxsoc = from->maxsoc;
|
to->maxsoc = from->maxsoc;
|
||||||
|
|
||||||
if (from->nearlink > -1)
|
/* hts_boolean/enum fields are unsigned (GCC), so a bare `> -1` unset-guard
|
||||||
|
is always false; cast to int to keep the -1 "unset" sentinel test. */
|
||||||
|
if ((int) from->nearlink > -1)
|
||||||
to->nearlink = from->nearlink;
|
to->nearlink = from->nearlink;
|
||||||
|
|
||||||
if (from->timeout > -1)
|
if (from->timeout > -1)
|
||||||
@@ -3729,10 +3731,10 @@ HTSEXT_API int copy_htsopt(const httrackp * from, httrackp * to) {
|
|||||||
if (from->hostcontrol > -1)
|
if (from->hostcontrol > -1)
|
||||||
to->hostcontrol = from->hostcontrol;
|
to->hostcontrol = from->hostcontrol;
|
||||||
|
|
||||||
if (from->errpage > -1)
|
if ((int) from->errpage > -1)
|
||||||
to->errpage = from->errpage;
|
to->errpage = from->errpage;
|
||||||
|
|
||||||
if (from->parseall > -1)
|
if ((int) from->parseall > -1)
|
||||||
to->parseall = from->parseall;
|
to->parseall = from->parseall;
|
||||||
|
|
||||||
// test all: bit 8 de travel
|
// test all: bit 8 de travel
|
||||||
|
|||||||
@@ -3096,6 +3096,41 @@ static int hts_main_internal(int argc, char **argv, httrackp * opt) {
|
|||||||
htsmain_free();
|
htsmain_free();
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
case '9': { // copy_htsopt selftest: httrack -#9
|
||||||
|
httrackp *from = hts_create_opt();
|
||||||
|
httrackp *to = hts_create_opt();
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
/* from-values differ from both the to-values and the
|
||||||
|
hts_create_opt() defaults (nearlink FALSE, errpage/parseall
|
||||||
|
TRUE), so a copy that no-ops or just resets to defaults is
|
||||||
|
caught too, not only the unsigned-guard bug. */
|
||||||
|
from->retry = 7; /* int field: positive control */
|
||||||
|
to->retry = 0;
|
||||||
|
from->nearlink = HTS_TRUE;
|
||||||
|
to->nearlink = HTS_FALSE;
|
||||||
|
from->errpage = HTS_FALSE;
|
||||||
|
to->errpage = HTS_TRUE;
|
||||||
|
from->parseall = HTS_FALSE;
|
||||||
|
to->parseall = HTS_TRUE;
|
||||||
|
|
||||||
|
copy_htsopt(from, to);
|
||||||
|
|
||||||
|
if (to->retry != 7)
|
||||||
|
err = 1;
|
||||||
|
if (to->nearlink != HTS_TRUE)
|
||||||
|
err = 1;
|
||||||
|
if (to->errpage != HTS_FALSE)
|
||||||
|
err = 1;
|
||||||
|
if (to->parseall != HTS_FALSE)
|
||||||
|
err = 1;
|
||||||
|
|
||||||
|
hts_free_opt(from);
|
||||||
|
hts_free_opt(to);
|
||||||
|
printf("copy-htsopt: %s\n", err ? "FAIL" : "OK");
|
||||||
|
htsmain_free();
|
||||||
|
return err;
|
||||||
|
} break;
|
||||||
case '!':
|
case '!':
|
||||||
HTS_PANIC_PRINTF
|
HTS_PANIC_PRINTF
|
||||||
("Option #! is disabled for security reasons");
|
("Option #! is disabled for security reasons");
|
||||||
|
|||||||
10
src/htsopt.h
10
src/htsopt.h
@@ -342,17 +342,17 @@ typedef enum hts_seeker {
|
|||||||
HTS_SEEKER_UP = 1 << 1 /**< may ascend to parent directories */
|
HTS_SEEKER_UP = 1 << 1 /**< may ascend to parent directories */
|
||||||
} hts_seeker;
|
} hts_seeker;
|
||||||
|
|
||||||
/* Link-following scope, stored in the low byte of opt->travel. */
|
/* opt->travel: link-following scope in the low byte, flags OR'd in above it. */
|
||||||
typedef enum hts_travel_scope {
|
typedef enum hts_travel_scope {
|
||||||
HTS_TRAVEL_SAME_ADDRESS = 0, /**< stay on the same address (host) */
|
HTS_TRAVEL_SAME_ADDRESS = 0, /**< stay on the same address (host) */
|
||||||
HTS_TRAVEL_SAME_DOMAIN = 1, /**< stay on the same principal domain */
|
HTS_TRAVEL_SAME_DOMAIN = 1, /**< stay on the same principal domain */
|
||||||
HTS_TRAVEL_SAME_TLD = 2, /**< stay on the same TLD (e.g. .com) */
|
HTS_TRAVEL_SAME_TLD = 2, /**< stay on the same TLD (e.g. .com) */
|
||||||
HTS_TRAVEL_EVERYWHERE = 7 /**< follow links anywhere on the web */
|
HTS_TRAVEL_EVERYWHERE = 7, /**< follow links anywhere on the web */
|
||||||
|
HTS_TRAVEL_TEST_ALL = 1 << 8 /**< also test forbidden URLs (-t) */
|
||||||
} hts_travel_scope;
|
} hts_travel_scope;
|
||||||
|
|
||||||
/* Flags OR'd into opt->travel above the scope value. */
|
/* Mask selecting the scope value out of opt->travel. */
|
||||||
#define HTS_TRAVEL_SCOPE_MASK 0xff /**< mask selecting the scope value */
|
#define HTS_TRAVEL_SCOPE_MASK 0xff
|
||||||
#define HTS_TRAVEL_TEST_ALL (1 << 8) /**< also test forbidden URLs (-t) */
|
|
||||||
|
|
||||||
/* Text progress display detail (opt->verbosedisplay). */
|
/* Text progress display detail (opt->verbosedisplay). */
|
||||||
typedef enum hts_verbosedisplay {
|
typedef enum hts_verbosedisplay {
|
||||||
|
|||||||
17
tests/01_engine-copyopt.test
Executable file
17
tests/01_engine-copyopt.test
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Regression guard for the unsigned-enum sentinel trap: copy_htsopt's
|
||||||
|
# `if (from->X > -1)` guard is always false for unsigned hts_boolean fields, so
|
||||||
|
# they silently stop being copied. Driven by the in-process 'httrack -#9' test.
|
||||||
|
# Keep POSIX-portable (harness runs it via $(BASH), a plain /bin/sh on macOS).
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# A trailing token is required; a bare '-#9' falls through to the usage screen.
|
||||||
|
out=$(httrack -#9 run)
|
||||||
|
|
||||||
|
# Exact-match the success line so a fall-through to usage can't pass the test.
|
||||||
|
test "$out" = "copy-htsopt: OK" || {
|
||||||
|
echo "expected 'copy-htsopt: OK', got: $out" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ TESTS = \
|
|||||||
01_engine-cache-golden.test \
|
01_engine-cache-golden.test \
|
||||||
01_engine-charset.test \
|
01_engine-charset.test \
|
||||||
01_engine-cmdline.test \
|
01_engine-cmdline.test \
|
||||||
|
01_engine-copyopt.test \
|
||||||
01_engine-doitlog.test \
|
01_engine-doitlog.test \
|
||||||
01_engine-entities.test \
|
01_engine-entities.test \
|
||||||
01_engine-filter.test \
|
01_engine-filter.test \
|
||||||
|
|||||||
Reference in New Issue
Block a user