mirror of
https://github.com/xroche/httrack.git
synced 2026-07-27 11:03:13 +03:00
Compare commits
20 Commits
feat/chang
...
feat/singl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0130473dc1 | ||
|
|
7e2209d4cc | ||
|
|
8b72e3dddf | ||
|
|
5ee188ba1a | ||
|
|
d3a915641f | ||
|
|
15e2c701a5 | ||
|
|
6bd4209c94 | ||
|
|
a228cede8a | ||
|
|
b5db9bb7ed | ||
|
|
37ee129810 | ||
|
|
06dc54fa44 | ||
|
|
42072f54b0 | ||
|
|
5f3787eb28 | ||
|
|
4a62cfb75b | ||
|
|
906906efa7 | ||
|
|
f50307d878 | ||
|
|
c6b7c407ed | ||
|
|
a1226401e0 | ||
|
|
71ca31e2ec | ||
|
|
b90d699d2e |
5
.github/workflows/windows-build.yml
vendored
5
.github/workflows/windows-build.yml
vendored
@@ -227,8 +227,9 @@ jobs:
|
||||
# tested nothing: pin the skips, and floor the passes in case the glob empties.
|
||||
# footer-overflow skips on Windows (needs a path past MAX_PATH); crange pending #581;
|
||||
# webdav-mime needs a reapable background listener, which MSYS cannot give it;
|
||||
# badmtime needs a filesystem that stores an mtime past gmtime's range.
|
||||
expected_skips=" 01_engine-footer-overflow.test 48_local-crange-memresume.test 71_local-crange-repaircache.test 79_local-proxytrack-webdav-mime.test 88_local-proxytrack-badmtime.test"
|
||||
# badmtime needs a filesystem that stores an mtime past gmtime's range;
|
||||
# single-file ends on a GUI half needing htsserver, which this job does not build.
|
||||
expected_skips=" 01_engine-footer-overflow.test 48_local-crange-memresume.test 71_local-crange-repaircache.test 79_local-proxytrack-webdav-mime.test 88_local-proxytrack-badmtime.test 94_local-single-file.test"
|
||||
[ "$pass" -ge 90 ] || { echo "::error::only $pass tests passed ($skip skipped)"; exit 1; }
|
||||
[ "$skipped" = "$expected_skips" ] || { echo "::error::unexpected skips:$skipped"; exit 1; }
|
||||
[ "$fail" -eq 0 ] || { echo "::error::failing:$failed"; exit 1; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
if FUZZERS
|
||||
noinst_PROGRAMS = fuzz-charset fuzz-meta fuzz-idna fuzz-entities \
|
||||
fuzz-unescape fuzz-filters fuzz-url fuzz-header fuzz-cachendx \
|
||||
fuzz-htsparse
|
||||
fuzz-htsparse fuzz-singlefile
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
@@ -27,6 +27,7 @@ fuzz_url_SOURCES = fuzz-url.c fuzz.h
|
||||
fuzz_header_SOURCES = fuzz-header.c fuzz.h
|
||||
fuzz_cachendx_SOURCES = fuzz-cachendx.c fuzz.h
|
||||
fuzz_htsparse_SOURCES = fuzz-htsparse.c fuzz.h
|
||||
fuzz_singlefile_SOURCES = fuzz-singlefile.c fuzz.h
|
||||
|
||||
# List corpus files explicitly: automake does not expand EXTRA_DIST globs.
|
||||
EXTRA_DIST = README.md run-fuzzers.sh \
|
||||
@@ -47,4 +48,8 @@ EXTRA_DIST = README.md run-fuzzers.sh \
|
||||
corpus/cachendx/regress-overadvance.bin \
|
||||
corpus/cachendx/regress-truncated-entry.bin \
|
||||
corpus/htsparse/basic.html corpus/htsparse/script-inscript.html \
|
||||
corpus/htsparse/meta-usemap.html corpus/htsparse/malformed.html
|
||||
corpus/htsparse/meta-usemap.html corpus/htsparse/malformed.html \
|
||||
corpus/singlefile/img-src.html corpus/singlefile/link-rel.html \
|
||||
corpus/singlefile/style-block.html corpus/singlefile/style-attr.html \
|
||||
corpus/singlefile/srcset.html corpus/singlefile/rawtext.html \
|
||||
corpus/singlefile/malformed.html corpus/singlefile/many-attrs.html
|
||||
|
||||
3
fuzz/corpus/singlefile/img-src.html
Normal file
3
fuzz/corpus/singlefile/img-src.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<img src="a.png">
|
||||
<img src=big.png alt=over-cap>
|
||||
<img src="../escape.png"><img src="/abs.png"><img src="data:,x">
|
||||
4
fuzz/corpus/singlefile/link-rel.html
Normal file
4
fuzz/corpus/singlefile/link-rel.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<link rel="stylesheet" href="s.css">
|
||||
<link rel=icon href=a.png>
|
||||
<link rel="next" href="p2.html">
|
||||
<link rel="preload" href="j.js">
|
||||
5
fuzz/corpus/singlefile/malformed.html
Normal file
5
fuzz/corpus/singlefile/malformed.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<img src="unterminated.png
|
||||
<div style="background:url(a.png">
|
||||
<style>@import url(
|
||||
<!-- unterminated comment
|
||||
<a href=
|
||||
1
fuzz/corpus/singlefile/many-attrs.html
Normal file
1
fuzz/corpus/singlefile/many-attrs.html
Normal file
@@ -0,0 +1 @@
|
||||
<img src="a.png" a0="v" a1="v" a2="v" a3="v" a4="v" a5="v" a6="v" a7="v" a8="v" a9="v" a10="v" a11="v" a12="v" a13="v" a14="v" a15="v" a16="v" a17="v" a18="v" a19="v" a20="v" a21="v" a22="v" a23="v" a24="v" a25="v" a26="v" a27="v" a28="v" a29="v" a30="v" a31="v" a32="v" a33="v" a34="v" a35="v" a36="v" a37="v" a38="v" a39="v" a40="v" a41="v" a42="v" a43="v" a44="v" a45="v" a46="v" a47="v" a48="v" a49="v" a50="v" a51="v" a52="v" a53="v" a54="v" a55="v" a56="v" a57="v" a58="v" a59="v" a60="v" a61="v" a62="v" a63="v" a64="v" a65="v" a66="v" a67="v" a68="v" a69="v">
|
||||
4
fuzz/corpus/singlefile/rawtext.html
Normal file
4
fuzz/corpus/singlefile/rawtext.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<script>var s="</scripting>"; if(a</b) x=1;</script>
|
||||
<script src="j.js"></script>
|
||||
<textarea></textareas></textarea>
|
||||
<title></titles></title>
|
||||
2
fuzz/corpus/singlefile/srcset.html
Normal file
2
fuzz/corpus/singlefile/srcset.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<img srcset="a.png 1x, big.png 2x, a.png 100w">
|
||||
<source srcset="a.png,, a.png 2x," src="a.png">
|
||||
2
fuzz/corpus/singlefile/style-attr.html
Normal file
2
fuzz/corpus/singlefile/style-attr.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<div style="background:url(a.png);list-style:url('a.png')"></div>
|
||||
<p style='background:url("a.png")'>x</p>
|
||||
5
fuzz/corpus/singlefile/style-block.html
Normal file
5
fuzz/corpus/singlefile/style-block.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<style>@import "s.css";
|
||||
@import url(sub/b.css);
|
||||
div{background:url(a.png)}
|
||||
/* url(a.png) */ p:after{content:"url(a.png)"}
|
||||
</style>
|
||||
131
fuzz/fuzz-singlefile.c
Normal file
131
fuzz/fuzz-singlefile.c
Normal file
@@ -0,0 +1,131 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 2026 Xavier Roche and other contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ethical use: we kindly ask that you NOT use this software to harvest email
|
||||
addresses or to collect any other private information about people. Doing so
|
||||
would dishonor our work and waste the many hours we have spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* Fuzz the --single-file rewriter (htssinglefile.c): hostile HTML walked
|
||||
through the tag, CSS url()/@import and srcset parsers, then re-serialized.
|
||||
The resolver is aimed at a private temp tree, so the inlining half (MIME
|
||||
guess, base64, nested stylesheet) is reached and nothing else on disk is. */
|
||||
#include "fuzz.h"
|
||||
|
||||
#include "httrack-library.h"
|
||||
#include "htssinglefile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Between a.png and big.png, so one input reaches both the inline path and the
|
||||
over-cap fallback. */
|
||||
#define FUZZ_SF_CAP 64
|
||||
|
||||
static char sf_root[512];
|
||||
static char sf_page[600];
|
||||
|
||||
/* The asset tree, in removal order: the subdirectory comes after its file. */
|
||||
static const char *const sf_files[] = {"a.png", "big.png", "j.js", "s.css",
|
||||
"sub/b.css", "sub", NULL};
|
||||
|
||||
static void sf_cleanup(void) {
|
||||
char path[700];
|
||||
int i;
|
||||
|
||||
for (i = 0; sf_files[i] != NULL; i++) {
|
||||
snprintf(path, sizeof(path), "%s/%s", sf_root, sf_files[i]);
|
||||
(void) remove(path);
|
||||
}
|
||||
(void) remove(sf_root);
|
||||
}
|
||||
|
||||
/* A missing asset would silently reduce the target to its parser half. */
|
||||
static void sf_write(const char *name, const char *data, size_t len) {
|
||||
char path[700];
|
||||
FILE *fp;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%s", sf_root, name);
|
||||
fp = fopen(path, "wb");
|
||||
if (fp == NULL || fwrite(data, 1, len, fp) != len)
|
||||
abort();
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
static void sf_text(const char *name, const char *data) {
|
||||
sf_write(name, data, strlen(data));
|
||||
}
|
||||
|
||||
static void sf_init(void) {
|
||||
static const char png[] = "\x89PNG\r\n\x1a\n";
|
||||
static const char big[4096] = "\x89PNG";
|
||||
const char *tmp = getenv("TMPDIR");
|
||||
char path[700];
|
||||
|
||||
hts_init();
|
||||
snprintf(sf_root, sizeof(sf_root), "%s/httrack-fuzz-sf-XXXXXX",
|
||||
tmp != NULL && tmp[0] != '\0' ? tmp : "/tmp");
|
||||
if (mkdtemp(sf_root) == NULL)
|
||||
abort();
|
||||
atexit(sf_cleanup);
|
||||
snprintf(sf_page, sizeof(sf_page), "%s/page.html", sf_root);
|
||||
snprintf(path, sizeof(path), "%s/sub", sf_root);
|
||||
if (mkdir(path, 0700) != 0)
|
||||
abort();
|
||||
sf_write("a.png", png, sizeof(png) - 1);
|
||||
sf_write("big.png", big, sizeof(big));
|
||||
sf_text("j.js", "var x=1;\n");
|
||||
/* @import plus a url(), so an inlined stylesheet recurses and its own
|
||||
relative reference is rebased. */
|
||||
sf_text("s.css", "@import url(sub/b.css);\ndiv{background:url(a.png)}\n");
|
||||
sf_text("sub/b.css", "p{background:url(../a.png)}\n");
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
static int inited = 0;
|
||||
|
||||
String out = STRING_EMPTY;
|
||||
httrackp *opt;
|
||||
/* Exact-length, unterminated: the rewriter is span-based, so ASan bounds a
|
||||
read past html_len instead of it landing on a terminator. */
|
||||
char *html = malloct(size != 0 ? size : 1);
|
||||
|
||||
if (!inited) {
|
||||
sf_init();
|
||||
inited = 1;
|
||||
}
|
||||
memcpy(html, data, size);
|
||||
|
||||
opt = hts_create_opt();
|
||||
opt->log = opt->errlog = NULL;
|
||||
opt->single_file_max_size = FUZZ_SF_CAP;
|
||||
|
||||
StringClear(out);
|
||||
(void) singlefile_rewrite_html(opt, sf_root, sf_page, html, size,
|
||||
SINGLEFILE_MAX_PAGE_SIZE, &out);
|
||||
|
||||
StringFree(out);
|
||||
freet(html);
|
||||
hts_free_opt(opt);
|
||||
return 0;
|
||||
}
|
||||
263
html/changes.html
Normal file
263
html/changes.html
Normal file
@@ -0,0 +1,263 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<meta name="description" content="HTTrack is an easy-to-use website mirror utility. It allows you to download a World Wide website from the Internet to a local directory,building recursively all structures, getting html, images, and other files from the server to your computer. Links are rebuiltrelatively so that you can freely browse to the local site (works with any browser). You can mirror several sites together so that you can jump from one toanother. You can, also, update an existing mirror site, or resume an interrupted download. The robot is fully configurable, with an integrated help" />
|
||||
<meta name="keywords" content="httrack, HTTRACK, HTTrack, winhttrack, WINHTTRACK, WinHTTrack, offline browser, web mirror utility, aspirateur web, surf offline, web capture, www mirror utility, browse offline, local site builder, website mirroring, aspirateur www, internet grabber, capture de site web, internet tool, hors connexion, unix, dos, windows 95, windows 98, solaris, ibm580, AIX 4.0, HTS, HTGet, web aspirator, web aspirateur, libre, GPL, GNU, free software" />
|
||||
<title>HTTrack Website Copier - Change report format specification</title>
|
||||
|
||||
<style type="text/css">
|
||||
<!--
|
||||
|
||||
body {
|
||||
margin: 0; padding: 0; margin-bottom: 15px; margin-top: 8px;
|
||||
background: #77b;
|
||||
}
|
||||
body, td {
|
||||
font: 14px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#subTitle {
|
||||
background: #000; color: #fff; padding: 4px; font-weight: bold;
|
||||
}
|
||||
|
||||
#siteNavigation a, #siteNavigation .current {
|
||||
font-weight: bold; color: #448;
|
||||
}
|
||||
#siteNavigation a:link { text-decoration: none; }
|
||||
#siteNavigation a:visited { text-decoration: none; }
|
||||
|
||||
#siteNavigation .current { background-color: #ccd; }
|
||||
|
||||
#siteNavigation a:hover { text-decoration: none; background-color: #fff; color: #000; }
|
||||
#siteNavigation a:active { text-decoration: none; background-color: #ccc; }
|
||||
|
||||
|
||||
a:link { text-decoration: underline; color: #00f; }
|
||||
a:visited { text-decoration: underline; color: #000; }
|
||||
a:hover { text-decoration: underline; color: #c00; }
|
||||
a:active { text-decoration: underline; }
|
||||
|
||||
#pageContent {
|
||||
clear: both;
|
||||
border-bottom: 6px solid #000;
|
||||
padding: 10px; padding-top: 20px;
|
||||
line-height: 1.65em;
|
||||
background-image: url(images/bg_rings.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: top right;
|
||||
}
|
||||
|
||||
#pageContent, #siteNavigation {
|
||||
background-color: #ccd;
|
||||
}
|
||||
|
||||
|
||||
.imgLeft { float: left; margin-right: 10px; margin-bottom: 10px; }
|
||||
.imgRight { float: right; margin-left: 10px; margin-bottom: 10px; }
|
||||
|
||||
hr { height: 1px; color: #000; background-color: #000; margin-bottom: 15px; }
|
||||
|
||||
h1 { margin: 0; font-weight: bold; font-size: 2em; }
|
||||
h2 { margin: 0; font-weight: bold; font-size: 1.6em; }
|
||||
h3 { margin: 0; font-weight: bold; font-size: 1.3em; }
|
||||
h4 { margin: 0; font-weight: bold; font-size: 1.18em; }
|
||||
|
||||
.blak { background-color: #000; }
|
||||
.hide { display: none; }
|
||||
.tableWidth { min-width: 400px; }
|
||||
|
||||
.tblRegular { border-collapse: collapse; }
|
||||
.tblRegular td { padding: 6px; background-image: url(fade.gif); border: 2px solid #99c; }
|
||||
.tblHeaderColor, .tblHeaderColor td { background: #99c; }
|
||||
.tblNoBorder td { border: 0; }
|
||||
|
||||
|
||||
// -->
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<table width="76%" border="0" align="center" cellspacing="0" cellpadding="0" class="tableWidth">
|
||||
<tr>
|
||||
<td><img src="images/header_title_4.gif" width="400" height="34" alt="HTTrack Website Copier" title="" border="0" id="title" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="76%" border="0" align="center" cellspacing="0" cellpadding="3" class="tableWidth">
|
||||
<tr>
|
||||
<td id="subTitle">Open Source offline browser</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="76%" border="0" align="center" cellspacing="0" cellpadding="0" class="tableWidth">
|
||||
<tr class="blak">
|
||||
<td>
|
||||
<table width="100%" border="0" align="center" cellspacing="1" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<table width="100%" border="0" align="center" cellspacing="0" cellpadding="10">
|
||||
<tr>
|
||||
<td id="pageContent">
|
||||
<!-- ==================== End prologue ==================== -->
|
||||
|
||||
<h2 align="center"><em>Change report format specification</em></h2>
|
||||
|
||||
<br />
|
||||
|
||||
Run with <tt>--changes</tt> (<tt>-%d</tt>), HTTrack writes <tt>hts-changes.json</tt>
|
||||
in the project directory, next to <tt>hts-log.txt</tt>, describing what the crawl
|
||||
left new, changed, unchanged and gone compared to the previous mirror. The file is
|
||||
rewritten from scratch at the end of every run, and the log carries a one-line
|
||||
summary of the same counts.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>What "changed" means</h3>
|
||||
|
||||
A resource is changed when its bytes differ, not when the server merely re-sent
|
||||
it. HTTrack compares the payload it just received against the copy the previous
|
||||
run left behind: for pages it parses, the previous payload comes from the cache
|
||||
(the file on disk carries the mirror footer and its crawl date, so its bytes
|
||||
differ on every run); for everything else, the mirrored file is the payload
|
||||
verbatim and is compared directly.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Where no digest can be taken on either side, because the cache is disabled or
|
||||
the previous copy is gone, the report falls back to the transfer signal, and a
|
||||
server that answers 200 rather than 304 reads as changed. Keeping the cache on
|
||||
(the default) is what makes the report precise.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>With the cache off</h3>
|
||||
|
||||
<tt>--cache=0</tt> costs the report more than the digest of a parsed page. The
|
||||
mirror's file index (<tt>hts-cache/new.lst</tt>) is what records which files a
|
||||
run produced, so without it there is no previous mirror to subtract from: nothing
|
||||
is reported <tt>gone</tt>, and whether the run is a first crawl cannot be decided
|
||||
at all, which <tt>first_crawl</tt> states as <tt>null</tt> rather than guess. What
|
||||
is on disk is still compared byte for byte, so the other three lists stay
|
||||
meaningful, except for the pages HTTrack parses: those have no cached payload to
|
||||
compare against and fall back to the transfer signal.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>Fields</h3>
|
||||
|
||||
<ul>
|
||||
<li><tt>schema</tt>: format version, currently <tt>1</tt>. It is bumped only
|
||||
on an incompatible change; new fields may appear without one.</li>
|
||||
<li><tt>generator</tt>: the HTTrack build that wrote the file.</li>
|
||||
<li><tt>date</tt>: when the report was written, UTC, <tt>YYYY-MM-DDThh:mm:ssZ</tt>.</li>
|
||||
<li><tt>first_crawl</tt>: true when no index of a previous mirror
|
||||
(<tt>hts-cache/old.lst</tt>) was found, so there was nothing to compare against and
|
||||
everything is listed as new. Null when the run kept no index at all and the
|
||||
question cannot be answered (see above).</li>
|
||||
<li><tt>partial</tt>: true when the report ran out of memory and lists only
|
||||
part of the mirror.</li>
|
||||
<li><tt>purged</tt>: true when <tt>--purge-old</tt> was in effect, so the
|
||||
files under <tt>gone</tt> were also deleted from disk.</li>
|
||||
<li><tt>counts</tt>: the size of each of the four lists.</li>
|
||||
<li><tt>new</tt>, <tt>changed</tt>, <tt>unchanged</tt>, <tt>gone</tt>: the
|
||||
lists themselves. Every mirrored file appears in exactly one of them.</li>
|
||||
</ul>
|
||||
|
||||
Each entry is an object:
|
||||
|
||||
<ul>
|
||||
<li><tt>url</tt>: the absolute URL the file came from. Empty under
|
||||
<tt>gone</tt>: deletions are computed from the mirror's file index, which records
|
||||
paths, not URLs.</li>
|
||||
<li><tt>file</tt>: the path relative to the mirror root, with forward
|
||||
slashes. This is the entry's identity: a URL and a redirect that resolve to the
|
||||
same local file are one entry, not two.</li>
|
||||
<li><tt>size</tt>: the mirrored file's size in bytes, absent when the file
|
||||
is not on disk.</li>
|
||||
<li><tt>previous_size</tt>: under <tt>changed</tt> only, the size of the
|
||||
copy the previous run left.</li>
|
||||
</ul>
|
||||
|
||||
<br />
|
||||
|
||||
<h3>Encoding</h3>
|
||||
|
||||
The file is JSON, UTF-8. URLs and local paths reach HTTrack as raw bytes and are
|
||||
not guaranteed to be valid UTF-8; any byte sequence that is not becomes
|
||||
U+FFFD (<tt>\ufffd</tt>), so the file always parses. Compare on <tt>file</tt>
|
||||
rather than on <tt>url</tt> when a mirror is known to carry legacy-charset URLs.
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<pre>
|
||||
{
|
||||
"schema": 1,
|
||||
"generator": "HTTrack Website Copier/3.49-14",
|
||||
"date": "2026-07-26T15:29:03Z",
|
||||
"first_crawl": false,
|
||||
"partial": false,
|
||||
"purged": true,
|
||||
"counts": { "new": 1, "changed": 1, "unchanged": 1, "gone": 1 },
|
||||
"new": [
|
||||
{ "url": "http://example.com/d.html", "file": "example.com/d.html", "size": 280 }
|
||||
],
|
||||
"changed": [
|
||||
{ "url": "http://example.com/a.html", "file": "example.com/a.html", "size": 281, "previous_size": 273 }
|
||||
],
|
||||
"unchanged": [
|
||||
{ "url": "http://example.com/b.html", "file": "example.com/b.html", "size": 277 }
|
||||
],
|
||||
"gone": [
|
||||
{ "url": "", "file": "example.com/c.html" }
|
||||
]
|
||||
}
|
||||
</pre>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<ul>
|
||||
<li>A file listed under <tt>gone</tt> is only deleted when <tt>--purge-old</tt> is
|
||||
on. Left in place it drops out of the mirror's index, so it is reported once and
|
||||
not again.</li>
|
||||
<li>A resource whose local file name changed since the previous mirror (a new
|
||||
MIME type, say) is reported as <tt>new</tt> under its new name; the old name is
|
||||
reported as <tt>gone</tt> only if the file is still on disk. The two entries are
|
||||
not paired.</li>
|
||||
<li>A resource this run tried and failed to transfer also drops out of the
|
||||
mirror's index, but its previous copy is untouched, so it is reported
|
||||
<tt>unchanged</tt>. Under <tt>--purge-old</tt> that copy is deleted anyway, and
|
||||
the report says <tt>gone</tt> to match.</li>
|
||||
<li>A run that transfers no data at all is rolled back: HTTrack restores the
|
||||
previous cache generation and leaves the previous report in place, so a lost
|
||||
connection does not overwrite a good report with an empty one.</li>
|
||||
<li>Content diffs, and keeping the previous copy of a changed page, are out of
|
||||
scope: both change what a mirror directory contains.</li>
|
||||
</ul>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<!-- ==================== Start epilogue ==================== -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="76%" border="0" align="center" valign="bottom" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td id="footer"><small>© 1998-2026 Xavier Roche & other contributors - Web Design: Leto Kauler.</small></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
@@ -300,6 +300,7 @@ ones it kept so the local copy browses offline. These options tune both halves.<
|
||||
<tr><td><tt>--preserve (-%p), --disable-passwords (-%x)</tt></td><td>Leave HTML untouched (no rewriting), and strip passwords out of saved links.</td></tr>
|
||||
<tr><td><tt>--extended-parsing (-%P), --parse-java (-j)</tt></td><td>Aggressive link discovery, and how much script content is parsed for links.</td></tr>
|
||||
<tr><td><tt>--mime-html (-%M)</tt></td><td>Save the whole mirror as a single MIME-encapsulated <tt>.mht</tt> archive (<tt>index.mht</tt>).</td></tr>
|
||||
<tr><td><tt>--single-file (-%Z), --single-file-max-size N</tt></td><td>Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded as <tt>data:</tt> URIs. Assets over the cap (10 MB by default) keep their link, as do audio, video, and the links from one page to another. A sibling of <tt>-%M</tt>, not a replacement: see the recipe below for which to pick.</td></tr>
|
||||
<tr><td><tt>--index (-I), --build-top-index (-%i), --search-index (-%I)</tt></td><td>Build a per-mirror index, a top index across projects, and a searchable keyword index.</td></tr>
|
||||
</table>
|
||||
|
||||
@@ -482,6 +483,34 @@ add <tt>--warc-cdx</tt> for a sorted CDXJ index, or <tt>--wacz</tt> to bundle th
|
||||
archive, index and pages into one WACZ for replay tools such as
|
||||
replayweb.page.</small></p>
|
||||
|
||||
<h4>See what a re-crawl changed</h4>
|
||||
<p><tt>httrack https://example.com/ --update --changes --path mydir</tt><br>
|
||||
<small>Writes <tt>hts-changes.json</tt> in the project folder, listing every
|
||||
mirrored file as new, changed, unchanged or gone, plus a one-line summary in the
|
||||
log. "Changed" means the bytes really differ: a server that answers 200
|
||||
with the same content it served last time lands in <tt>unchanged</tt>. Deletions
|
||||
are reported whether or not <tt>--purge-old</tt> is deleting them. The format is
|
||||
documented in <a href="changes.html">the change report specification</a>.</small></p>
|
||||
|
||||
<h4>Pages you can hand to someone as one file</h4>
|
||||
<p><tt>httrack https://example.com/ --single-file --path mydir</tt><br>
|
||||
<small>Rewrites each saved page after the crawl so its stylesheets, scripts,
|
||||
images and fonts are embedded as <tt>data:</tt> URIs. The mirror stays a normal
|
||||
browsable tree, with links between pages relative and the assets still on disk,
|
||||
but any single <tt>.html</tt> file can now be mailed or archived on its own.
|
||||
Raise or lower the 10 MB per-asset limit with
|
||||
<tt>--single-file-max-size N</tt>; anything over it, plus audio and video, keeps
|
||||
its link. One caveat if you raise it: an inlined stylesheet becomes a
|
||||
<tt>data:</tt> URL, whose path is opaque, so an asset it referenced that stayed
|
||||
over the cap no longer resolves from inside it. Raising the cap past that asset
|
||||
embeds it too and the question goes away.<br>
|
||||
Reach for this when the file has to open for someone you cannot make assumptions
|
||||
about: it is plain HTML and needs no add-on. Reach for <tt>--mime-html</tt>
|
||||
instead when a Chromium-family browser is a given and the mirror is large: MIME
|
||||
carries text parts without the base64 tax, keeps each resource's original URL,
|
||||
and stores a shared asset once rather than re-embedding it in every page that
|
||||
uses it.</small></p>
|
||||
|
||||
<h4>HTTrack as a fetch tool</h4>
|
||||
<p><tt>httrack --get https://host/file.bin --path tmp</tt><br>
|
||||
<small><tt>--get</tt> fetches one file with cache, index, depth, cookies and robots
|
||||
@@ -490,7 +519,8 @@ all disabled.</small></p>
|
||||
<p><br>For the complete, always-current option list, see
|
||||
<a href="httrack.man.html">the manual page</a>. For the filter language, see
|
||||
<a href="filters.html">filters</a>; for the cache and updates, see
|
||||
<a href="cache.html">cache</a>.</p>
|
||||
<a href="cache.html">cache</a>; for the change report, see
|
||||
<a href="changes.html">changes</a>.</p>
|
||||
|
||||
<!-- ==================== Start epilogue ==================== -->
|
||||
</td>
|
||||
|
||||
@@ -129,6 +129,9 @@ The library can be used to write graphical GUIs for httrack, or to run mirrors f
|
||||
<li><a href="cache.html">Cache format</a></li><br>
|
||||
HTTrack stores original HTML data and references to downloaded files in a cache, located in the hts-cache directory.
|
||||
This page describes the HTTrack cache format.
|
||||
<li><a href="changes.html">Change report format</a></li><br>
|
||||
With --changes, HTTrack writes hts-changes.json describing what the crawl left new, changed, unchanged and gone
|
||||
compared to the previous mirror. This page describes that file.
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -90,9 +90,10 @@ offline browser : copy websites to a local directory</p>
|
||||
] [ <b>-NN, --structure[=N]</b> ] [ <b>-%N,
|
||||
--delayed-type-check</b> ] [ <b>-%D,
|
||||
--cached-delayed-type-check</b> ] [ <b>-%M, --mime-html</b>
|
||||
] [ <b>-LN, --long-names[=N]</b> ] [ <b>-KN,
|
||||
--keep-links[=N]</b> ] [ <b>-x, --replace-external</b> ] [
|
||||
<b>-%x, --disable-passwords</b> ] [ <b>-%q,
|
||||
] [ <b>-%Z, --single-file</b> ] [ <b>-LN,
|
||||
--long-names[=N]</b> ] [ <b>-KN, --keep-links[=N]</b> ] [
|
||||
<b>-x, --replace-external</b> ] [ <b>-%x,
|
||||
--disable-passwords</b> ] [ <b>-%q,
|
||||
--include-query-string</b> ] [ <b>-%g, --strip-query</b> ] [
|
||||
<b>-o, --generate-errors</b> ] [ <b>-X, --purge-old[=N]</b>
|
||||
] [ <b>-%p, --preserve</b> ] [ <b>-%T, --utf8-conversion</b>
|
||||
@@ -108,16 +109,17 @@ offline browser : copy websites to a local directory</p>
|
||||
--footer</b> ] [ <b>-%l, --language</b> ] [ <b>-%a,
|
||||
--accept</b> ] [ <b>-%X, --headers</b> ] [ <b>-C,
|
||||
--cache[=N]</b> ] [ <b>-k, --store-all-in-cache</b> ] [
|
||||
<b>-%r, --warc</b> ] [ <b>-%n, --do-not-recatch</b> ] [
|
||||
<b>-%v, --display</b> ] [ <b>-Q, --do-not-log</b> ] [ <b>-q,
|
||||
--quiet</b> ] [ <b>-z, --extra-log</b> ] [ <b>-Z,
|
||||
--debug-log</b> ] [ <b>-v, --verbose</b> ] [ <b>-f,
|
||||
--file-log</b> ] [ <b>-f2, --single-log</b> ] [ <b>-I,
|
||||
--index</b> ] [ <b>-%i, --build-top-index</b> ] [ <b>-%I,
|
||||
--search-index</b> ] [ <b>-pN, --priority[=N]</b> ] [ <b>-S,
|
||||
--stay-on-same-dir</b> ] [ <b>-D, --can-go-down</b> ] [
|
||||
<b>-U, --can-go-up</b> ] [ <b>-B, --can-go-up-and-down</b> ]
|
||||
[ <b>-a, --stay-on-same-address</b> ] [ <b>-d,
|
||||
<b>-%r, --warc</b> ] [ <b>-%d, --changes</b> ] [ <b>-%n,
|
||||
--do-not-recatch</b> ] [ <b>-%v, --display</b> ] [ <b>-Q,
|
||||
--do-not-log</b> ] [ <b>-q, --quiet</b> ] [ <b>-z,
|
||||
--extra-log</b> ] [ <b>-Z, --debug-log</b> ] [ <b>-v,
|
||||
--verbose</b> ] [ <b>-f, --file-log</b> ] [ <b>-f2,
|
||||
--single-log</b> ] [ <b>-I, --index</b> ] [ <b>-%i,
|
||||
--build-top-index</b> ] [ <b>-%I, --search-index</b> ] [
|
||||
<b>-pN, --priority[=N]</b> ] [ <b>-S, --stay-on-same-dir</b>
|
||||
] [ <b>-D, --can-go-down</b> ] [ <b>-U, --can-go-up</b> ] [
|
||||
<b>-B, --can-go-up-and-down</b> ] [ <b>-a,
|
||||
--stay-on-same-address</b> ] [ <b>-d,
|
||||
--stay-on-same-domain</b> ] [ <b>-l, --stay-on-same-tld</b>
|
||||
] [ <b>-e, --go-everywhere</b> ] [ <b>-%H,
|
||||
--debug-headers</b> ] [ <b>-%!,
|
||||
@@ -648,6 +650,24 @@ don’t wait) (--cached-delayed-type-check)</p></td></tr>
|
||||
<td width="4%">
|
||||
|
||||
|
||||
<p>-%Z</p></td>
|
||||
<td width="5%"></td>
|
||||
<td width="82%">
|
||||
|
||||
|
||||
<p>after the mirror, rewrite each saved page with its
|
||||
stylesheets, scripts, images and fonts inlined as data:
|
||||
URIs, so any page opens by double-click anywhere (links
|
||||
between pages stay relative; audio and video stay links);
|
||||
--single-file-max-size N caps each asset (default 10485760
|
||||
bytes). %M is the better container where a Chromium-family
|
||||
browser is a given: one archive, no base64 tax on text, a
|
||||
shared asset stored once (--single-file)</p></td></tr>
|
||||
<tr valign="top" align="left">
|
||||
<td width="9%"></td>
|
||||
<td width="4%">
|
||||
|
||||
|
||||
<p>-%t</p></td>
|
||||
<td width="5%"></td>
|
||||
<td width="82%">
|
||||
@@ -1143,6 +1163,19 @@ past N bytes, --warc-cdx also writes a sorted CDXJ index,
|
||||
<td width="4%">
|
||||
|
||||
|
||||
<p>-%d</p></td>
|
||||
<td width="5%"></td>
|
||||
<td width="82%">
|
||||
|
||||
|
||||
<p>write hts-changes.json listing what this crawl left new,
|
||||
changed, unchanged and gone compared to the previous mirror
|
||||
(--changes)</p> </td></tr>
|
||||
<tr valign="top" align="left">
|
||||
<td width="9%"></td>
|
||||
<td width="4%">
|
||||
|
||||
|
||||
<p>-%n</p></td>
|
||||
<td width="5%"></td>
|
||||
<td width="82%">
|
||||
|
||||
@@ -104,6 +104,7 @@ ${do:end-if}
|
||||
<input type="hidden" name="hidepwd" value="">
|
||||
<input type="hidden" name="hidequery" value="">
|
||||
<input type="hidden" name="nopurge" value="">
|
||||
<input type="hidden" name="singlefile" value="">
|
||||
|
||||
${LANG_I33}
|
||||
<br>
|
||||
@@ -143,6 +144,13 @@ ${listid:build:LISTDEF_3}
|
||||
<tr><td><input type="checkbox" name="nopurge" ${checked:nopurge}
|
||||
title='${html:LANG_I1a}' onMouseOver="info('${html:LANG_I1a}'); return true" onMouseOut="info(' '); return true"
|
||||
> ${LANG_I57}</td></tr>
|
||||
<tr><td><input type="checkbox" name="singlefile" ${checked:singlefile}
|
||||
title='${html:LANG_SINGLEFILETIP}' onMouseOver="info('${html:LANG_SINGLEFILETIP}'); return true" onMouseOut="info(' '); return true"
|
||||
> ${LANG_SINGLEFILE}</td></tr>
|
||||
<tr><td>${LANG_SINGLEFILEMAX}
|
||||
<input name="singlefilemax" value="${singlefilemax}" size="12"
|
||||
title='${html:LANG_SINGLEFILEMAXTIP}' onMouseOver="info('${html:LANG_SINGLEFILEMAXTIP}'); return true" onMouseOut="info(' '); return true"
|
||||
></td></tr>
|
||||
</table>
|
||||
|
||||
<tr><td>
|
||||
|
||||
@@ -100,6 +100,7 @@ ${do:end-if}
|
||||
|
||||
<!-- clear if not checked -->
|
||||
<input type="hidden" name="warc" value="">
|
||||
<input type="hidden" name="changes" value="">
|
||||
<input type="hidden" name="norecatch" value="">
|
||||
<input type="hidden" name="logf" value="">
|
||||
<input type="hidden" name="index" value="">
|
||||
@@ -121,6 +122,11 @@ ${LANG_WARCFILE}
|
||||
>
|
||||
<br><br>
|
||||
|
||||
<input type="checkbox" name="changes" ${checked:changes}
|
||||
title='${html:LANG_CHANGESTIP}' onMouseOver="info('${html:LANG_CHANGESTIP}'); return true" onMouseOut="info(' '); return true"
|
||||
> ${LANG_CHANGES}
|
||||
<br><br>
|
||||
|
||||
<input type="checkbox" name="norecatch" ${checked:norecatch}
|
||||
title='${html:LANG_I5b}' onMouseOver="info('${html:LANG_I5b}'); return true" onMouseOut="info(' '); return true"
|
||||
> ${LANG_I34b}
|
||||
|
||||
@@ -143,6 +143,9 @@ ${do:copy:StripQuery:stripquery}
|
||||
${do:copy:StoreAllInCache:cache2}
|
||||
${do:copy:Warc:warc}
|
||||
${do:copy:WarcFile:warcfile}
|
||||
${do:copy:Changes:changes}
|
||||
${do:copy:SingleFile:singlefile}
|
||||
${do:copy:SingleFileMaxSize:singlefilemax}
|
||||
${do:copy:LogType:logtype}
|
||||
${do:copy:UseHTTPProxyForFTP:ftpprox}
|
||||
${do:copy:ProxyType:proxytype}
|
||||
|
||||
@@ -190,6 +190,9 @@ ${/* -m<n> resets the html limit, so the bare form must precede the -m,<n> one *
|
||||
${test:cache2:--store-all-in-cache}
|
||||
${test:warc:--warc}
|
||||
${test:warcfile:--warc-file "}${arg:warcfile}${test:warcfile:"}
|
||||
${test:changes:--changes}
|
||||
${test:singlefile:--single-file}
|
||||
${test:singlefilemax:--single-file-max-size=}${unquoted:singlefilemax}
|
||||
${test:norecatch:--do-not-recatch}
|
||||
${test:logf:--single-log}
|
||||
${test:logtype:::--extra-log:--debug-log}
|
||||
@@ -242,6 +245,9 @@ StripQuery=${stripquery}
|
||||
StoreAllInCache=${ztest:cache2:0:1}
|
||||
Warc=${ztest:warc:0:1}
|
||||
WarcFile=${warcfile}
|
||||
Changes=${ztest:changes:0:1}
|
||||
SingleFile=${ztest:singlefile:0:1}
|
||||
SingleFileMaxSize=${singlefilemax}
|
||||
LogType=${logtype}
|
||||
UseHTTPProxyForFTP=${ztest:ftpprox:0:1}
|
||||
ProxyType=${proxytype}
|
||||
|
||||
12
lang.def
12
lang.def
@@ -1042,3 +1042,15 @@ LANG_WARCFILE
|
||||
WARC archive name:
|
||||
LANG_WARCFILETIP
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
LANG_CHANGES
|
||||
Report what changed since the previous mirror
|
||||
LANG_CHANGESTIP
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
LANG_SINGLEFILE
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
LANG_SINGLEFILETIP
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
LANG_SINGLEFILEMAX
|
||||
Largest inlined asset (bytes):
|
||||
LANG_SINGLEFILEMAXTIP
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Èìå íà WARC àðõèâà:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Íåçàäúëæèòåëíî áàçîâî èìå çà WARC àðõèâà; îñòàâåòå ïðàçíî çà àâòîìàòè÷íî èìåíóâàíå â èçõîäíàòà äèðåêòîðèÿ.
|
||||
Report what changed since the previous mirror
|
||||
Îò÷åò çà ïðîìåíèòå ñïðÿìî ïðåäèøíîòî îãëåäàëî
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Çàïèñâàíå è íà hts-changes.json ñúñ ñïèñúê íà íîâèòå, ïðîìåíåíèòå, íåïðîìåíåíèòå è èç÷åçíàëèòå ôàéëîâå ñïðÿìî ïðåäèøíîòî îãëåäàëî.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Âãðàæäàíå íà ðåñóðñèòå êàòî data: URI (ñàìîñòîÿòåëíè ñòðàíèöè)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Ñëåä çàâúðøâàíå íà îãëåäàëîòî âñÿêà çàïàçåíà ñòðàíèöà ñå ïðåçàïèñâà ñ âãðàäåíè ñòèëîâå, ñêðèïòîâå, èçîáðàæåíèÿ è øðèôòîâå, òàêà ÷å ñòðàíèöàòà äà ìîæå äà ñå îòâîðè è ñàìîñòîÿòåëíî.
|
||||
Largest inlined asset (bytes):
|
||||
Íàé-ãîëÿì âãðàäåí ðåñóðñ (áàéòîâå):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Ðåñóðñ íàä òîçè ðàçìåð çàïàçâà îáèêíîâåíà âðúçêà; îñòàâåòå ïðàçíî çà ñòîéíîñòòà ïî ïîäðàçáèðàíå îò 10485760 áàéòà.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Nombre del archivo WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nombre base opcional para el archivo WARC; déjelo en blanco para nombrarlo automáticamente en el directorio de salida.
|
||||
Report what changed since the previous mirror
|
||||
Informar de los cambios desde la copia anterior
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Escribir también hts-changes.json con la lista de lo que esta captura deja como nuevo, modificado, sin cambios o desaparecido respecto a la copia anterior.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Incrustar los recursos como URI data: (páginas autónomas)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Una vez terminada la copia, reescribir cada página guardada con sus hojas de estilo, scripts, imágenes y fuentes incrustadas, de modo que una página también pueda abrirse por sí sola.
|
||||
Largest inlined asset (bytes):
|
||||
Tamaño máximo del recurso incrustado (bytes):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Un recurso mayor que este tamaño conserva un enlace normal; déjelo vacío para el valor predeterminado de 10485760 bytes.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Název archivu WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Volitelný základní název archivu WARC; ponechte prázdné pro automatické pojmenování ve výstupním adresáøi.
|
||||
Report what changed since the previous mirror
|
||||
Hlásit, co se od pøedchozího zrcadlení zmìnilo
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapsat také hts-changes.json se seznamem toho, co je oproti pøedchozímu zrcadlení nové, zmìnìné, nezmìnìné nebo chybìjící.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Vložit zdroje jako URI data: (samostatné stránky)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Po dokonèení zrcadlení pøepsat každou uloženou stránku s vloženými styly, skripty, obrázky a písmy, aby ji bylo možné otevøít i samostatnì.
|
||||
Largest inlined asset (bytes):
|
||||
Nejvìtší vložený zdroj (bajty):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Zdroj vìtší než tato velikost si ponechá bìžný odkaz; ponechte prázdné pro výchozí hodnotu 10485760 bajtù.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC 封存檔名稱:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC 封存檔的選用基本名稱;留空則於輸出目錄中自動命名。
|
||||
Report what changed since the previous mirror
|
||||
回報自上次鏡射以來的變更
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
同時寫入 hts-changes.json,列出這次擷取相對於上次鏡射的新增、變更、未變更與消失的項目。
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
將資源內嵌為 data: URI(獨立網頁)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
鏡射完成後,重寫每個已儲存的網頁,將樣式表、指令碼、圖片與字型內嵌其中,讓網頁也能單獨開啟。
|
||||
Largest inlined asset (bytes):
|
||||
內嵌資源大小上限(位元組):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
超過此大小的資源會保留一般連結;留空則使用預設的 10485760 位元組。
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC 归档名称:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC 归档的可选基本名称;留空则在输出目录中自动命名。
|
||||
Report what changed since the previous mirror
|
||||
报告自上次镜像以来的变更
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
同时写入 hts-changes.json,列出本次抓取相对于上次镜像的新增、更改、未更改和消失的项目。
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
将资源内嵌为 data: URI(独立网页)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
镜像完成后,重写每个已保存的网页,将样式表、脚本、图片和字体内嵌其中,使网页也能单独打开。
|
||||
Largest inlined asset (bytes):
|
||||
内嵌资源大小上限(字节):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
超过此大小的资源会保留普通链接;留空则使用默认的 10485760 字节。
|
||||
|
||||
@@ -966,3 +966,15 @@ WARC archive name:
|
||||
Naziv WARC arhive:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Neobavezni osnovni naziv WARC arhive; ostavite prazno za automatsko imenovanje u izlaznom direktoriju.
|
||||
Report what changed since the previous mirror
|
||||
Prijavi ¹to se promijenilo od prethodnog zrcaljenja
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapi¹i i hts-changes.json s popisom onoga ¹to je u odnosu na prethodno zrcaljenje novo, promijenjeno, nepromijenjeno ili nestalo.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Ugradi resurse kao data: URI-je (samostalne stranice)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Nakon dovr¹etka zrcaljenja ponovno zapi¹i svaku spremljenu stranicu s ugraðenim stilskim listovima, skriptama, slikama i fontovima, tako da se stranica mo¾e otvoriti i zasebno.
|
||||
Largest inlined asset (bytes):
|
||||
Najveæi ugraðeni resurs (bajtovi):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Resurs veæi od ove velièine zadr¾ava obiènu poveznicu; ostavite prazno za zadanih 10485760 bajtova.
|
||||
|
||||
@@ -1012,3 +1012,15 @@ WARC archive name:
|
||||
Navn på WARC-arkiv:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valgfrit basisnavn til WARC-arkivet; lad feltet stå tomt for automatisk navngivning i outputmappen.
|
||||
Report what changed since the previous mirror
|
||||
Rapportér hvad der er ændret siden den forrige spejling
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Skriv også hts-changes.json med en liste over, hvad denne gennemgang efterlader som nyt, ændret, uændret eller forsvundet i forhold til den forrige spejling.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Indlejr ressourcer som data:-URI'er (selvstændige sider)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Når spejlingen er færdig, omskrives hver gemt side med dens typografiark, scripts, billeder og skrifttyper indlejret, så en side også kan åbnes alene.
|
||||
Largest inlined asset (bytes):
|
||||
Største indlejrede ressource (byte):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
En ressource over denne størrelse beholder et almindeligt link; lad feltet stå tomt for standardværdien på 10485760 byte.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Name des WARC-Archivs:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Optionaler Basisname für das WARC-Archiv; leer lassen, um es automatisch im Ausgabeverzeichnis zu benennen.
|
||||
Report what changed since the previous mirror
|
||||
Melden, was sich seit der vorherigen Spiegelung geändert hat
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zusätzlich hts-changes.json schreiben, das auflistet, was dieser Durchlauf gegenüber der vorherigen Spiegelung als neu, geändert, unverändert oder verschwunden hinterlässt.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Ressourcen als data:-URIs einbetten (eigenständige Seiten)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Nach Abschluss der Spiegelung jede gespeicherte Seite mit eingebetteten Stylesheets, Skripten, Bildern und Schriftarten neu schreiben, sodass eine Seite auch für sich allein geöffnet werden kann.
|
||||
Largest inlined asset (bytes):
|
||||
Größte eingebettete Ressource (Bytes):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Eine Ressource über dieser Größe behält einen gewöhnlichen Link; leer lassen für den Standardwert von 10485760 Bytes.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC-arhiivi nimi:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC-arhiivi valikuline põhinimi; jäta tühjaks, et see väljundkataloogis automaatselt nimetada.
|
||||
Report what changed since the previous mirror
|
||||
Teata, mis on eelmisest peegeldusest saadik muutunud
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Kirjuta ka hts-changes.json, mis loetleb, mis on võrreldes eelmise peegeldusega uus, muutunud, muutumatu või kadunud.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Manusta ressursid data: URI-dena (iseseisvad lehed)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Pärast peegelduse lõppu kirjuta iga salvestatud leht ümber, manustades selle laaditabelid, skriptid, pildid ja fondid, nii et lehte saab avada ka eraldi.
|
||||
Largest inlined asset (bytes):
|
||||
Suurim manustatud ressurss (baiti):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Sellest suurem ressurss säilitab tavalise lingi; jäta tühjaks vaikeväärtuse 10485760 baiti jaoks.
|
||||
|
||||
@@ -1012,3 +1012,15 @@ WARC archive name:
|
||||
WARC archive name:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Report what changed since the previous mirror
|
||||
Report what changed since the previous mirror
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Largest inlined asset (bytes):
|
||||
Largest inlined asset (bytes):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
|
||||
@@ -966,3 +966,15 @@ WARC archive name:
|
||||
WARC-arkiston nimi:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valinnainen WARC-arkiston perusnimi; jätä tyhjäksi, jotta se nimetään automaattisesti tulostehakemistoon.
|
||||
Report what changed since the previous mirror
|
||||
Raportoi, mikä on muuttunut edellisen peilauksen jälkeen
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Kirjoita myös hts-changes.json, joka luettelee, mikä on edelliseen peilaukseen verrattuna uutta, muuttunutta, muuttumatonta tai kadonnutta.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Upota resurssit data:-URI-osoitteina (itsenäiset sivut)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Kun peilaus on valmis, kirjoita jokainen tallennettu sivu uudelleen niin, että sen tyylitiedostot, komentosarjat, kuvat ja fontit upotetaan, jolloin sivun voi avata myös yksinään.
|
||||
Largest inlined asset (bytes):
|
||||
Suurin upotettu resurssi (tavua):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Tätä suurempi resurssi säilyttää tavallisen linkin; jätä tyhjäksi, jolloin käytetään oletusarvoa 10485760 tavua.
|
||||
|
||||
@@ -1012,3 +1012,15 @@ WARC archive name:
|
||||
Nom de l'archive WARC :
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nom de base optionnel pour l'archive WARC ; laissez vide pour le générer automatiquement dans le répertoire de sortie.
|
||||
Report what changed since the previous mirror
|
||||
Signaler ce qui a changé depuis le miroir précédent
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Écrire aussi hts-changes.json, qui liste ce que ce crawl laisse nouveau, modifié, inchangé ou disparu par rapport au miroir précédent.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Intégrer les ressources en URI data: (pages autonomes)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Une fois le miroir terminé, réécrire chaque page enregistrée avec ses feuilles de style, scripts, images et polices intégrés, afin qu'une page puisse aussi être ouverte seule.
|
||||
Largest inlined asset (bytes):
|
||||
Taille maximale d'une ressource intégrée (octets) :
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Au-delà de cette taille, la ressource reste un lien ordinaire ; laissez vide pour la valeur par défaut de 10485760 octets.
|
||||
|
||||
@@ -966,3 +966,15 @@ WARC archive name:
|
||||
Όνομα αρχείου WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Προαιρετικό βασικό όνομα για το αρχείο WARC. Αφήστε το κενό για αυτόματη ονομασία στον κατάλογο εξόδου.
|
||||
Report what changed since the previous mirror
|
||||
Αναφορά των αλλαγών από το προηγούμενο αντίγραφο
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Εγγραφή και του hts-changes.json, που παραθέτει τι είναι νέο, τι άλλαξε, τι έμεινε ίδιο και τι χάθηκε σε σχέση με το προηγούμενο αντίγραφο.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Ενσωμάτωση των πόρων ως URI data: (αυτόνομες σελίδες)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Μόλις ολοκληρωθεί το αντίγραφο, κάθε αποθηκευμένη σελίδα ξαναγράφεται με ενσωματωμένα τα φύλλα στυλ, τα σενάρια, τις εικόνες και τις γραμματοσειρές της, ώστε η σελίδα να μπορεί να ανοίξει και μόνη της.
|
||||
Largest inlined asset (bytes):
|
||||
Μέγιστος ενσωματωμένος πόρος (byte):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Πόρος μεγαλύτερος από αυτό το μέγεθος διατηρεί κανονικό σύνδεσμο. Αφήστε το κενό για την προεπιλογή των 10485760 byte.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Nome dell'archivio WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nome di base facoltativo per l'archivio WARC; lascia vuoto per assegnarlo automaticamente nella directory di output.
|
||||
Report what changed since the previous mirror
|
||||
Segnala che cosa è cambiato dalla copia precedente
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Scrive anche hts-changes.json, che elenca ciò che questa scansione lascia come nuovo, modificato, invariato o scomparso rispetto alla copia precedente.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Incorpora le risorse come URI data: (pagine autonome)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Al termine della copia, riscrive ogni pagina salvata incorporando fogli di stile, script, immagini e caratteri, in modo che una pagina possa essere aperta anche da sola.
|
||||
Largest inlined asset (bytes):
|
||||
Dimensione massima della risorsa incorporata (byte):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Una risorsa oltre questa dimensione mantiene un collegamento normale; lasciare vuoto per il valore predefinito di 10485760 byte.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC アーカイブ名:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC アーカイブの任意のベース名。空欄にすると出力ディレクトリ内で自動的に名前が付けられます。
|
||||
Report what changed since the previous mirror
|
||||
前回のミラーからの変更点を報告する
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
hts-changes.json も書き出し、前回のミラーと比べて新規、変更、変更なし、消滅となったものを一覧にします。
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
リソースを data: URI として埋め込む (単独で開けるページ)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
ミラーの完了後、保存された各ページを、スタイルシート、スクリプト、画像、フォントを埋め込んだ形で書き直します。ページ単体でも開けるようになります。
|
||||
Largest inlined asset (bytes):
|
||||
埋め込む最大サイズ (バイト):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
このサイズを超えるリソースは通常のリンクのままになります。空欄にすると既定値の 10485760 バイトになります。
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
¸ÜÕ ÝÐ WARC ÐàåØÒÐâÐ:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
¸×ÑÞàÝÞ ÞáÝÞÒÝÞ ØÜÕ ×Ð WARC ÐàåØÒÐâÐ; ÞáâÐÒÕâÕ ßàÐ×ÝÞ ×Ð ÐÒâÞÜÐâáÚÞ ØÜÕÝãÒÐúÕ ÒÞ Ø×ÛÕ×ÝØÞâ ÔØàÕÚâÞàØãÜ.
|
||||
Report what changed since the previous mirror
|
||||
¸×ÒÕáâØ èâÞ Õ ßàÞÜÕÝÕâÞ ÞÔ ßàÕâåÞÔÝÞâÞ ÞÓÛÕÔÐÛÞ
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
·ÐßØèØ Ø hts-changes.json áÞ áߨáÞÚ ÝÐ âÞÐ èâÞ Õ ÝÞÒÞ, ßàÞÜÕÝÕâÞ, ÝÕßàÞÜÕÝÕâÞ ØÛØ ØáçÕ×ÝÐâÞ ÒÞ ÞÔÝÞá ÝÐ ßàÕâåÞÔÝÞâÞ ÞÓÛÕÔÐÛÞ.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
²ÓàÐÔØ ÓØ àÕáãàáØâÕ ÚÐÚÞ data: URI (áÐÜÞáâÞøÝØ áâàÐÝØæØ)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
¿Þ ×ÐÒàèãÒÐúÕ ÝÐ ÞÓÛÕÔÐÛÞâÞ, áÕÚÞøÐ ×ÐçãÒÐÝÐ áâàÐÝØæÐ áÕ ßàÕߨèãÒÐ áÞ ÒÓàÐÔÕÝØ áâØÛáÚØ ÛØáâÞÒØ, áÚàØßâØ, áÛØÚØ Ø äÞÝâÞÒØ, ×Ð ÔÐ ÜÞÖÕ áâàÐÝØæÐâÐ ÔÐ áÕ ÞâÒÞàØ Ø áÐÜÞáâÞøÝÞ.
|
||||
Largest inlined asset (bytes):
|
||||
½ÐøÓÞÛÕÜ ÒÓàÐÔÕÝ àÕáãàá (ÑÐøâØ):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
ÀÕáãàá ßÞÓÞÛÕÜ ÞÔ ÞÒÐÐ ÓÞÛÕÜØÝÐ ×ÐÔàÖãÒÐ ÞÑØçÝÐ ÒàáÚÐ; ÞáâÐÒÕâÕ ßàÐ×ÝÞ ×Ð áâÐÝÔÐàÔÝØâÕ 10485760 ÑÐøâØ.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC archívum neve:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
A WARC archívum opcionális alapneve; hagyja üresen az automatikus elnevezéshez a kimeneti könyvtárban.
|
||||
Report what changed since the previous mirror
|
||||
Jelentés arról, mi változott az elõzõ tükrözés óta
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
A hts-changes.json fájl írása is, amely felsorolja, mi új, mi változott, mi maradt változatlan és mi tûnt el az elõzõ tükrözéshez képest.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Erõforrások beágyazása data: URI-ként (önálló oldalak)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
A tükrözés befejezése után minden mentett oldal újraírása a stíluslapok, parancsfájlok, képek és betûtípusok beágyazásával, így az oldal önmagában is megnyitható.
|
||||
Largest inlined asset (bytes):
|
||||
Legnagyobb beágyazott erõforrás (bájt):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Az ennél nagyobb erõforrás közönséges hivatkozás marad; hagyja üresen a 10485760 bájtos alapértelmezéshez.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Naam van WARC-archief:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Optionele basisnaam voor het WARC-archief; laat leeg om het automatisch een naam te geven in de uitvoermap.
|
||||
Report what changed since the previous mirror
|
||||
Rapporteren wat er sinds de vorige spiegeling is gewijzigd
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Ook hts-changes.json schrijven met een overzicht van wat deze doorloop nieuw, gewijzigd, ongewijzigd of verdwenen laat ten opzichte van de vorige spiegeling.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Bronnen insluiten als data:-URI's (op zichzelf staande pagina's)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Zodra de spiegeling klaar is, elke opgeslagen pagina herschrijven met ingesloten stijlbladen, scripts, afbeeldingen en lettertypen, zodat een pagina ook los geopend kan worden.
|
||||
Largest inlined asset (bytes):
|
||||
Grootste ingesloten bron (bytes):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Een bron boven deze grootte houdt een gewone koppeling; laat leeg voor de standaardwaarde van 10485760 bytes.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Navn på WARC-arkiv:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valgfritt basisnavn for WARC-arkivet; la feltet stå tomt for automatisk navngivning i utdatamappen.
|
||||
Report what changed since the previous mirror
|
||||
Rapporter hva som er endret siden forrige speiling
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Skriv også hts-changes.json som lister opp hva denne gjennomgangen etterlater som nytt, endret, uendret eller forsvunnet sammenlignet med forrige speiling.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Bygg inn ressurser som data:-URI-er (selvstendige sider)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Når speilingen er ferdig, skrives hver lagrede side om med stilark, skript, bilder og skrifter innebygd, slik at en side også kan åpnes alene.
|
||||
Largest inlined asset (bytes):
|
||||
Største innebygde ressurs (byte):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
En ressurs over denne størrelsen beholder en vanlig lenke; la feltet stå tomt for standardverdien på 10485760 byte.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Nazwa archiwum WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Opcjonalna nazwa bazowa archiwum WARC; pozostaw puste, aby nazwaæ je automatycznie w katalogu wyj¶ciowym.
|
||||
Report what changed since the previous mirror
|
||||
Zg³o¶, co zmieni³o siê od poprzedniej kopii
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapisz równie¿ plik hts-changes.json z list± tego, co w porównaniu z poprzedni± kopi± jest nowe, zmienione, niezmienione lub usuniête.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Osad¼ zasoby jako identyfikatory data: URI (samodzielne strony)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Po zakoñczeniu tworzenia kopii przepisz ka¿d± zapisan± stronê z osadzonymi arkuszami stylów, skryptami, obrazami i czcionkami, aby stronê mo¿na by³o otworzyæ równie¿ samodzielnie.
|
||||
Largest inlined asset (bytes):
|
||||
Najwiêkszy osadzony zasób (bajty):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Zasób wiêkszy ni¿ ten rozmiar zachowuje zwyk³y odno¶nik; pozostaw puste, aby u¿yæ domy¶lnych 10485760 bajtów.
|
||||
|
||||
@@ -1012,3 +1012,15 @@ WARC archive name:
|
||||
Nome do arquivo WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nome base opcional para o arquivo WARC; deixe em branco para nomeá-lo automaticamente no diretório de saída.
|
||||
Report what changed since the previous mirror
|
||||
Relatar o que mudou desde o espelhamento anterior
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Gravar também hts-changes.json listando o que esta captura deixa como novo, alterado, inalterado ou removido em relação ao espelhamento anterior.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Incorporar os recursos como URIs data: (páginas autônomas)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Ao terminar o espelhamento, reescrever cada página salva com suas folhas de estilo, scripts, imagens e fontes incorporadas, para que a página também possa ser aberta sozinha.
|
||||
Largest inlined asset (bytes):
|
||||
Maior recurso incorporado (bytes):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Um recurso acima desse tamanho mantém um link comum; deixe em branco para o padrão de 10485760 bytes.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Nome do arquivo WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nome base opcional para o arquivo WARC; deixe em branco para o nomear automaticamente no diretório de saída.
|
||||
Report what changed since the previous mirror
|
||||
Comunicar o que mudou desde o espelho anterior
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Escrever também hts-changes.json, que lista o que esta recolha deixa como novo, alterado, inalterado ou desaparecido em relação ao espelho anterior.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Incorporar os recursos como URI data: (páginas autónomas)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Depois de terminado o espelho, reescrever cada página guardada com as suas folhas de estilo, scripts, imagens e tipos de letra incorporados, para que a página também possa ser aberta sozinha.
|
||||
Largest inlined asset (bytes):
|
||||
Maior recurso incorporado (bytes):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Um recurso acima deste tamanho mantém uma ligação normal; deixe em branco para o valor predefinido de 10485760 bytes.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Numele arhivei WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Nume de baza optional pentru arhiva WARC; lasati gol pentru a-l denumi automat in directorul de iesire.
|
||||
Report what changed since the previous mirror
|
||||
Raporteaza ce s-a schimbat fata de copia anterioara
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Scrie si hts-changes.json, care listeaza ce este nou, modificat, nemodificat sau disparut fata de copia anterioara.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Încorporeaza resursele ca URI data: (pagini de sine statatoare)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Dupa terminarea copiei, fiecare pagina salvata este rescrisa cu foile de stil, scripturile, imaginile si fonturile încorporate, astfel încât pagina sa poata fi deschisa si singura.
|
||||
Largest inlined asset (bytes):
|
||||
Cea mai mare resursa încorporata (octeti):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
O resursa mai mare decât aceasta dimensiune pastreaza o legatura obisnuita; lasati gol pentru valoarea implicita de 10485760 de octeti.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Èìÿ WARC-àðõèâà:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Íåîáÿçàòåëüíîå áàçîâîå èìÿ WARC-àðõèâà; îñòàâüòå ïóñòûì äëÿ àâòîìàòè÷åñêîãî èìåíîâàíèÿ â âûõîäíîì êàòàëîãå.
|
||||
Report what changed since the previous mirror
|
||||
Ñîîáùàòü, ÷òî èçìåíèëîñü ñ ïðåäûäóùåãî çåðêàëà
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Òàêæå çàïèñûâàòü hts-changes.json ñî ñïèñêîì òîãî, ÷òî ïî ñðàâíåíèþ ñ ïðåäûäóùèì çåðêàëîì ñòàëî íîâûì, èçìåí¸ííûì, íåèçìåí¸ííûì èëè èñ÷åçëî.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Âñòðàèâàòü ðåñóðñû êàê data: URI (ñàìîñòîÿòåëüíûå ñòðàíèöû)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Ïîñëå çàâåðøåíèÿ çåðêàëèðîâàíèÿ êàæäàÿ ñîõðàí¸ííàÿ ñòðàíèöà ïåðåçàïèñûâàåòñÿ ñî âñòðîåííûìè òàáëèöàìè ñòèëåé, ñöåíàðèÿìè, èçîáðàæåíèÿìè è øðèôòàìè, ÷òîáû ñòðàíèöó ìîæíî áûëî îòêðûòü îòäåëüíî.
|
||||
Largest inlined asset (bytes):
|
||||
Íàèáîëüøèé âñòðàèâàåìûé ðåñóðñ (áàéòû):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Ðåñóðñ áîëüøå ýòîãî ðàçìåðà ñîõðàíÿåò îáû÷íóþ ññûëêó; îñòàâüòå ïóñòûì äëÿ çíà÷åíèÿ ïî óìîë÷àíèþ 10485760 áàéò.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Názov archívu WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Voliteµný základný názov archívu WARC; ponechajte prázdne pre automatické pomenovanie vo výstupnom adresári.
|
||||
Report what changed since the previous mirror
|
||||
Oznámi», èo sa od predchádzajúceho zrkadlenia zmenilo
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapísa» aj hts-changes.json so zoznamom toho, èo je oproti predchádzajúcemu zrkadleniu nové, zmenené, nezmenené alebo chýbajúce.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Vlo¾i» zdroje ako URI data: (samostatné stránky)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Po dokonèení zrkadlenia prepísa» ka¾dú ulo¾enú stránku s vlo¾enými ¹týlmi, skriptmi, obrázkami a písmami, aby sa stránka dala otvori» aj samostatne.
|
||||
Largest inlined asset (bytes):
|
||||
Najväè¹í vlo¾ený zdroj (bajty):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Zdroj väè¹í ne¾ táto veµkos» si ponechá be¾ný odkaz; ponechajte prázdne pre predvolených 10485760 bajtov.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
Ime arhiva WARC:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Neobvezno osnovno ime arhiva WARC; pustite prazno za samodejno poimenovanje v izhodni mapi.
|
||||
Report what changed since the previous mirror
|
||||
Porocaj, kaj se je spremenilo od prejsnjega zrcaljenja
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Zapisi tudi hts-changes.json s seznamom tega, kar je v primerjavi s prejsnjim zrcaljenjem novo, spremenjeno, nespremenjeno ali izginilo.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Vgradi vire kot data: URI (samostojne strani)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Ko je zrcaljenje koncano, se vsaka shranjena stran prepise z vgrajenimi slogovnimi listi, skripti, slikami in pisavami, tako da jo je mogoce odpreti tudi samostojno.
|
||||
Largest inlined asset (bytes):
|
||||
Najvecji vgrajeni vir (bajti):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Vir, vecji od te velikosti, ohrani obicajno povezavo; pustite prazno za privzetih 10485760 bajtov.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC-arkivets namn:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Valfritt basnamn för WARC-arkivet; lämna tomt för att namnge det automatiskt i utdatakatalogen.
|
||||
Report what changed since the previous mirror
|
||||
Rapportera vad som ändrats sedan föregående spegling
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Skriv även hts-changes.json som listar vad den här genomgången lämnar som nytt, ändrat, oförändrat eller försvunnet jämfört med föregående spegling.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Bädda in resurser som data:-URI:er (fristående sidor)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
När speglingen är klar skrivs varje sparad sida om med sina formatmallar, skript, bilder och teckensnitt inbäddade, så att en sida också kan öppnas för sig.
|
||||
Largest inlined asset (bytes):
|
||||
Största inbäddade resurs (byte):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
En resurs över den här storleken behåller en vanlig länk; lämna tomt för standardvärdet 10485760 byte.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC arþivi adý:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC arþivi için isteðe baðlý temel ad; çýktý dizininde otomatik adlandýrma için boþ býrakýn.
|
||||
Report what changed since the previous mirror
|
||||
Önceki yansýmadan bu yana deðiþenleri bildir
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Ayrýca hts-changes.json yazarak bu taramanýn önceki yansýmaya göre neyi yeni, deðiþmiþ, deðiþmemiþ veya kaybolmuþ býraktýðýný listele.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Kaynaklarý data: URI olarak göm (kendi kendine yeten sayfalar)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Yansýlama bittiðinde, kaydedilen her sayfa stil sayfalarý, betikleri, görselleri ve yazý tipleri gömülü olarak yeniden yazýlýr; böylece sayfa tek baþýna da açýlabilir.
|
||||
Largest inlined asset (bytes):
|
||||
En büyük gömülü kaynak (bayt):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Bu boyutun üzerindeki bir kaynak sýradan baðlantýsýný korur; 10485760 baytlýk varsayýlan için boþ býrakýn.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
²ì'ÿ WARC-àðõ³âó:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
Íåîáîâ'ÿçêîâà áàçîâà íàçâà WARC-àðõ³âó; çàëèøòå ïîðîæí³ì äëÿ àâòîìàòè÷íîãî íàéìåíóâàííÿ ó âèõ³äíîìó êàòàëîç³.
|
||||
Report what changed since the previous mirror
|
||||
Ïîâ³äîìëÿòè, ùî çì³íèëîñÿ ç ïîïåðåäíüîãî äçåðêàëà
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
Òàêîæ çàïèñóâàòè hts-changes.json ç³ ñïèñêîì òîãî, ùî ïîð³âíÿíî ç ïîïåðåäí³ì äçåðêàëîì º íîâèì, çì³íåíèì, íåçì³íåíèì àáî çíèêëèì.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Âáóäîâóâàòè ðåñóðñè ÿê data: URI (ñàìîñò³éí³ ñòîð³íêè)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
ϳñëÿ çàâåðøåííÿ äçåðêàëþâàííÿ êîæíà çáåðåæåíà ñòîð³íêà ïåðåçàïèñóºòüñÿ ç âáóäîâàíèìè òàáëèöÿìè ñòèë³â, ñöåíàð³ÿìè, çîáðàæåííÿìè òà øðèôòàìè, ùîá ñòîð³íêó ìîæíà áóëî â³äêðèòè îêðåìî.
|
||||
Largest inlined asset (bytes):
|
||||
Íàéá³ëüøèé âáóäîâàíèé ðåñóðñ (áàéòè):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Ðåñóðñ, á³ëüøèé çà öåé ðîçì³ð, çáåð³ãຠçâè÷àéíå ïîñèëàííÿ; çàëèøòå ïîðîæí³ì äëÿ òèïîâîãî çíà÷åííÿ 10485760 áàéò³â.
|
||||
|
||||
@@ -964,3 +964,15 @@ WARC archive name:
|
||||
WARC arxivi nomi:
|
||||
Optional base name for the WARC archive; leave blank to auto-name it under the output directory.
|
||||
WARC arxivi uchun ixtiyoriy asosiy nom; chiqish katalogida avtomatik nomlash uchun bo'sh qoldiring.
|
||||
Report what changed since the previous mirror
|
||||
Oldingi nusxadan beri nima o’zgarganini xabar qilish
|
||||
Also write hts-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror.
|
||||
hts-changes.json ham yoziladi: unda ushbu yig’ish oldingi nusxaga nisbatan nimani yangi, o’zgargan, o’zgarmagan yoki yo’qolgan holda qoldirgani ro’yxati bo’ladi.
|
||||
Inline assets as data: URIs (self-contained pages)
|
||||
Resurslarni data: URI sifatida joylash (mustaqil sahifalar)
|
||||
Once the mirror is finished, rewrite every saved page with its stylesheets, scripts, images and fonts embedded, so a page can also be opened on its own.
|
||||
Nusxalash tugagach, har bir saqlangan sahifa uslublar jadvallari, skriptlar, rasmlar va shriftlar joylangan holda qayta yoziladi, shunda sahifani alohida ham ochish mumkin.
|
||||
Largest inlined asset (bytes):
|
||||
Eng katta joylangan resurs (bayt):
|
||||
An asset above this size keeps an ordinary link; leave blank for the 10485760-byte default.
|
||||
Bu o’lchamdan katta resurs oddiy havolani saqlab qoladi; standart 10485760 bayt uchun bo’sh qoldiring.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.\"
|
||||
.\" This file is generated by man/makeman.sh; do not edit by hand.
|
||||
.\" SPDX-License-Identifier: GPL-3.0-or-later
|
||||
.TH httrack 1 "23 July 2026" "httrack website copier"
|
||||
.TH httrack 1 "26 July 2026" "httrack website copier"
|
||||
.SH NAME
|
||||
httrack \- offline browser : copy websites to a local directory
|
||||
.SH SYNOPSIS
|
||||
@@ -40,6 +40,7 @@ httrack \- offline browser : copy websites to a local directory
|
||||
[ \fB\-%N, \-\-delayed\-type\-check\fR ]
|
||||
[ \fB\-%D, \-\-cached\-delayed\-type\-check\fR ]
|
||||
[ \fB\-%M, \-\-mime\-html\fR ]
|
||||
[ \fB\-%Z, \-\-single\-file\fR ]
|
||||
[ \fB\-LN, \-\-long\-names[=N]\fR ]
|
||||
[ \fB\-KN, \-\-keep\-links[=N]\fR ]
|
||||
[ \fB\-x, \-\-replace\-external\fR ]
|
||||
@@ -75,6 +76,7 @@ httrack \- offline browser : copy websites to a local directory
|
||||
[ \fB\-C, \-\-cache[=N]\fR ]
|
||||
[ \fB\-k, \-\-store\-all\-in\-cache\fR ]
|
||||
[ \fB\-%r, \-\-warc\fR ]
|
||||
[ \fB\-%d, \-\-changes\fR ]
|
||||
[ \fB\-%n, \-\-do\-not\-recatch\fR ]
|
||||
[ \fB\-%v, \-\-display\fR ]
|
||||
[ \fB\-Q, \-\-do\-not\-log\fR ]
|
||||
@@ -198,6 +200,8 @@ delayed type check, don't make any link test but wait for files download to star
|
||||
cached delayed type check, don't wait for remote type during updates, to speedup them (%D0 wait, * %D1 don't wait) (\-\-cached\-delayed\-type\-check)
|
||||
.IP \-%M
|
||||
generate a RFC MIME\-encapsulated full\-archive (.mht) (\-\-mime\-html)
|
||||
.IP \-%Z
|
||||
after the mirror, rewrite each saved page with its stylesheets, scripts, images and fonts inlined as data: URIs, so any page opens by double\-click anywhere (links between pages stay relative; audio and video stay links); \-\-single\-file\-max\-size N caps each asset (default 10485760 bytes). %M is the better container where a Chromium\-family browser is a given: one archive, no base64 tax on text, a shared asset stored once (\-\-single\-file)
|
||||
.IP \-%t
|
||||
keep the original file extension, don't rewrite it from the MIME type (%t0 rewrite)
|
||||
.IP \-LN
|
||||
@@ -279,6 +283,8 @@ create/use a cache for updates and retries (C0 no cache,C1 cache is prioritary,*
|
||||
store all files in cache (not useful if files on disk) (\-\-store\-all\-in\-cache)
|
||||
.IP \-%r
|
||||
write an ISO\-28500 WARC/1.1 archive; \-\-warc\-file NAME sets the output name, \-\-warc\-max\-size N rotates segments past N bytes, \-\-warc\-cdx also writes a sorted CDXJ index, \-\-wacz packages it all as a WACZ file (\-\-warc)
|
||||
.IP \-%d
|
||||
write hts\-changes.json listing what this crawl left new, changed, unchanged and gone compared to the previous mirror (\-\-changes)
|
||||
.IP \-%n
|
||||
do not re\-download locally erased files (\-\-do\-not\-recatch)
|
||||
.IP \-%v
|
||||
|
||||
@@ -66,7 +66,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
htscmdline.c htshelp.c htslib.c htsurlport.c htscoremain.c \
|
||||
htsname.c htsrobots.c htstools.c htswizard.c \
|
||||
htsalias.c htsthread.c htsindex.c htsbauth.c \
|
||||
htsmd5.c htscodec.c htswarc.c htsproxy.c htszlib.c htswrap.c htsconcat.c \
|
||||
htsmd5.c htscodec.c htswarc.c htschanges.c htssinglefile.c htsproxy.c htszlib.c htswrap.c htsconcat.c \
|
||||
htsmodules.c htscharset.c punycode.c htsencoding.c htssniff.c \
|
||||
md5.c \
|
||||
minizip/ioapi.c minizip/mztools.c minizip/unzip.c minizip/zip.c \
|
||||
@@ -77,7 +77,7 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \
|
||||
htshelp.h htsindex.h htslib.h htsurlport.h htsmd5.h \
|
||||
htsmodules.h htsname.h htsnet.h htssniff.h \
|
||||
htsopt.h htsrobots.h htsthread.h \
|
||||
htstools.h htswizard.h htswrap.h htscodec.h htswarc.h htsproxy.h htszlib.h \
|
||||
htstools.h htswizard.h htswrap.h htscodec.h htswarc.h htschanges.h htssinglefile.h htsproxy.h htszlib.h \
|
||||
htsstrings.h htsarrays.h httrack-library.h \
|
||||
htscharset.h punycode.h htsencoding.h \
|
||||
htsentities.h htsentities.sh htsbasiccharsets.sh htscodepages.h \
|
||||
|
||||
@@ -114,6 +114,8 @@ const char *hts_optalias[][4] = {
|
||||
"strip [host/pattern=]key1,key2,... from URLs"},
|
||||
{"cookies-file", "-%K", "param1",
|
||||
"load extra cookies from a Netscape cookies.txt"},
|
||||
{"changes", "-%d", "single",
|
||||
"write hts-changes.json: what this crawl changed vs. the previous mirror"},
|
||||
{"warc", "-%r", "single", "write an ISO-28500 WARC/1.1 archive of the crawl"},
|
||||
{"warc-file", "-%rf", "param1", "write a WARC archive to the given base name"},
|
||||
{"warc-max-size", "-%rs", "param1",
|
||||
@@ -123,6 +125,10 @@ const char *hts_optalias[][4] = {
|
||||
{"warc-cdxj", "-%rc", "single", ""},
|
||||
{"wacz", "-%rz", "single",
|
||||
"package the WARC archive, CDXJ index and pages as a WACZ file"},
|
||||
{"single-file", "-%Z", "single",
|
||||
"after the mirror, inline each page's assets as data: URIs"},
|
||||
{"single-file-max-size", "-%Zs", "param1",
|
||||
"per-asset cap for --single-file, in bytes (implies it; default 10485760)"},
|
||||
{"why", "-%Y", "param1",
|
||||
"explain which filter rule accepts or rejects a URL, then exit"},
|
||||
{"pause", "-%G", "param1",
|
||||
|
||||
@@ -38,6 +38,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsnet.h"
|
||||
#include "htscore.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htsthread.h"
|
||||
#include <time.h>
|
||||
/* END specific definitions */
|
||||
@@ -728,6 +729,13 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback,
|
||||
if ((size = hts_codec_unpack(codec, back[p].tmpfile,
|
||||
unpacked)) >= 0) {
|
||||
back[p].r.size = back[p].r.totalsize = size;
|
||||
if (back[p].r.is_write) {
|
||||
/* Sample the previous copy now: the rename below replaces
|
||||
it, and file_notify() only fires once it is gone. */
|
||||
hts_changes_notify(
|
||||
opt, back[p].url_adr, back[p].url_fil, back[p].url_sav,
|
||||
HTS_TRUE, back[p].r.notmodified ? HTS_TRUE : HTS_FALSE);
|
||||
}
|
||||
if (!back[p].r.is_write) {
|
||||
// fichier -> mémoire ; le fichier est écrit plus tard
|
||||
deleteaddr(&back[p].r);
|
||||
|
||||
@@ -1297,12 +1297,17 @@ char *readfile2(const char *fil, LLint * size) {
|
||||
}
|
||||
|
||||
/* Note: utf-8 */
|
||||
char *readfile_utf8(const char *fil) {
|
||||
char *readfile_utf8(const char *fil) { return readfile2_utf8(fil, NULL); }
|
||||
|
||||
/* Note: utf-8 */
|
||||
char *readfile2_utf8(const char *fil, LLint *size) {
|
||||
char *adr = NULL;
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
const LLint len = fsize_utf8(fil);
|
||||
const size_t buflen = len >= 0 ? llint_to_size_t(len) : (size_t) -1;
|
||||
|
||||
if (size != NULL)
|
||||
*size = len;
|
||||
if (buflen != (size_t) -1) { // exists, and is addressable (see readfile2)
|
||||
FILE *const fp = FOPEN(fconv(catbuff, sizeof(catbuff), fil), "rb");
|
||||
|
||||
|
||||
679
src/htschanges.c
Normal file
679
src/htschanges.c
Normal file
@@ -0,0 +1,679 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 2026 Xavier Roche and other contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ethical use: we kindly ask that you NOT use this software to harvest email
|
||||
addresses or to collect any other private information about people. Doing so
|
||||
would dishonor our work and waste the many hours we have spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* File: htschanges.c subroutines: */
|
||||
/* --changes: what this crawl changed vs. the previous */
|
||||
/* mirror (hts-changes.json) */
|
||||
/* Author: Xavier Roche */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#define HTS_INTERNAL_BYTECODE
|
||||
|
||||
#include "htschanges.h"
|
||||
|
||||
#include "htscache.h"
|
||||
#include "htscharset.h"
|
||||
#include "htscore.h"
|
||||
#include "htslib.h"
|
||||
#include "htsmd5.h"
|
||||
#include "htssafe.h"
|
||||
#include "htsthread.h"
|
||||
#include "htstools.h"
|
||||
#include "coucal/coucal.h"
|
||||
#include "md5.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define DIGEST_SIZE 16
|
||||
|
||||
typedef struct hts_changes hts_changes;
|
||||
|
||||
/* One mirrored file. The mirror-relative path is the key, not the URL: a
|
||||
redirect and its target can share a save name, and counting that file twice
|
||||
would put it in two buckets. */
|
||||
typedef struct {
|
||||
char *url; /* absolute URL, "" for an engine-generated file */
|
||||
char *file; /* mirror-relative path, as listed in new.lst */
|
||||
hts_boolean rewritten; /* the crawl wrote over the local copy */
|
||||
hts_boolean not_updated; /* transfer signal: the server reported no change */
|
||||
hts_boolean existed; /* the file was part of the previous mirror */
|
||||
hts_boolean on_disk; /* a copy was on disk when the crawl first saw it */
|
||||
hts_boolean listed_prev; /* the previous mirror's index listed this file */
|
||||
hts_boolean has_prev; /* prev_digest holds the previous payload's digest */
|
||||
hts_boolean has_new; /* new_digest was taken from the payload, not disk */
|
||||
unsigned char prev_digest[DIGEST_SIZE];
|
||||
unsigned char new_digest[DIGEST_SIZE];
|
||||
LLint prev_size; /* -1 when unknown */
|
||||
LLint size; /* size after the crawl, -1 when unknown */
|
||||
hts_change_bucket bucket;
|
||||
} changes_entry;
|
||||
|
||||
struct hts_changes {
|
||||
coucal index; /* mirror-relative path -> entry slot + 1 */
|
||||
changes_entry *entries;
|
||||
size_t count;
|
||||
size_t capacity;
|
||||
hts_boolean has_index; /* the run keeps a mirror index (the cache is on) */
|
||||
hts_boolean old_index; /* the previous mirror's index was read */
|
||||
hts_boolean overflow; /* an allocation failed; the report is partial */
|
||||
hts_boolean closed; /* reported: late notifies are dropped, not recorded */
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* JSON */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/* Length of the UTF-8 sequence led by c, or 0 if c cannot lead one. */
|
||||
static size_t utf8_lead_length(unsigned char c) {
|
||||
if (c >= 0xc2 && c <= 0xdf)
|
||||
return 2;
|
||||
if (c >= 0xe0 && c <= 0xef)
|
||||
return 3;
|
||||
if (c >= 0xf0 && c <= 0xf4)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hts_changes_json_string(String *out, const char *s) {
|
||||
const unsigned char *p = (const unsigned char *) s;
|
||||
|
||||
StringAddchar(*out, '"');
|
||||
while (*p != '\0') {
|
||||
const unsigned char c = *p;
|
||||
|
||||
if (c == '"' || c == '\\') {
|
||||
StringAddchar(*out, '\\');
|
||||
StringAddchar(*out, (char) c);
|
||||
p++;
|
||||
} else if (c < 0x20 || c == 0x7f) {
|
||||
char esc[8];
|
||||
|
||||
snprintf(esc, sizeof(esc), "\\u%04x", (unsigned) c);
|
||||
StringCat(*out, esc);
|
||||
p++;
|
||||
} else if (c < 0x80) {
|
||||
StringAddchar(*out, (char) c);
|
||||
p++;
|
||||
} else {
|
||||
/* Non-ASCII: emit it verbatim only if it is a well-formed sequence, so
|
||||
a legacy-charset URL cannot produce unparseable JSON. */
|
||||
const size_t len = utf8_lead_length(c);
|
||||
|
||||
if (len != 0 && strnlen((const char *) p, len) == len &&
|
||||
hts_isStringUTF8((const char *) p, len)) {
|
||||
StringMemcat(*out, (const char *) p, len);
|
||||
p += len;
|
||||
} else {
|
||||
StringCat(*out, "\\ufffd");
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
StringAddchar(*out, '"');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Accumulator */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
static hts_changes *changes_new(void) {
|
||||
hts_changes *changes = calloct(1, sizeof(*changes));
|
||||
|
||||
if (changes == NULL)
|
||||
return NULL;
|
||||
changes->index = coucal_new(0);
|
||||
if (changes->index == NULL) {
|
||||
freet(changes);
|
||||
return NULL;
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
static void changes_free(hts_changes **pchanges) {
|
||||
hts_changes *changes = *pchanges;
|
||||
|
||||
if (changes == NULL)
|
||||
return;
|
||||
if (changes->entries != NULL) {
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < changes->count; i++) {
|
||||
freet(changes->entries[i].url);
|
||||
freet(changes->entries[i].file);
|
||||
}
|
||||
freet(changes->entries);
|
||||
}
|
||||
if (changes->index != NULL)
|
||||
coucal_delete(&changes->index);
|
||||
freet(changes);
|
||||
*pchanges = NULL;
|
||||
}
|
||||
|
||||
/* Slot of `file`, or -1 when it has not been recorded. */
|
||||
static intptr_t changes_find(const hts_changes *changes, const char *file) {
|
||||
intptr_t slot = 0;
|
||||
|
||||
return coucal_read(changes->index, file, &slot) ? slot - 1 : -1;
|
||||
}
|
||||
|
||||
/* Slot of `file`, appending a fresh entry when it is new; -1 if allocation
|
||||
failed, which flags the report partial. */
|
||||
static intptr_t changes_slot(hts_changes *changes, const char *file,
|
||||
hts_boolean *is_new) {
|
||||
intptr_t slot = 0;
|
||||
|
||||
*is_new = HTS_FALSE;
|
||||
if (coucal_read(changes->index, file, &slot))
|
||||
return slot - 1;
|
||||
|
||||
if (changes->count == changes->capacity) {
|
||||
const size_t capacity = changes->capacity != 0 ? changes->capacity * 2 : 64;
|
||||
changes_entry *const entries =
|
||||
realloct(changes->entries, capacity * sizeof(*entries));
|
||||
|
||||
if (entries == NULL) {
|
||||
changes->overflow = HTS_TRUE;
|
||||
return -1;
|
||||
}
|
||||
changes->entries = entries;
|
||||
changes->capacity = capacity;
|
||||
}
|
||||
slot = (intptr_t) changes->count;
|
||||
memset(&changes->entries[slot], 0, sizeof(changes->entries[slot]));
|
||||
changes->entries[slot].file = strdupt(file);
|
||||
changes->entries[slot].prev_size = -1;
|
||||
changes->entries[slot].size = -1;
|
||||
if (changes->entries[slot].file == NULL) {
|
||||
changes->overflow = HTS_TRUE;
|
||||
return -1;
|
||||
}
|
||||
changes->count++;
|
||||
coucal_write(changes->index, file, slot + 1);
|
||||
*is_new = HTS_TRUE;
|
||||
return slot;
|
||||
}
|
||||
|
||||
/* MD5 of the file at `path`; not a security boundary. Never call it holding
|
||||
changes_mutex: hashing a large file would stall every other connection.
|
||||
HTS_FALSE if it cannot be read. */
|
||||
static hts_boolean digest_file(const char *path,
|
||||
unsigned char digest[DIGEST_SIZE]) {
|
||||
const int endian = 1;
|
||||
struct MD5Context ctx;
|
||||
char BIGSTK buffer[32768];
|
||||
FILE *fp = FOPEN(path, "rb");
|
||||
size_t nread;
|
||||
|
||||
if (fp == NULL)
|
||||
return HTS_FALSE;
|
||||
MD5Init(&ctx, *((const char *) &endian));
|
||||
while ((nread = fread(buffer, 1, sizeof(buffer), fp)) > 0)
|
||||
MD5Update(&ctx, (const unsigned char *) buffer, (unsigned int) nread);
|
||||
if (ferror(fp) != 0) {
|
||||
fclose(fp);
|
||||
return HTS_FALSE;
|
||||
}
|
||||
fclose(fp);
|
||||
MD5Final(digest, &ctx);
|
||||
return HTS_TRUE;
|
||||
}
|
||||
|
||||
static void digest_mem(const char *buffer, size_t len,
|
||||
unsigned char digest[DIGEST_SIZE]) {
|
||||
domd5mem(buffer, len, (char *) digest, 0);
|
||||
}
|
||||
|
||||
hts_change_bucket hts_changes_classify(hts_boolean rewritten,
|
||||
hts_boolean existed,
|
||||
hts_boolean not_updated,
|
||||
hts_boolean have_digests,
|
||||
hts_boolean digests_equal) {
|
||||
if (!rewritten)
|
||||
return HTS_CHANGE_UNCHANGED; /* the crawl left the copy alone */
|
||||
if (!existed)
|
||||
return HTS_CHANGE_NEW;
|
||||
if (have_digests)
|
||||
return digests_equal ? HTS_CHANGE_UNCHANGED : HTS_CHANGE_CHANGED;
|
||||
/* No digest to compare: a server with no validators answers 200 with the
|
||||
same bytes, so this signal alone over-reports. */
|
||||
return not_updated ? HTS_CHANGE_UNCHANGED : HTS_CHANGE_CHANGED;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Engine hooks */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/* FTP transfers reach file_notify() from a thread the crawl never joins, so
|
||||
every entry point below, report and teardown included, takes this lock. */
|
||||
static htsmutex changes_mutex = HTSMUTEX_INIT;
|
||||
|
||||
/* The live accumulator, created on first use; NULL when --changes is off or
|
||||
the report is already written. Call under the lock. */
|
||||
static hts_changes *changes_get(httrackp *opt) {
|
||||
hts_changes *changes = (hts_changes *) opt->changes_state;
|
||||
|
||||
if (!opt->changes)
|
||||
return NULL;
|
||||
if (changes == NULL) {
|
||||
changes = changes_new();
|
||||
opt->changes_state = changes;
|
||||
}
|
||||
return changes != NULL && !changes->closed ? changes : NULL;
|
||||
}
|
||||
|
||||
void hts_changes_notify(httrackp *opt, const char *adr, const char *fil,
|
||||
const char *save, hts_boolean rewritten,
|
||||
hts_boolean not_updated) {
|
||||
hts_changes *changes;
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK url[HTS_URLMAXSIZE * 4 + 8]; /* holds adr + fil + a scheme */
|
||||
unsigned char prev_digest[DIGEST_SIZE];
|
||||
hts_boolean has_prev = HTS_FALSE;
|
||||
hts_boolean is_new = HTS_FALSE;
|
||||
intptr_t slot = -1;
|
||||
LLint prev_size;
|
||||
|
||||
if (!opt->changes)
|
||||
return;
|
||||
/* Engine-generated scaffolding (the top index) carries no URL and is not a
|
||||
mirrored resource. */
|
||||
if (save == NULL || !strnotempty(save) || adr == NULL || fil == NULL ||
|
||||
(!strnotempty(adr) && !strnotempty(fil)))
|
||||
return;
|
||||
|
||||
hts_savename_listed(StringBuff(opt->path_html), save, file, sizeof(file));
|
||||
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes != NULL) {
|
||||
slot = changes_slot(changes, file, &is_new);
|
||||
if (slot >= 0 && !is_new) {
|
||||
/* Retry, or a second call site for the same file: the pre-run state was
|
||||
already sampled and the copy on disk may no longer be it. */
|
||||
changes->entries[slot].rewritten =
|
||||
changes->entries[slot].rewritten || rewritten;
|
||||
}
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
if (slot < 0 || !is_new)
|
||||
return;
|
||||
|
||||
url[0] = '\0';
|
||||
if (!link_has_authority(adr))
|
||||
strlcatbuff(url, "http://", sizeof(url));
|
||||
strlcatbuff(url, adr, sizeof(url));
|
||||
strlcatbuff(url, fil, sizeof(url));
|
||||
|
||||
/* Unlocked: hashing a large file would stall every other connection. Hash
|
||||
it only when it is about to be overwritten, the last moment it exists. */
|
||||
prev_size = fsize_utf8(save);
|
||||
if (prev_size >= 0 && rewritten)
|
||||
has_prev = digest_file(save, prev_digest);
|
||||
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
/* The slot index is stable, entries being append-only; the array is not. */
|
||||
if (changes != NULL && (size_t) slot < changes->count) {
|
||||
changes_entry *const entry = &changes->entries[slot];
|
||||
|
||||
entry->url = strdupt(url);
|
||||
if (entry->url == NULL)
|
||||
changes->overflow = HTS_TRUE;
|
||||
entry->rewritten = entry->rewritten || rewritten;
|
||||
entry->not_updated = not_updated;
|
||||
entry->prev_size = prev_size;
|
||||
entry->on_disk = prev_size >= 0;
|
||||
/* hts_changes_html() compares payloads, and its digests win. */
|
||||
if (has_prev && !entry->has_new) {
|
||||
entry->has_prev = HTS_TRUE;
|
||||
memcpy(entry->prev_digest, prev_digest, DIGEST_SIZE);
|
||||
}
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_html(httrackp *opt, cache_back *cache, const htsblk *r,
|
||||
const char *adr, const char *fil, const char *save) {
|
||||
hts_changes *changes;
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK location[HTS_URLMAXSIZE * 2];
|
||||
unsigned char new_digest[DIGEST_SIZE];
|
||||
unsigned char prev_digest[DIGEST_SIZE];
|
||||
hts_boolean has_prev = HTS_FALSE;
|
||||
intptr_t slot;
|
||||
htsblk prev;
|
||||
|
||||
/* Ahead of the digest and the cache read: off must cost nothing. */
|
||||
if (!opt->changes)
|
||||
return;
|
||||
if (r->adr == NULL || r->size < 0 || save == NULL || !strnotempty(save))
|
||||
return;
|
||||
|
||||
/* On disk this is the payload plus rewritten links and a footer dated by the
|
||||
crawl, so it differs every run; compare payloads, the previous one being
|
||||
the body the cache kept. */
|
||||
digest_mem(r->adr, (size_t) r->size, new_digest);
|
||||
prev = cache_read_ro(opt, cache, adr, fil, "", location);
|
||||
if (HTTP_IS_OK(prev.statuscode) && prev.adr != NULL && prev.size >= 0) {
|
||||
digest_mem(prev.adr, (size_t) prev.size, prev_digest);
|
||||
has_prev = HTS_TRUE;
|
||||
}
|
||||
freet(prev.adr);
|
||||
|
||||
/* Only now take the lock and look the entry up: cache_read_ro() can itself
|
||||
reach file_notify(), which would move the entries array. */
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
/* file_notify() records the entry; this call only refines it. */
|
||||
if (changes != NULL) {
|
||||
hts_savename_listed(StringBuff(opt->path_html), save, file, sizeof(file));
|
||||
slot = changes_find(changes, file);
|
||||
if (slot >= 0) {
|
||||
changes_entry *const entry = &changes->entries[slot];
|
||||
|
||||
entry->has_new = HTS_TRUE;
|
||||
memcpy(entry->new_digest, new_digest, DIGEST_SIZE);
|
||||
entry->has_prev = has_prev;
|
||||
if (has_prev)
|
||||
memcpy(entry->prev_digest, prev_digest, DIGEST_SIZE);
|
||||
}
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_dropped(httrackp *opt, const char *file, hts_boolean kept) {
|
||||
hts_changes *changes;
|
||||
hts_boolean is_new;
|
||||
intptr_t slot;
|
||||
|
||||
if (!opt->changes || file == NULL || !strnotempty(file))
|
||||
return;
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes != NULL) {
|
||||
slot = changes_slot(changes, file, &is_new);
|
||||
if (slot >= 0 && is_new) {
|
||||
changes->entries[slot].url = strdupt("");
|
||||
changes->entries[slot].listed_prev = HTS_TRUE;
|
||||
/* A kept file leaves rewritten clear, which resolves to unchanged. */
|
||||
if (!kept)
|
||||
changes->entries[slot].bucket = HTS_CHANGE_GONE;
|
||||
}
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_previous(httrackp *opt, const char *file) {
|
||||
hts_changes *changes;
|
||||
intptr_t slot;
|
||||
|
||||
if (!opt->changes || file == NULL)
|
||||
return;
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes != NULL) {
|
||||
changes->has_index = HTS_TRUE;
|
||||
changes->old_index = HTS_TRUE;
|
||||
slot = changes_find(changes, file);
|
||||
if (slot >= 0)
|
||||
changes->entries[slot].listed_prev = HTS_TRUE;
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_indexed(httrackp *opt) {
|
||||
hts_changes *changes;
|
||||
|
||||
if (!opt->changes)
|
||||
return;
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = changes_get(opt);
|
||||
if (changes != NULL)
|
||||
changes->has_index = HTS_TRUE;
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Report */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
/* Assign each entry its final bucket from the bytes now on disk. */
|
||||
static void changes_resolve(hts_changes *changes, httrackp *opt) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < changes->count; i++) {
|
||||
changes_entry *const entry = &changes->entries[i];
|
||||
const char *path;
|
||||
unsigned char digest[DIGEST_SIZE];
|
||||
hts_boolean have_digests = HTS_FALSE;
|
||||
hts_boolean digests_equal = HTS_FALSE;
|
||||
|
||||
if (entry->bucket == HTS_CHANGE_GONE)
|
||||
continue;
|
||||
|
||||
/* The previous mirror's index is the authority on what was there before:
|
||||
a partial left by this crawl's own failed attempt is on disk but was
|
||||
never part of the previous mirror. Without an index, fall back to what
|
||||
the first notify saw on disk. */
|
||||
entry->existed = changes->old_index ? entry->listed_prev : entry->on_disk;
|
||||
path = fconcat(catbuff, sizeof(catbuff), StringBuff(opt->path_html),
|
||||
entry->file);
|
||||
entry->size = fsize_utf8(path);
|
||||
if (entry->rewritten && entry->existed) {
|
||||
/* The size shortcut only holds when both digests describe the file on
|
||||
disk; has_new means they are payload digests, and a parsed page's
|
||||
rendered size moves with its links and footer. */
|
||||
if (!entry->has_new && entry->size >= 0 && entry->prev_size >= 0 &&
|
||||
entry->size != entry->prev_size) {
|
||||
have_digests = HTS_TRUE; /* different lengths: no need to hash */
|
||||
digests_equal = HTS_FALSE;
|
||||
} else if (entry->has_prev &&
|
||||
(entry->has_new
|
||||
? (memcpy(digest, entry->new_digest, DIGEST_SIZE), 1)
|
||||
: digest_file(path, digest))) {
|
||||
have_digests = HTS_TRUE;
|
||||
digests_equal = memcmp(digest, entry->prev_digest, DIGEST_SIZE) == 0
|
||||
? HTS_TRUE
|
||||
: HTS_FALSE;
|
||||
}
|
||||
}
|
||||
entry->bucket =
|
||||
hts_changes_classify(entry->rewritten, entry->existed,
|
||||
entry->not_updated, have_digests, digests_equal);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *const bucket_names[HTS_CHANGE_BUCKETS] = {
|
||||
"new", "changed", "unchanged", "gone"};
|
||||
|
||||
/* Serialize the report. Call under changes_mutex. */
|
||||
static void changes_serialize(httrackp *opt, String *out) {
|
||||
hts_changes *const changes = (hts_changes *) opt->changes_state;
|
||||
size_t counts[HTS_CHANGE_BUCKETS];
|
||||
char date[32];
|
||||
char scratch[64];
|
||||
int bucket;
|
||||
size_t i;
|
||||
|
||||
StringClear(*out);
|
||||
if (changes == NULL)
|
||||
return;
|
||||
changes_resolve(changes, opt);
|
||||
|
||||
memset(counts, 0, sizeof(counts));
|
||||
for (i = 0; i < changes->count; i++)
|
||||
counts[changes->entries[i].bucket]++;
|
||||
|
||||
hts_now_iso8601(date);
|
||||
StringCat(*out, "{\n \"schema\": ");
|
||||
snprintf(scratch, sizeof(scratch), "%d", HTS_CHANGES_SCHEMA);
|
||||
StringCat(*out, scratch);
|
||||
StringCat(*out, ",\n \"generator\": ");
|
||||
hts_changes_json_string(out, "HTTrack Website Copier/" HTTRACK_VERSION);
|
||||
StringCat(*out, ",\n \"date\": ");
|
||||
hts_changes_json_string(out, date);
|
||||
StringCat(*out, ",\n \"first_crawl\": ");
|
||||
StringCat(*out, !changes->has_index
|
||||
? "null"
|
||||
: (changes->old_index ? "false" : "true"));
|
||||
StringCat(*out, ",\n \"partial\": ");
|
||||
StringCat(*out, changes->overflow ? "true" : "false");
|
||||
StringCat(*out, ",\n \"purged\": ");
|
||||
StringCat(*out, opt->delete_old ? "true" : "false");
|
||||
|
||||
StringCat(*out, ",\n \"counts\": {");
|
||||
for (bucket = 0; bucket < HTS_CHANGE_BUCKETS; bucket++) {
|
||||
StringCat(*out, bucket != 0 ? ", " : " ");
|
||||
hts_changes_json_string(out, bucket_names[bucket]);
|
||||
snprintf(scratch, sizeof(scratch), ": %d", (int) counts[bucket]);
|
||||
StringCat(*out, scratch);
|
||||
}
|
||||
StringCat(*out, " }");
|
||||
|
||||
for (bucket = 0; bucket < HTS_CHANGE_BUCKETS; bucket++) {
|
||||
hts_boolean first = HTS_TRUE;
|
||||
|
||||
StringCat(*out, ",\n ");
|
||||
hts_changes_json_string(out, bucket_names[bucket]);
|
||||
StringCat(*out, ": [");
|
||||
for (i = 0; i < changes->count; i++) {
|
||||
const changes_entry *const entry = &changes->entries[i];
|
||||
|
||||
if (entry->bucket != bucket)
|
||||
continue;
|
||||
StringCat(*out, first ? "\n { \"url\": " : ",\n { \"url\": ");
|
||||
first = HTS_FALSE;
|
||||
hts_changes_json_string(out, entry->url != NULL ? entry->url : "");
|
||||
StringCat(*out, ", \"file\": ");
|
||||
hts_changes_json_string(out, entry->file);
|
||||
if (entry->size >= 0) {
|
||||
snprintf(scratch, sizeof(scratch), ", \"size\": " LLintP,
|
||||
(LLint) entry->size);
|
||||
StringCat(*out, scratch);
|
||||
}
|
||||
if (bucket == HTS_CHANGE_CHANGED && entry->prev_size >= 0) {
|
||||
snprintf(scratch, sizeof(scratch), ", \"previous_size\": " LLintP,
|
||||
(LLint) entry->prev_size);
|
||||
StringCat(*out, scratch);
|
||||
}
|
||||
StringCat(*out, " }");
|
||||
}
|
||||
StringCat(*out, first ? "]" : "\n ]");
|
||||
}
|
||||
StringCat(*out, "\n}\n");
|
||||
}
|
||||
|
||||
void hts_changes_report(httrackp *opt, String *out) {
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes_serialize(opt, out);
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
|
||||
void hts_changes_close_opt(httrackp *opt) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
const char *path;
|
||||
String report = STRING_EMPTY;
|
||||
size_t counts[HTS_CHANGE_BUCKETS];
|
||||
size_t total;
|
||||
hts_boolean has_index, old_index;
|
||||
FILE *fp;
|
||||
|
||||
hts_mutexlock(&changes_mutex);
|
||||
{
|
||||
/* changes_get(), not the raw field: a crawl that mirrored nothing still
|
||||
owes the user a report, and a stale one from the previous run must not
|
||||
survive on disk as if it described this one. */
|
||||
hts_changes *const changes = changes_get(opt);
|
||||
size_t i;
|
||||
|
||||
if (changes == NULL) {
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
return;
|
||||
}
|
||||
changes_serialize(opt, &report);
|
||||
memset(counts, 0, sizeof(counts));
|
||||
for (i = 0; i < changes->count; i++)
|
||||
counts[changes->entries[i].bucket]++;
|
||||
total = changes->count;
|
||||
has_index = changes->has_index;
|
||||
old_index = changes->old_index;
|
||||
/* Sticky: whatever the crawl's stragglers do next is not in this report. */
|
||||
changes->closed = HTS_TRUE;
|
||||
}
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
|
||||
path = fconcat(catbuff, sizeof(catbuff), StringBuff(opt->path_log),
|
||||
HTS_CHANGES_FILE);
|
||||
fp = FOPEN(path, "wb");
|
||||
if (fp != NULL) {
|
||||
const size_t len = StringLength(report);
|
||||
|
||||
if (len != 0 && fwrite(StringBuff(report), 1, len, fp) != len)
|
||||
hts_log_print(opt, LOG_ERROR | LOG_ERRNO,
|
||||
"Unable to write the change report %s", path);
|
||||
fclose(fp);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR | LOG_ERRNO,
|
||||
"Unable to create the change report %s", path);
|
||||
}
|
||||
|
||||
if (!has_index) {
|
||||
hts_log_print(opt, LOG_NOTICE,
|
||||
"Change report: no mirror index (the cache is off), %d files "
|
||||
"mirrored, deletions not detected (%s)",
|
||||
(int) total, HTS_CHANGES_FILE);
|
||||
} else if (!old_index) {
|
||||
hts_log_print(opt, LOG_NOTICE,
|
||||
"Change report: first crawl, %d files mirrored, nothing to "
|
||||
"compare against (%s)",
|
||||
(int) total, HTS_CHANGES_FILE);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_NOTICE,
|
||||
"Change report: %d new, %d changed, %d unchanged, %d gone "
|
||||
"(%s)",
|
||||
(int) counts[HTS_CHANGE_NEW],
|
||||
(int) counts[HTS_CHANGE_CHANGED],
|
||||
(int) counts[HTS_CHANGE_UNCHANGED],
|
||||
(int) counts[HTS_CHANGE_GONE], HTS_CHANGES_FILE);
|
||||
}
|
||||
|
||||
StringFree(report);
|
||||
}
|
||||
|
||||
void hts_changes_free_opt(httrackp *opt) {
|
||||
hts_changes *changes;
|
||||
|
||||
hts_mutexlock(&changes_mutex);
|
||||
changes = (hts_changes *) opt->changes_state;
|
||||
changes_free(&changes);
|
||||
opt->changes_state = NULL;
|
||||
hts_mutexrelease(&changes_mutex);
|
||||
}
|
||||
125
src/htschanges.h
Normal file
125
src/htschanges.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 2026 Xavier Roche and other contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ethical use: we kindly ask that you NOT use this software to harvest email
|
||||
addresses or to collect any other private information about people. Doing so
|
||||
would dishonor our work and waste the many hours we have spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* HTTrack change report (--changes). Internal, not installed.
|
||||
Accumulates what the crawl did to each mirrored file, compares the bytes
|
||||
against the copy the previous run left behind, and writes
|
||||
hts-changes.json next to the log. */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#ifndef HTS_CHANGES_DEFH
|
||||
#define HTS_CHANGES_DEFH
|
||||
|
||||
#include "htsopt.h"
|
||||
#include "htsstrings.h"
|
||||
|
||||
#ifndef HTS_DEF_FWSTRUCT_cache_back
|
||||
#define HTS_DEF_FWSTRUCT_cache_back
|
||||
typedef struct cache_back cache_back;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Report file name, written under the project's log directory. */
|
||||
#define HTS_CHANGES_FILE "hts-changes.json"
|
||||
|
||||
/* Schema version carried by the report; bump on an incompatible change. */
|
||||
#define HTS_CHANGES_SCHEMA 1
|
||||
|
||||
/* Which side of the comparison a mirrored file ended up on. */
|
||||
typedef enum {
|
||||
HTS_CHANGE_NEW = 0, /* no local copy before this run */
|
||||
HTS_CHANGE_CHANGED, /* rewritten, and the bytes differ */
|
||||
HTS_CHANGE_UNCHANGED, /* the bytes are those of the previous mirror */
|
||||
HTS_CHANGE_GONE, /* in the previous mirror, absent from this one */
|
||||
HTS_CHANGE_BUCKETS
|
||||
} hts_change_bucket;
|
||||
|
||||
/* Record what this crawl is doing to the local file `save` (absolute path;
|
||||
adr/fil form its URL, either may be empty for an engine-generated file).
|
||||
`rewritten` means the copy on disk is being written over, `not_updated` is
|
||||
the 200-versus-304 signal, used only when no digest can be taken. Only the
|
||||
first call for a file samples the previous copy, so a retried or
|
||||
twice-notified resource is counted once. No-op unless --changes is on. */
|
||||
void hts_changes_notify(httrackp *opt, const char *adr, const char *fil,
|
||||
const char *save, hts_boolean rewritten,
|
||||
hts_boolean not_updated);
|
||||
|
||||
/* Refine the entry for a parsed HTML file: its local copy carries rewritten
|
||||
links and a footer dated by the crawl, so it differs every run. Compares the
|
||||
payload `r` holds against the body the previous run left in the cache. */
|
||||
void hts_changes_html(httrackp *opt, cache_back *cache, const htsblk *r,
|
||||
const char *adr, const char *fil, const char *save);
|
||||
|
||||
/* Record `file` (mirror-relative, as listed in new.lst) as listed by the
|
||||
previous mirror's index and absent from this run's. `kept` means its local
|
||||
copy survives the run because the crawl tried and failed to replace it: a
|
||||
failed transfer is not a deletion, so it is reported unchanged, not gone. */
|
||||
void hts_changes_dropped(httrackp *opt, const char *file, hts_boolean kept);
|
||||
|
||||
/* Record that the previous mirror's index listed `file`. That index, not the
|
||||
file's presence on disk, decides what counts as already mirrored. */
|
||||
void hts_changes_previous(httrackp *opt, const char *file);
|
||||
|
||||
/* Record that this run keeps a mirror index. Without one (the cache is off)
|
||||
deletions and first_crawl are undecidable, and the report says so. */
|
||||
void hts_changes_indexed(httrackp *opt);
|
||||
|
||||
/* Resolve every entry against the bytes now on disk and serialize the report
|
||||
into `out` (replaced). Exposed for the self-tests. */
|
||||
void hts_changes_report(httrackp *opt, String *out);
|
||||
|
||||
/* Write the report and log a one-line summary. Idempotent, and seals the
|
||||
accumulator: a late notify is dropped rather than starting a second one. */
|
||||
void hts_changes_close_opt(httrackp *opt);
|
||||
|
||||
/* Drop the accumulator, for a run that never reached its end and to start the
|
||||
next one clean. Null-safe and idempotent. */
|
||||
void hts_changes_free_opt(httrackp *opt);
|
||||
|
||||
/* Bucket for one entry, from what was observed. No filesystem access:
|
||||
`have_digests` says both sides could be hashed, `digests_equal` compares
|
||||
them, and `not_updated` is the fallback signal when they could not. */
|
||||
hts_change_bucket hts_changes_classify(hts_boolean rewritten,
|
||||
hts_boolean existed,
|
||||
hts_boolean not_updated,
|
||||
hts_boolean have_digests,
|
||||
hts_boolean digests_equal);
|
||||
|
||||
/* Append `s` to `out` as a quoted JSON string. Byte sequences that are not
|
||||
valid UTF-8 become U+FFFD, so a mirror carrying legacy-charset URLs still
|
||||
produces parseable JSON. */
|
||||
void hts_changes_json_string(String *out, const char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,8 @@ Please visit our Website: http://www.httrack.com
|
||||
/* File defs */
|
||||
#include "htscore.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htssinglefile.h"
|
||||
|
||||
/* specific definitions */
|
||||
#include "htsbase.h"
|
||||
@@ -488,6 +490,7 @@ void hts_finish_html_file(httrackp *opt, cache_back *cache, htsblk *r,
|
||||
const char *adr, const char *fil, const char *save) {
|
||||
{
|
||||
file_notify(opt, adr, fil, save, 1, 1, r->notmodified);
|
||||
hts_changes_html(opt, cache, r, adr, fil, save);
|
||||
*fp = filecreate(&opt->state.strc, save);
|
||||
if (*fp) {
|
||||
if (ht_len > 0 && fwrite(ht_buff, 1, ht_len, *fp) != ht_len) {
|
||||
@@ -691,6 +694,9 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
// hash table
|
||||
opt->hash = &hash;
|
||||
|
||||
// a change report left by a previous crawl on this opt is not this one's
|
||||
hts_changes_free_opt(opt);
|
||||
|
||||
// initialize link heap
|
||||
hts_record_init(opt);
|
||||
|
||||
@@ -2089,9 +2095,12 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
if (cache.lst) {
|
||||
fclose(cache.lst);
|
||||
cache.lst = opt->state.strc.lst = NULL;
|
||||
if (opt->delete_old) {
|
||||
/* old.lst minus new.lst is the set of files the previous mirror had and
|
||||
this one does not. --changes reports it; only --purge-old acts on it. */
|
||||
if (opt->delete_old || opt->changes) {
|
||||
FILE *old_lst, *new_lst;
|
||||
|
||||
hts_changes_indexed(opt);
|
||||
//
|
||||
opt->state._hts_in_html_parsing = 3;
|
||||
//
|
||||
@@ -2117,21 +2126,37 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
int purge = 0;
|
||||
|
||||
while(!feof(old_lst)) {
|
||||
linput(old_lst, line, 1000);
|
||||
if (!strstr(adr, line)) { // not found in the new list?
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK file[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strcpybuff(file, StringBuff(opt->path_html));
|
||||
strcatbuff(file, line + 1);
|
||||
file[strlen(file) - 1] = '\0';
|
||||
if (fexist_utf8(file)) { // toujours sur disque: virer
|
||||
hts_log_print(opt, LOG_INFO, "Purging %s", file);
|
||||
UNLINK(file);
|
||||
purge = 1;
|
||||
linput(old_lst, line, 1000);
|
||||
if (!strnotempty(line))
|
||||
continue;
|
||||
strcpybuff(file, StringBuff(opt->path_html));
|
||||
strcatbuff(file, line + 1);
|
||||
file[strlen(file) - 1] = '\0';
|
||||
hts_changes_previous(opt, file + StringLength(opt->path_html));
|
||||
if (!strstr(adr, line)) { // not found in the new list?
|
||||
if (fexist_utf8(file)) { // still on disk
|
||||
/* A link this crawl did try but never wrote (a transfer
|
||||
killed mid-flight) also drops out of new.lst. Unless it
|
||||
is about to be purged, its previous copy stands and the
|
||||
file is not gone. */
|
||||
const hts_boolean kept =
|
||||
!opt->delete_old &&
|
||||
hash_read(opt->hash, file, NULL,
|
||||
HASH_STRUCT_FILENAME) >= 0;
|
||||
|
||||
hts_changes_dropped(
|
||||
opt, file + StringLength(opt->path_html), kept);
|
||||
if (opt->delete_old) {
|
||||
hts_log_print(opt, LOG_INFO, "Purging %s", file);
|
||||
UNLINK(file);
|
||||
purge = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
if (opt->delete_old) { // emptied directories go with the files
|
||||
fseek(old_lst, 0, SEEK_SET);
|
||||
while(!feof(old_lst)) {
|
||||
linput(old_lst, line, 1000);
|
||||
@@ -2166,7 +2191,7 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
}
|
||||
}
|
||||
//
|
||||
if (!purge) {
|
||||
if (opt->delete_old && !purge) {
|
||||
hts_log_print(opt, LOG_INFO, "No files purged");
|
||||
}
|
||||
}
|
||||
@@ -2182,6 +2207,10 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
}
|
||||
// fin purge!
|
||||
|
||||
/* --single-file: inline each page's assets now the tree is final, after the
|
||||
purge has deleted whatever this run dropped. */
|
||||
singlefile_process_mirror(opt);
|
||||
|
||||
// Indexation
|
||||
if (opt->kindex)
|
||||
index_finish(StringBuff(opt->path_html), opt->kindex);
|
||||
@@ -2256,6 +2285,7 @@ int httpmirror(char *url1, httrackp * opt) {
|
||||
// ending
|
||||
usercommand(opt, 0, NULL, NULL, NULL, NULL);
|
||||
warc_close_opt(opt);
|
||||
hts_changes_close_opt(opt);
|
||||
|
||||
// désallocation mémoire & buffers
|
||||
XH_uninit;
|
||||
@@ -2881,6 +2911,17 @@ int filecreateempty(filenote_strc * strc, const char *filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hts_savename_listed(const char *root, const char *s, char *dest,
|
||||
size_t destsize) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
strlcpybuff(dest, fslash(catbuff, sizeof(catbuff), s), destsize);
|
||||
if (strnotempty(root) && strncmp(fslash(catbuff, sizeof(catbuff), root), dest,
|
||||
strlen(root)) == 0) {
|
||||
strlcpybuff(dest, s + strlen(root), destsize);
|
||||
}
|
||||
}
|
||||
|
||||
// noter fichier
|
||||
int filenote(filenote_strc * strc, const char *s, filecreate_params * params) {
|
||||
// gestion du fichier liste liste
|
||||
@@ -2890,15 +2931,8 @@ int filenote(filenote_strc * strc, const char *s, filecreate_params * params) {
|
||||
return 0;
|
||||
} else if (strc->lst) {
|
||||
char BIGSTK savelst[HTS_URLMAXSIZE * 2];
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
strcpybuff(savelst, fslash(catbuff, sizeof(catbuff), s));
|
||||
// couper chemin?
|
||||
if (strnotempty(strc->path)) {
|
||||
if (strncmp(fslash(catbuff, sizeof(catbuff), strc->path), savelst, strlen(strc->path)) == 0) { // couper
|
||||
strcpybuff(savelst, s + strlen(strc->path));
|
||||
}
|
||||
}
|
||||
hts_savename_listed(strc->path, s, savelst, sizeof(savelst));
|
||||
fprintf(strc->lst, "[%s]" LF, savelst);
|
||||
fflush(strc->lst);
|
||||
}
|
||||
@@ -2908,6 +2942,9 @@ int filenote(filenote_strc * strc, const char *s, filecreate_params * params) {
|
||||
/* Note: utf-8 */
|
||||
void file_notify(httrackp * opt, const char *adr, const char *fil,
|
||||
const char *save, int create, int modify, int not_updated) {
|
||||
hts_changes_notify(opt, adr, fil, save,
|
||||
(create || modify) ? HTS_TRUE : HTS_FALSE,
|
||||
not_updated ? HTS_TRUE : HTS_FALSE);
|
||||
RUN_CALLBACK6(opt, filesave2, adr, fil, save, create, modify, not_updated);
|
||||
}
|
||||
|
||||
@@ -3642,6 +3679,11 @@ HTSEXT_API int copy_htsopt(const httrackp * from, httrackp * to) {
|
||||
to->warc_max_size = from->warc_max_size;
|
||||
to->warc_cdx = from->warc_cdx;
|
||||
to->warc_wacz = from->warc_wacz;
|
||||
to->changes = from->changes;
|
||||
|
||||
to->single_file = from->single_file;
|
||||
if (from->single_file_max_size > 0)
|
||||
to->single_file_max_size = from->single_file_max_size;
|
||||
|
||||
if (from->pause_max_ms > 0) {
|
||||
to->pause_min_ms = from->pause_min_ms;
|
||||
|
||||
@@ -354,6 +354,12 @@ int filecreateempty(filenote_strc * strct, const char *filename);
|
||||
|
||||
int filenote(filenote_strc * strct, const char *s, filecreate_params * params);
|
||||
|
||||
/* Copy into dest (destsize bytes) the form under which the local path s is
|
||||
listed in new.lst: forward slashes, with the mirror `root` stripped when s
|
||||
sits under it. Also the change report's key, so the two must not drift. */
|
||||
void hts_savename_listed(const char *root, const char *s, char *dest,
|
||||
size_t destsize);
|
||||
|
||||
void file_notify(httrackp * opt, const char *adr, const char *fil,
|
||||
const char *save, int create, int modify, int wasupdated);
|
||||
|
||||
@@ -409,6 +415,8 @@ char *readfile2(const char *fil, LLint * size);
|
||||
|
||||
char *readfile_utf8(const char *fil);
|
||||
|
||||
char *readfile2_utf8(const char *fil, LLint *size);
|
||||
|
||||
char *readfile_or(const char *fil, const char *defaultdata);
|
||||
|
||||
/* Backing (download-slot) scheduler. Operate on the back[] ring (struct_back).
|
||||
|
||||
@@ -41,6 +41,7 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsdefines.h"
|
||||
#include "htsalias.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htsbauth.h"
|
||||
#include "htswrap.h"
|
||||
#include "htsmodules.h"
|
||||
@@ -1747,6 +1748,13 @@ static int hts_main_internal(int argc, char **argv, httrackp * opt) {
|
||||
StringCopy(opt->cookies_file, argv[na]);
|
||||
}
|
||||
break;
|
||||
case 'd': // --changes: report what this crawl changed
|
||||
opt->changes = HTS_TRUE;
|
||||
if (*(com + 1) == '0') {
|
||||
opt->changes = HTS_FALSE;
|
||||
com++;
|
||||
}
|
||||
break;
|
||||
case 'r': // warc / warc-file: write an ISO-28500 WARC archive
|
||||
if (*(com + 1) == 'f') { // --warc-file NAME: explicit basename
|
||||
com++;
|
||||
@@ -1795,6 +1803,36 @@ static int hts_main_internal(int argc, char **argv, httrackp * opt) {
|
||||
StringCopy(opt->warc_file, WARC_AUTONAME);
|
||||
}
|
||||
break;
|
||||
case 'Z': // single-file: inline each page's assets as data: URIs
|
||||
if (*(com + 1) == 's') { // --single-file-max-size N
|
||||
com++;
|
||||
if ((na + 1 >= argc) || (argv[na + 1][0] == '-')) {
|
||||
HTS_PANIC_PRINTF(
|
||||
"Option single-file-max-size needs a blank "
|
||||
"space and a size");
|
||||
htsmain_free();
|
||||
return -1;
|
||||
}
|
||||
na++;
|
||||
{ // reject non-numeric/negative/overflow; keep the default
|
||||
char *end;
|
||||
LLint v;
|
||||
|
||||
errno = 0;
|
||||
v = strtoll(argv[na], &end, 10);
|
||||
if (isdigit((unsigned char) argv[na][0]) && *end == '\0' &&
|
||||
errno != ERANGE && v > 0)
|
||||
opt->single_file_max_size = v;
|
||||
}
|
||||
opt->single_file = HTS_TRUE;
|
||||
} else {
|
||||
opt->single_file = HTS_TRUE;
|
||||
if (*(com + 1) == '0') {
|
||||
opt->single_file = HTS_FALSE;
|
||||
com++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Y': // why: explain the filter verdict for a URL, no crawl
|
||||
if ((na + 1 >= argc) || (argv[na + 1][0] == '-')) {
|
||||
HTS_PANIC_PRINTF("Option why needs a blank space and a URL");
|
||||
|
||||
@@ -535,6 +535,13 @@ void help(const char *app, int more) {
|
||||
infomsg
|
||||
(" %D cached delayed type check, don't wait for remote type during updates, to speedup them (%D0 wait, * %D1 don't wait)");
|
||||
infomsg(" %M generate a RFC MIME-encapsulated full-archive (.mht)");
|
||||
infomsg(" %Z after the mirror, rewrite each saved page with its "
|
||||
"stylesheets, scripts, images and fonts inlined as data: URIs, so "
|
||||
"any page opens by double-click anywhere (links between pages stay "
|
||||
"relative; audio and video stay links); --single-file-max-size N "
|
||||
"caps each asset (default 10485760 bytes). %M is the better "
|
||||
"container where a Chromium-family browser is a given: one archive, "
|
||||
"no base64 tax on text, a shared asset stored once");
|
||||
infomsg(" %t keep the original file extension, don't rewrite it from the "
|
||||
"MIME type (%t0 rewrite)");
|
||||
infomsg
|
||||
@@ -608,6 +615,8 @@ void help(const char *app, int more) {
|
||||
"output name, --warc-max-size N rotates segments past N bytes, "
|
||||
"--warc-cdx also writes a sorted CDXJ index, --wacz packages it all "
|
||||
"as a WACZ file");
|
||||
infomsg(" %d write hts-changes.json listing what this crawl left new, "
|
||||
"changed, unchanged and gone compared to the previous mirror");
|
||||
infomsg(" %n do not re-download locally erased files");
|
||||
infomsg
|
||||
(" %v display on screen filenames downloaded (in realtime) - * %v1 short version - %v2 full animation");
|
||||
|
||||
26
src/htslib.c
26
src/htslib.c
@@ -37,6 +37,8 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#include "htscore.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htssinglefile.h"
|
||||
|
||||
/* specific definitions */
|
||||
#include "htsbase.h"
|
||||
@@ -2698,6 +2700,24 @@ void time_gmt_rfc822(char *s) {
|
||||
time_rfc822(s, A);
|
||||
}
|
||||
|
||||
void hts_now_iso8601(char out[32]) {
|
||||
time_t t = time(NULL);
|
||||
struct tm tmv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
struct tm *g = gmtime(&t);
|
||||
|
||||
if (g != NULL)
|
||||
tmv = *g;
|
||||
else
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#else
|
||||
if (gmtime_r(&t, &tmv) == NULL)
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#endif
|
||||
strftime(out, 32, "%Y-%m-%dT%H:%M:%SZ", &tmv);
|
||||
}
|
||||
|
||||
// heure actuelle, format rfc (taille buffer 256o)
|
||||
void time_local_rfc822(char *s) {
|
||||
time_t tt;
|
||||
@@ -6011,6 +6031,10 @@ HTSEXT_API httrackp *hts_create_opt(void) {
|
||||
StringCopy(opt->cookies_file, "");
|
||||
StringCopy(opt->warc_file, "");
|
||||
opt->warc_max_size = 0; /* no rotation unless --warc-max-size sets it */
|
||||
opt->changes = HTS_FALSE;
|
||||
opt->changes_state = NULL;
|
||||
opt->single_file = HTS_FALSE;
|
||||
opt->single_file_max_size = SINGLEFILE_DEFAULT_MAX_SIZE;
|
||||
StringCopy(opt->why_url, "");
|
||||
opt->pause_min_ms = 0;
|
||||
opt->pause_max_ms = 0;
|
||||
@@ -6164,6 +6188,8 @@ HTSEXT_API void hts_free_opt(httrackp * opt) {
|
||||
StringFree(opt->why_url);
|
||||
StringFree(opt->warc_file);
|
||||
|
||||
hts_changes_free_opt(opt);
|
||||
|
||||
StringFree(opt->path_html);
|
||||
StringFree(opt->path_html_utf8);
|
||||
StringFree(opt->path_log);
|
||||
|
||||
@@ -258,6 +258,10 @@ void sec2str(char *s, TStamp t);
|
||||
|
||||
void time_gmt_rfc822(char *s);
|
||||
void time_local_rfc822(char *s);
|
||||
|
||||
/* Current UTC time as "YYYY-MM-DDThh:mm:ssZ". */
|
||||
void hts_now_iso8601(char out[32]);
|
||||
|
||||
struct tm *convert_time_rfc822(struct tm *buffer, const char *s);
|
||||
int set_filetime(const char *file, struct tm *tm_time);
|
||||
int set_filetime_rfc822(const char *file, const char *date);
|
||||
|
||||
10
src/htsopt.h
10
src/htsopt.h
@@ -547,6 +547,16 @@ struct httrackp {
|
||||
archive. Tail: ABI */
|
||||
hts_boolean warc_wacz; /**< --wacz: package archive+index+pages as a WACZ zip
|
||||
(implies --warc + --warc-cdx). Tail: ABI */
|
||||
hts_boolean changes; /**< --changes: report what this crawl changed against
|
||||
the previous mirror. Tail: ABI */
|
||||
void *changes_state; /**< live change-report accumulator (hts_changes*),
|
||||
engine-owned. Tail: ABI */
|
||||
hts_boolean single_file; /**< --single-file: once the mirror is done, rewrite
|
||||
each saved page with its assets inlined as
|
||||
data: URIs. Tail: ABI */
|
||||
LLint single_file_max_size; /**< --single-file-max-size: per-asset cap in
|
||||
bytes; a bigger asset stays a link.
|
||||
Tail: ABI */
|
||||
};
|
||||
|
||||
/* Running statistics for a mirror. */
|
||||
|
||||
@@ -60,6 +60,8 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htscodec.h"
|
||||
#include "htsproxy.h"
|
||||
#include "htswarc.h"
|
||||
#include "htschanges.h"
|
||||
#include "htssinglefile.h"
|
||||
#if HTS_USEZLIB
|
||||
#include "htszlib.h"
|
||||
#endif
|
||||
@@ -1740,6 +1742,26 @@ static int st_copyopt(httrackp *opt, int argc, char **argv) {
|
||||
if (strcmp(StringBuff(to->warc_file), "run.warc.gz") != 0)
|
||||
err = 1;
|
||||
|
||||
from->changes = HTS_TRUE;
|
||||
to->changes = HTS_FALSE;
|
||||
copy_htsopt(from, to);
|
||||
if (to->changes != HTS_TRUE)
|
||||
err = 1;
|
||||
|
||||
/* single_file pair: the cap is guarded by >0, so an unset source must not
|
||||
overwrite the default the target already carries */
|
||||
from->single_file = HTS_TRUE;
|
||||
from->single_file_max_size = 4096;
|
||||
to->single_file = HTS_FALSE;
|
||||
to->single_file_max_size = SINGLEFILE_DEFAULT_MAX_SIZE;
|
||||
copy_htsopt(from, to);
|
||||
if (!to->single_file || to->single_file_max_size != 4096)
|
||||
err = 1;
|
||||
from->single_file_max_size = 0;
|
||||
copy_htsopt(from, to);
|
||||
if (to->single_file_max_size != 4096)
|
||||
err = 1;
|
||||
|
||||
/* #185 pause pair: copied when enabled (max>0), the 0 sentinel skips */
|
||||
from->pause_min_ms = 5000;
|
||||
from->pause_max_ms = 10000;
|
||||
@@ -4875,6 +4897,520 @@ static int st_warc_wacz(httrackp *opt, int argc, char **argv) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* --single-file */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
static int sf_err = 0;
|
||||
|
||||
/* Set when the filesystem accepted a ':' in a name; Windows never does. */
|
||||
static hts_boolean sf_colon_ok = HTS_FALSE;
|
||||
|
||||
static void sf_check(int ok, const char *what) {
|
||||
if (!ok) {
|
||||
fprintf(stderr, "singlefile: %s\n", what);
|
||||
sf_err++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write rel (a '/'-separated path under dir), creating the directories.
|
||||
Returns HTS_FALSE if the name is one the filesystem will not take. */
|
||||
static hts_boolean sf_try_put(const char *dir, const char *rel,
|
||||
const void *data, size_t len) {
|
||||
char BIGSTK path[HTS_URLMAXSIZE * 2];
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
FILE *fp;
|
||||
|
||||
fconcat(path, sizeof(path), dir, rel);
|
||||
structcheck_utf8(path);
|
||||
fp = FOPEN(fconv(catbuff, sizeof(catbuff), path), "wb");
|
||||
if (fp == NULL)
|
||||
return HTS_FALSE;
|
||||
assertf(len == 0 || fwrite(data, 1, len, fp) == len);
|
||||
fclose(fp);
|
||||
return HTS_TRUE;
|
||||
}
|
||||
|
||||
static void sf_put(const char *dir, const char *rel, const void *data,
|
||||
size_t len) {
|
||||
assertf(sf_try_put(dir, rel, data, len));
|
||||
}
|
||||
|
||||
/* Number of times needle occurs in hay. */
|
||||
static int sf_count(const char *hay, const char *needle) {
|
||||
const size_t l = strlen(needle);
|
||||
int n = 0;
|
||||
const char *p = hay;
|
||||
|
||||
while ((p = strstr(p, needle)) != NULL) {
|
||||
n++;
|
||||
p += l;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* The base64 payload following the first occurrence of prefix, up to the first
|
||||
byte outside the base64 alphabet. NULL if prefix is absent. */
|
||||
static const char *sf_payload(const char *hay, const char *prefix,
|
||||
size_t *len) {
|
||||
const char *p = strstr(hay, prefix);
|
||||
size_t n = 0;
|
||||
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
p += strlen(prefix);
|
||||
while (p[n] != '\0' && (isalnum((unsigned char) p[n]) || p[n] == '+' ||
|
||||
p[n] == '/' || p[n] == '='))
|
||||
n++;
|
||||
*len = n;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Independent base64 decoder: the round-trip check must not lean on code64().
|
||||
*/
|
||||
static unsigned char *sf_unb64(const char *s, size_t len, size_t *outlen) {
|
||||
static const char alpha[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
unsigned char *out = (unsigned char *) malloct(len / 4 * 3 + 4);
|
||||
unsigned int acc = 0;
|
||||
size_t i, n = 0;
|
||||
int bits = 0;
|
||||
|
||||
if (out == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < len; i++) {
|
||||
const char *const p = s[i] != '\0' ? strchr(alpha, s[i]) : NULL;
|
||||
|
||||
if (s[i] == '=')
|
||||
break;
|
||||
if (p == NULL) {
|
||||
freet(out);
|
||||
return NULL;
|
||||
}
|
||||
acc = (acc << 6) | (unsigned int) (p - alpha);
|
||||
bits += 6;
|
||||
if (bits >= 8) {
|
||||
bits -= 8;
|
||||
out[n++] = (unsigned char) ((acc >> bits) & 0xff);
|
||||
}
|
||||
}
|
||||
*outlen = n;
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Decoded payload of the first data: URI with that MIME, as a NUL-terminated
|
||||
buffer the caller freet()s. NULL when absent or undecodable. */
|
||||
static char *sf_decode(const char *hay, const char *mime, size_t *outlen) {
|
||||
char prefix[128];
|
||||
size_t len = 0, dlen = 0;
|
||||
const char *b64;
|
||||
unsigned char *raw;
|
||||
|
||||
snprintf(prefix, sizeof(prefix), "data:%s;base64,", mime);
|
||||
b64 = sf_payload(hay, prefix, &len);
|
||||
if (b64 == NULL)
|
||||
return NULL;
|
||||
raw = sf_unb64(b64, len, &dlen);
|
||||
if (raw == NULL)
|
||||
return NULL;
|
||||
raw[dlen] = '\0';
|
||||
if (outlen != NULL)
|
||||
*outlen = dlen;
|
||||
return (char *) raw;
|
||||
}
|
||||
|
||||
/* How many data: URIs of that MIME nest inside each other, starting at hay. */
|
||||
static int sf_nesting(const char *hay, const char *mime) {
|
||||
char *cur = strdupt(hay);
|
||||
int n = 0;
|
||||
|
||||
while (cur != NULL) {
|
||||
char *const inner = sf_decode(cur, mime, NULL);
|
||||
|
||||
freet(cur);
|
||||
cur = inner;
|
||||
if (inner != NULL)
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Above the tag parser's attribute limit, so the fixture crosses it. */
|
||||
#define SF_ST_MAX_ATTRS 64
|
||||
|
||||
/* The 12-byte asset: high bytes and an embedded NUL, so a text-shaped copy
|
||||
would be caught. */
|
||||
static const char sf_png[] = "\x89PNG\r\n\x1a\n\x00\x01\x02\xff";
|
||||
#define SF_PNG_LEN 12
|
||||
|
||||
static const char sf_page[] =
|
||||
"<html><head>\n"
|
||||
"<link rel=\"stylesheet\" href=\"css/main.css\">\n"
|
||||
"<link rel=\"canonical\" href=\"other.html\">\n"
|
||||
"<title>t</title>\n"
|
||||
"<style>body { background: url(\"img/a%20b.png\"); }</style>\n"
|
||||
"</head><body>\n"
|
||||
"<img src=\"img/a%20b.png\" srcset=\"img/a%20b.png 1x, img/big.png 2x\">\n"
|
||||
"<link rel=\"icon\" href=\"icon.png\">\n"
|
||||
"<link rel=\"preload\" as=\"font\" href=\"font/f.woff2\">\n"
|
||||
"<img src=\"data:image/gif;base64,QUJD\">\n"
|
||||
/* Each has a real file where its guard's removal would land it; without
|
||||
that they stay links either way, the target merely being absent. */
|
||||
"<img src=\"http://example.com/x.png\">\n"
|
||||
"<img src=\"//example.com/x.png\">\n"
|
||||
"<input type=\"image\" src=\"img/in.png\">\n"
|
||||
/* Lazy loading: src is the placeholder, the real image rides data-src. */
|
||||
"<img src=\"img/ph.png\" data-src=\"img/lz.png\" "
|
||||
"data-srcset=\"img/lz2.png 2x\" lowsrc=\"img/low.png\">\n"
|
||||
"<object data=\"img/ob.png\"></object>\n"
|
||||
"<embed src=\"img/em.png\">\n"
|
||||
"<img data-src=\"other.html\">\n"
|
||||
/* What a first pass emits: re-resolving it is what a second pass must not
|
||||
do, and the fallback type would inline whatever the walk found. */
|
||||
"<link rel=\"stylesheet\" href=\"data:text/css;base64,QUJD\">\n"
|
||||
"<video poster=\"img/po.png\" controls>"
|
||||
"<source src=\"v.mp4\" type=\"video/mp4\"></video>\n"
|
||||
"<svg><image href=\"img/sv.png\"/></svg>\n"
|
||||
"<table background=\"img/bg.png\"><tr><td>x</td></tr></table>\n"
|
||||
/* The second is what bites: drop the clamp and its leading ".." lands it
|
||||
back on <root>/img/a b.png. The first can only 404 either way. */
|
||||
"<img src=\"../escape.png\">\n"
|
||||
"<img src=\"../img/a%20b.png\">\n"
|
||||
"<a href=\"img/a%20b.png\">link</a>\n"
|
||||
"<script src=\"js/app.js\"></script>\n"
|
||||
"<script>var s = \"</scripting>\"; var t = \"<img src='img/a%20b.png'>\";"
|
||||
"</script>\n"
|
||||
"<img src=\"missing.png\" >\n"
|
||||
"<!--><img src=\"img/a%20b.png\">\n"
|
||||
"<div style=\"background:url(img/a%20b.png)\"></div>\n"
|
||||
"<div style='content:\"x\"; background:url(img/a%20b.png)'></div>\n"
|
||||
"</body></html>\n";
|
||||
|
||||
/* Lay a small mirror down under root. */
|
||||
static void sf_fixture(const char *root) {
|
||||
/* The over-cap url() is what drives the rebase fallback: a reference an
|
||||
inlined stylesheet could not embed has to come out relative to the page,
|
||||
not to the stylesheet, or it dangles. */
|
||||
static const char css[] =
|
||||
"@import \"sub/nested.css\";\n"
|
||||
"@import url(\"sub/two.css\");\n"
|
||||
"@import \"a\\\"url(../img/a b.png)b.css\";\n"
|
||||
"@font-face { font-family: f; src: url(../font/f.woff2); }\n"
|
||||
"body { background: url(../img/a b.png); }\n"
|
||||
"div { background: url(../img/big.png); }\n"
|
||||
"/* url(../img/never.png) */\n";
|
||||
static const char nested[] = "div { background: url(../../img/a b.png); }\n";
|
||||
static const char two[] = "p { background: url(../../img/a b.png); }\n";
|
||||
static const char deep[] =
|
||||
"<html><head><link rel=\"stylesheet\" href=\"../../css/main.css\">\n"
|
||||
"</head><body>d</body></html>\n";
|
||||
static const char js[] = "var app = 1;\n";
|
||||
char big[4096];
|
||||
|
||||
memset(big, 'B', sizeof(big));
|
||||
sf_put(root, "page.html", sf_page, sizeof(sf_page) - 1);
|
||||
sf_put(root, "deep/sub/page.html", deep, sizeof(deep) - 1);
|
||||
sf_put(root, "other.html", "<html>o</html>", 14);
|
||||
sf_put(root, "css/main.css", css, sizeof(css) - 1);
|
||||
sf_put(root, "css/sub/nested.css", nested, sizeof(nested) - 1);
|
||||
sf_put(root, "css/sub/two.css", two, sizeof(two) - 1);
|
||||
sf_put(root, "js/app.js", js, sizeof(js) - 1);
|
||||
sf_put(root, "img/a b.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/big.png", big, sizeof(big));
|
||||
sf_put(root, "img/in.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/po.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/sv.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/bg.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/ph.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/lz.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/lz2.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/low.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/ob.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "img/em.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "icon.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "font/f.woff2", "wOF2\x00\x01", 6);
|
||||
/* Where a guard's removal would land each reference that has to stay a
|
||||
link. The colon-bearing two are impossible on Windows, where the scheme
|
||||
guard then only gets the weaker "the link survived" check. */
|
||||
sf_put(root, "img/never.png", sf_png, SF_PNG_LEN);
|
||||
sf_put(root, "example.com/x.png", sf_png, SF_PNG_LEN);
|
||||
sf_colon_ok =
|
||||
sf_try_put(root, "http:/example.com/x.png", sf_png, SF_PNG_LEN) &&
|
||||
sf_try_put(root, "data:text/css;base64,QUJD", "p{}", 3);
|
||||
{ /* More attributes than the tag parser records, with a '>' inside a quoted
|
||||
value: the give-up path must not rescan quote-blind. */
|
||||
String wide = STRING_EMPTY;
|
||||
int n;
|
||||
|
||||
StringCopy(wide, "<html><body><p");
|
||||
for (n = 0; n <= SF_ST_MAX_ATTRS; n++) {
|
||||
char one[32];
|
||||
|
||||
assertf(sprintfbuff(one, " a%d=1", n));
|
||||
StringCat(wide, one);
|
||||
}
|
||||
StringCat(wide,
|
||||
" title=\"> <img src=img/a%20b.png> \">end</p></body></html>");
|
||||
sf_put(root, "wide.html", StringBuff(wide), StringLength(wide));
|
||||
StringFree(wide);
|
||||
}
|
||||
sf_put(root, "v.mp4",
|
||||
"\x00\x00\x00\x18"
|
||||
"ftypisom",
|
||||
12);
|
||||
}
|
||||
|
||||
/* -#test=singlefile <dir>: rewrite a hand-built mirror and check what gets
|
||||
inlined, what must keep its link, the per-asset cap, and idempotence. */
|
||||
static int st_singlefile(httrackp *opt, int argc, char **argv) {
|
||||
char BIGSTK root[HTS_URLMAXSIZE];
|
||||
char BIGSTK page[HTS_URLMAXSIZE * 2];
|
||||
const LLint saved_cap = opt->single_file_max_size;
|
||||
char *out, *css, *nested;
|
||||
size_t outlen = 0, len = 0;
|
||||
|
||||
if (argc < 1) {
|
||||
fprintf(stderr, "singlefile: needs a writable directory\n");
|
||||
return 1;
|
||||
}
|
||||
sf_err = 0;
|
||||
sf_put(argv[0], "escape.png", sf_png,
|
||||
SF_PNG_LEN); /* just outside the mirror */
|
||||
fconcat(root, sizeof(root), argv[0], "mirror/");
|
||||
sf_fixture(root);
|
||||
fconcat(page, sizeof(page), root, "page.html");
|
||||
|
||||
/* Cap between the small assets and big.png. */
|
||||
opt->single_file_max_size = 1024;
|
||||
sf_check(singlefile_rewrite_file(opt, root, page),
|
||||
"first pass changed nothing");
|
||||
out = readfile_utf8(page);
|
||||
assertf(out != NULL);
|
||||
|
||||
/* Inlined, and the payload is the file's exact bytes. */
|
||||
{
|
||||
char *img = sf_decode(out, "image/png", &len);
|
||||
|
||||
sf_check(img != NULL && len == SF_PNG_LEN &&
|
||||
memcmp(img, sf_png, SF_PNG_LEN) == 0,
|
||||
"image payload does not round-trip");
|
||||
freet(img);
|
||||
}
|
||||
{
|
||||
char *js = sf_decode(out, "application/x-javascript", &len);
|
||||
|
||||
sf_check(js != NULL && len == 13 && memcmp(js, "var app = 1;\n", 13) == 0,
|
||||
"script payload does not round-trip");
|
||||
freet(js);
|
||||
}
|
||||
sf_check(strstr(out, "href=\"data:text/css;base64,") != NULL,
|
||||
"stylesheet not inlined into the link");
|
||||
{
|
||||
char *font = sf_decode(out, "font/woff2", &len);
|
||||
|
||||
sf_check(font != NULL && len == 6 && memcmp(font, "wOF2\x00\x01", 6) == 0,
|
||||
"rel=preload font payload does not round-trip");
|
||||
freet(font);
|
||||
}
|
||||
|
||||
/* Every other (tag, attribute) rule in the table. */
|
||||
sf_check(strstr(out, "icon.png") == NULL, "rel=icon not inlined");
|
||||
sf_check(strstr(out, "img/in.png") == NULL, "input src not inlined");
|
||||
sf_check(strstr(out, "img/po.png") == NULL, "video poster not inlined");
|
||||
sf_check(strstr(out, "img/sv.png") == NULL, "svg image href not inlined");
|
||||
sf_check(strstr(out, "img/bg.png") == NULL,
|
||||
"legacy background attribute not inlined");
|
||||
sf_check(strstr(out, "img/ob.png") == NULL, "object data not inlined");
|
||||
sf_check(strstr(out, "img/em.png") == NULL, "embed src not inlined");
|
||||
sf_check(strstr(out, "img/ph.png") == NULL, "lazy placeholder not inlined");
|
||||
sf_check(strstr(out, "img/lz.png") == NULL, "data-src not inlined");
|
||||
sf_check(strstr(out, "img/lz2.png") == NULL, "data-srcset not inlined");
|
||||
sf_check(strstr(out, "img/low.png") == NULL, "lowsrc not inlined");
|
||||
/* The class gate, not the attribute name, is what keeps a page out. */
|
||||
sf_check(strstr(out, "data-src=\"other.html\"") != NULL,
|
||||
"data-src pointing at a page was inlined");
|
||||
|
||||
sf_check(strstr(out, "<a href=\"img/a%20b.png\">") != NULL, "anchor inlined");
|
||||
sf_check(strstr(out, "href=\"other.html\"") != NULL, "rel=canonical inlined");
|
||||
sf_check(strstr(out, "src=\"v.mp4\"") != NULL, "video source inlined");
|
||||
sf_check(strstr(out, "src=\"http://example.com/x.png\"") != NULL,
|
||||
"absolute URL rewritten");
|
||||
sf_check(strstr(out, "src=\"//example.com/x.png\"") != NULL,
|
||||
"site-root-relative URL rewritten");
|
||||
sf_check(sf_count(out, "QUJD") == 2, "existing data: URI not preserved");
|
||||
sf_check(strstr(out, "src=\"../escape.png\"") != NULL,
|
||||
"a reference outside the mirror was resolved");
|
||||
sf_check(strstr(out, "src=\"../img/a%20b.png\"") != NULL,
|
||||
"a leading .. was dropped instead of rejected");
|
||||
sf_check(strstr(out, "var t = \"<img src='img/a%20b.png'>\";") != NULL,
|
||||
"script body rewritten past a </scripting> lookalike");
|
||||
|
||||
/* Nothing an attribute value cannot hold: url() stays unquoted, and a quote
|
||||
that was already in the CSS is escaped. */
|
||||
sf_check(strstr(out, "url(\"data:") == NULL,
|
||||
"a quoted url() would end a style attribute");
|
||||
sf_check(strstr(out, "style=\"content:"x"; background:url(data:") !=
|
||||
NULL,
|
||||
"quote inside a rewritten style attribute not escaped");
|
||||
|
||||
sf_check(strstr(out, "img/big.png 2x") != NULL, "over-cap asset inlined");
|
||||
sf_check(strstr(out, " 1x") != NULL, "srcset descriptor lost");
|
||||
sf_check(sf_count(out, "img/a%20b.png") ==
|
||||
3, /* the anchor, the script body, and the ".." one */
|
||||
"an inlinable reference was left as a link");
|
||||
|
||||
/* The inlined stylesheet carries its own @import and url() inlined. */
|
||||
css = sf_decode(out, "text/css", NULL);
|
||||
sf_check(css != NULL, "stylesheet payload undecodable");
|
||||
if (css != NULL) {
|
||||
sf_check(strstr(css, "@import \"data:text/css;base64,") != NULL,
|
||||
"@import not inlined");
|
||||
sf_check(strstr(css, "url(data:image/png;base64,") != NULL,
|
||||
"url() in stylesheet not inlined");
|
||||
sf_check(strstr(css, "url(../img/never.png)") != NULL,
|
||||
"url() inside a CSS comment was rewritten");
|
||||
sf_check(strstr(css, "url(data:font/woff2;base64,") != NULL,
|
||||
"@font-face src not inlined");
|
||||
sf_check(strstr(css, "@import url(data:text/css;base64,") != NULL,
|
||||
"@import url() form not inlined");
|
||||
sf_check(strstr(css, "url(../img/a b.png)b.css") != NULL,
|
||||
"url() inside a string with an escaped quote was rewritten");
|
||||
/* The over-cap url() read ../img/big.png from css/; this page sits at the
|
||||
root, so it has to come back out as img/big.png or it dangles. */
|
||||
sf_check(strstr(css, "url(img/big.png)") != NULL,
|
||||
"over-cap url() not rebased onto the page's directory");
|
||||
nested = sf_decode(css, "text/css", NULL);
|
||||
sf_check(nested != NULL &&
|
||||
strstr(nested, "url(data:image/png;base64,") != NULL,
|
||||
"url() in the @import'ed stylesheet not inlined");
|
||||
freet(nested);
|
||||
freet(css);
|
||||
}
|
||||
|
||||
/* A tag with more attributes than the parser records comes back byte for
|
||||
byte, quoted '>' and all, instead of being re-scanned as markup. */
|
||||
{
|
||||
char BIGSTK wide[HTS_URLMAXSIZE * 2];
|
||||
char *before, *after;
|
||||
|
||||
fconcat(wide, sizeof(wide), root, "wide.html");
|
||||
before = readfile_utf8(wide);
|
||||
assertf(before != NULL);
|
||||
(void) singlefile_rewrite_file(opt, root, wide);
|
||||
after = readfile_utf8(wide);
|
||||
sf_check(after != NULL && strcmp(before, after) == 0,
|
||||
"an over-wide tag was rewritten");
|
||||
freet(after);
|
||||
freet(before);
|
||||
}
|
||||
|
||||
/* The same stylesheet from two directories down, where the rebase has to
|
||||
climb: the emitted path must stay inside the mirror and name the file. */
|
||||
{
|
||||
char BIGSTK deep[HTS_URLMAXSIZE * 2];
|
||||
char *dout, *dcss;
|
||||
|
||||
fconcat(deep, sizeof(deep), root, "deep/sub/page.html");
|
||||
sf_check(singlefile_rewrite_file(opt, root, deep),
|
||||
"deep page not rewritten");
|
||||
dout = readfile_utf8(deep);
|
||||
assertf(dout != NULL);
|
||||
dcss = sf_decode(dout, "text/css", NULL);
|
||||
sf_check(dcss != NULL && strstr(dcss, "url(../../img/big.png)") != NULL,
|
||||
"over-cap url() not rebased from a nested page");
|
||||
freet(dcss);
|
||||
freet(dout);
|
||||
}
|
||||
|
||||
/* Idempotence: a second pass must find nothing and leave the bytes alone. */
|
||||
sf_check(!singlefile_rewrite_file(opt, root, page), "second pass rewrote");
|
||||
{
|
||||
char *again = readfile_utf8(page);
|
||||
|
||||
sf_check(again != NULL && strcmp(again, out) == 0,
|
||||
"second pass changed the page");
|
||||
freet(again);
|
||||
}
|
||||
freet(out);
|
||||
|
||||
/* Same page, a cap above big.png: it now inlines. */
|
||||
fconcat(root, sizeof(root), argv[0], "mirror2/");
|
||||
sf_fixture(root);
|
||||
fconcat(page, sizeof(page), root, "page.html");
|
||||
opt->single_file_max_size = 1024 * 1024;
|
||||
sf_check(singlefile_rewrite_file(opt, root, page),
|
||||
"raised-cap pass changed nothing");
|
||||
out = readfile_utf8(page);
|
||||
assertf(out != NULL);
|
||||
sf_check(strstr(out, "img/big.png 2x") == NULL,
|
||||
"asset under the raised cap still a link");
|
||||
freet(out);
|
||||
|
||||
/* Nothing inlines, so the rewriter must be byte transparent. Assert on its
|
||||
output: the file it declined to write could not have changed regardless. */
|
||||
fconcat(root, sizeof(root), argv[0], "mirror3/");
|
||||
sf_fixture(root);
|
||||
fconcat(page, sizeof(page), root, "page.html");
|
||||
opt->single_file_max_size = 1;
|
||||
sf_check(!singlefile_rewrite_file(opt, root, page), "one-byte cap inlined");
|
||||
{
|
||||
String verbatim = STRING_EMPTY;
|
||||
|
||||
StringClear(verbatim);
|
||||
(void) singlefile_rewrite_html(opt, root, page, sf_page,
|
||||
sizeof(sf_page) - 1,
|
||||
SINGLEFILE_MAX_PAGE_SIZE, &verbatim);
|
||||
sf_check(StringLength(verbatim) == sizeof(sf_page) - 1 &&
|
||||
memcmp(StringBuff(verbatim), sf_page, sizeof(sf_page) - 1) ==
|
||||
0,
|
||||
"a page with nothing to inline was re-serialized differently");
|
||||
StringFree(verbatim);
|
||||
}
|
||||
(void) outlen;
|
||||
|
||||
/* The per-page budget against a self-importing stylesheet. The large-budget
|
||||
run is the control: it proves the fan-out is real, so the small one was
|
||||
cut short by the budget and not by the fixture. */
|
||||
{
|
||||
static const char bomb_css[] = "@import \"b.css\";@import \"b.css\";"
|
||||
"@import \"b.css\";@import \"b.css\";\n";
|
||||
static const char bomb_html[] = "<html><head>"
|
||||
"<link rel=\"stylesheet\" href=\"b.css\">"
|
||||
"</head></html>\n";
|
||||
const size_t css_len = sizeof(bomb_css) - 1;
|
||||
String small = STRING_EMPTY, large = STRING_EMPTY;
|
||||
|
||||
fconcat(root, sizeof(root), argv[0], "bomb/");
|
||||
sf_put(root, "b.css", bomb_css, css_len);
|
||||
fconcat(page, sizeof(page), root, "page.html");
|
||||
opt->single_file_max_size = 1024 * 1024;
|
||||
StringClear(small);
|
||||
StringClear(large);
|
||||
(void) singlefile_rewrite_html(opt, root, page, bomb_html,
|
||||
sizeof(bomb_html) - 1, (LLint) css_len * 3,
|
||||
&small);
|
||||
(void) singlefile_rewrite_html(opt, root, page, bomb_html,
|
||||
sizeof(bomb_html) - 1,
|
||||
SINGLEFILE_MAX_PAGE_SIZE, &large);
|
||||
sf_check(StringLength(large) > 4096, "the @import bomb did not fan out");
|
||||
sf_check(StringLength(small) < StringLength(large) / 8,
|
||||
"the per-page budget did not cut the fan-out short");
|
||||
/* Three files fit in three file-lengths only if the budget is charged
|
||||
before each nested rewrite; charging after measured five levels. */
|
||||
sf_check(sf_nesting(StringBuff(small), "text/css") == 3,
|
||||
"the per-page budget was not charged as each asset was taken");
|
||||
StringFree(small);
|
||||
StringFree(large);
|
||||
}
|
||||
|
||||
if (!sf_colon_ok)
|
||||
printf("singlefile: ':' is not a legal filename here, so the scheme guard "
|
||||
"only gets the weaker check\n");
|
||||
opt->single_file_max_size = saved_cap;
|
||||
printf("singlefile: %s\n", sf_err ? "FAIL" : "OK");
|
||||
return sf_err;
|
||||
}
|
||||
|
||||
// -#test=longpath <dir>: round-trip a >MAX_PATH (260) file through the file
|
||||
// wrappers, exercising hts_pathToUCS2's \\?\ prefixing on Windows (#133).
|
||||
static int st_longpath(httrackp *opt, int argc, char **argv) {
|
||||
@@ -5226,6 +5762,192 @@ static int st_cookieimport(httrackp *opt, int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --changes bucket accounting and JSON escaping (#714). */
|
||||
static int st_changes(httrackp *opt, int argc, char **argv) {
|
||||
String out = STRING_EMPTY;
|
||||
int err = 0;
|
||||
|
||||
(void) opt;
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
/* A file the crawl did not rewrite is unchanged whatever the wire said. */
|
||||
assertf(hts_changes_classify(HTS_FALSE, HTS_TRUE, HTS_FALSE, HTS_FALSE,
|
||||
HTS_FALSE) == HTS_CHANGE_UNCHANGED);
|
||||
/* Rewritten with no previous copy: new, digests or not. */
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_FALSE, HTS_FALSE, HTS_TRUE,
|
||||
HTS_FALSE) == HTS_CHANGE_NEW);
|
||||
/* Digests decide, and outrank the transfer signal both ways: a server with
|
||||
no validators answers 200 with the same bytes, and a 304 can still sit in
|
||||
front of a locally damaged copy. */
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_FALSE, HTS_TRUE,
|
||||
HTS_TRUE) == HTS_CHANGE_UNCHANGED);
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_TRUE, HTS_TRUE,
|
||||
HTS_FALSE) == HTS_CHANGE_CHANGED);
|
||||
/* Only with no digest at all does the transfer signal get a say. */
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_TRUE, HTS_FALSE,
|
||||
HTS_FALSE) == HTS_CHANGE_UNCHANGED);
|
||||
assertf(hts_changes_classify(HTS_TRUE, HTS_TRUE, HTS_FALSE, HTS_FALSE,
|
||||
HTS_FALSE) == HTS_CHANGE_CHANGED);
|
||||
|
||||
#define JSON_IS(SRC, WANT) \
|
||||
do { \
|
||||
StringClear(out); \
|
||||
hts_changes_json_string(&out, SRC); \
|
||||
if (strcmp(StringBuff(out), WANT) != 0) { \
|
||||
fprintf(stderr, "changes: %s -> %s, expected %s\n", #SRC, \
|
||||
StringBuff(out), WANT); \
|
||||
err = 1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
JSON_IS("/a/b.html", "\"/a/b.html\"");
|
||||
JSON_IS("a\"b\\c", "\"a\\\"b\\\\c\"");
|
||||
JSON_IS("tab\there", "\"tab\\u0009here\"");
|
||||
/* Valid UTF-8 rides through; a lone Latin-1 byte, a truncated sequence and
|
||||
an overlong encoding of '/' each become U+FFFD rather than invalid JSON. */
|
||||
JSON_IS("caf\xc3\xa9", "\"caf\xc3\xa9\"");
|
||||
JSON_IS("caf\xe9", "\"caf\\ufffd\"");
|
||||
JSON_IS("\xc3", "\"\\ufffd\"");
|
||||
JSON_IS("\xc0\xaf", "\"\\ufffd\\ufffd\"");
|
||||
/* A UTF-16 surrogate half is well-formed UTF-8 by shape only. */
|
||||
JSON_IS("\xed\xa0\x80", "\"\\ufffd\\ufffd\\ufffd\"");
|
||||
|
||||
#undef JSON_IS
|
||||
StringFree(out);
|
||||
printf("changes self-test: %s\n", err ? "FAIL" : "OK");
|
||||
return err;
|
||||
}
|
||||
|
||||
#define CHANGES_RACE_FILES 8
|
||||
#define CHANGES_RACE_ROUNDS 400
|
||||
|
||||
static void changes_race_notify(httrackp *opt, int n) {
|
||||
char fil[64];
|
||||
char BIGSTK save[HTS_URLMAXSIZE * 2];
|
||||
|
||||
snprintf(fil, sizeof(fil), "/f%d.bin", n);
|
||||
strlcpybuff(save, StringBuff(opt->path_html), sizeof(save));
|
||||
strlcatbuff(save, "race.example", sizeof(save));
|
||||
strlcatbuff(save, fil, sizeof(save));
|
||||
hts_changes_notify(opt, "race.example", fil, save, HTS_TRUE, HTS_FALSE);
|
||||
}
|
||||
|
||||
/* htsthread_wait() counts a thread only once it is running, so it can return
|
||||
before any of them started; join on our own counter instead. */
|
||||
static htsmutex changes_race_lock = HTSMUTEX_INIT;
|
||||
static int changes_race_started = 0;
|
||||
static int changes_race_live = 0;
|
||||
|
||||
static int changes_race_count(int *which) {
|
||||
int n;
|
||||
|
||||
hts_mutexlock(&changes_race_lock);
|
||||
n = *which;
|
||||
hts_mutexrelease(&changes_race_lock);
|
||||
return n;
|
||||
}
|
||||
|
||||
static void changes_race_thread(void *arg) {
|
||||
httrackp *const opt = (httrackp *) arg;
|
||||
int i;
|
||||
|
||||
hts_mutexlock(&changes_race_lock);
|
||||
changes_race_started++;
|
||||
hts_mutexrelease(&changes_race_lock);
|
||||
for (i = 0; i < CHANGES_RACE_ROUNDS; i++)
|
||||
changes_race_notify(opt, i % CHANGES_RACE_FILES);
|
||||
hts_mutexlock(&changes_race_lock);
|
||||
changes_race_live--;
|
||||
hts_mutexrelease(&changes_race_lock);
|
||||
}
|
||||
|
||||
/* A transfer thread the crawl never joins (FTP) reaches hts_changes_notify()
|
||||
while the report is being resolved and written. Run it under TSan. */
|
||||
static int st_changes_race(httrackp *opt, int argc, char **argv) {
|
||||
String out = STRING_EMPTY;
|
||||
char base[HTS_URLMAXSIZE];
|
||||
int err = 0;
|
||||
int i;
|
||||
|
||||
if (argc < 1) {
|
||||
fprintf(stderr, "usage: -#test=changes-race <writable directory>\n");
|
||||
return 1;
|
||||
}
|
||||
strcpybuff(base, argv[0]);
|
||||
if (base[0] != '\0' && base[strlen(base) - 1] != '/')
|
||||
strcatbuff(base, "/");
|
||||
StringCopy(opt->path_html, base);
|
||||
StringCopy(opt->path_html_utf8, base);
|
||||
StringCopy(opt->path_log, base);
|
||||
opt->changes = HTS_TRUE;
|
||||
hts_changes_free_opt(opt);
|
||||
|
||||
/* Real files, so the reader hashes and stats them for as long as it takes. */
|
||||
{
|
||||
char BIGSTK dir[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strlcpybuff(dir, base, sizeof(dir));
|
||||
strlcatbuff(dir, "race.example", sizeof(dir));
|
||||
for (i = 0; i < CHANGES_RACE_FILES; i++) {
|
||||
char BIGSTK path[HTS_URLMAXSIZE * 2];
|
||||
char name[64];
|
||||
FILE *fp;
|
||||
int n;
|
||||
|
||||
snprintf(name, sizeof(name), "/f%d.bin", i);
|
||||
strlcpybuff(path, dir, sizeof(path));
|
||||
strlcatbuff(path, name, sizeof(path));
|
||||
structcheck(path);
|
||||
fp = FOPEN(path, "wb");
|
||||
if (fp == NULL) {
|
||||
fprintf(stderr, "changes-race: cannot write %s\n", path);
|
||||
return 1;
|
||||
}
|
||||
for (n = 0; n < 16384; n++)
|
||||
fwrite("0123456789abcdef", 1, 16, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Take both locks once here: hts_mutexlock() initializes lazily, and two
|
||||
threads reaching a fresh one together race on the init itself. */
|
||||
hts_mutexlock(&changes_race_lock);
|
||||
changes_race_started = 0;
|
||||
changes_race_live = 4;
|
||||
hts_mutexrelease(&changes_race_lock);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (hts_newthread(changes_race_thread, opt) != 0) {
|
||||
fprintf(stderr, "changes-race: cannot spawn a notifier thread\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* Report only once they are all notifying, or there is nothing to race. */
|
||||
while (changes_race_count(&changes_race_started) < 4)
|
||||
Sleep(10);
|
||||
for (i = 0; i < 64; i++)
|
||||
hts_changes_report(opt, &out);
|
||||
hts_changes_close_opt(opt);
|
||||
while (changes_race_count(&changes_race_live) > 0)
|
||||
Sleep(10);
|
||||
|
||||
/* Sealed: a straggler must be dropped, not start a report nobody writes. */
|
||||
changes_race_notify(opt, CHANGES_RACE_FILES + 1);
|
||||
hts_changes_report(opt, &out);
|
||||
if (StringLength(out) == 0) {
|
||||
fprintf(stderr, "changes-race: the report was lost after close\n");
|
||||
err = 1;
|
||||
} else if (strstr(StringBuff(out), "f9.bin") != NULL) {
|
||||
fprintf(stderr, "changes-race: a post-close notify reached the report\n");
|
||||
err = 1;
|
||||
}
|
||||
|
||||
StringFree(out);
|
||||
hts_changes_free_opt(opt);
|
||||
printf("changes-race self-test: %s\n", err ? "FAIL" : "OK");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Registry: name -> handler, with a usage hint and a one-line description. */
|
||||
/* ------------------------------------------------------------ */
|
||||
@@ -5281,6 +6003,10 @@ static const struct selftest_entry {
|
||||
{"strsafe", "[overflow|overflow-buff|overflow-src [str]]",
|
||||
"bounded string-op self-test", st_strsafe},
|
||||
{"copyopt", "", "copy_htsopt option-copy self-test", st_copyopt},
|
||||
{"changes", "", "--changes bucket accounting and JSON escaping (#714)",
|
||||
st_changes},
|
||||
{"changes-race", "<dir>", "--changes under a late transfer thread (#714)",
|
||||
st_changes_race},
|
||||
{"pause", "", "randomized inter-file pause target self-test", st_pause},
|
||||
{"relative", "<link> <curr-file>", "relative link between two paths",
|
||||
st_relative},
|
||||
@@ -5383,6 +6109,9 @@ static const struct selftest_entry {
|
||||
{"warc-wacz", "<dir>", "--wacz package: layout, STORE mode, sha256 digests",
|
||||
st_warc_wacz},
|
||||
#endif
|
||||
{"singlefile", "<dir>",
|
||||
"--single-file: what is inlined, the per-asset cap, idempotence",
|
||||
st_singlefile},
|
||||
};
|
||||
|
||||
static void list_selftests(void) {
|
||||
|
||||
1160
src/htssinglefile.c
Normal file
1160
src/htssinglefile.c
Normal file
File diff suppressed because it is too large
Load Diff
84
src/htssinglefile.h
Normal file
84
src/htssinglefile.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 2026 Xavier Roche and other contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Ethical use: we kindly ask that you NOT use this software to harvest email
|
||||
addresses or to collect any other private information about people. Doing so
|
||||
would dishonor our work and waste the many hours we have spent on it.
|
||||
|
||||
Please visit our Website: http://www.httrack.com
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* --single-file: post-mirror pass embedding each page's assets as data: URIs.
|
||||
Internal, not installed. Unlike -%M (one MHT archive for the whole mirror)
|
||||
it rewrites the saved pages in place and keeps page-to-page links relative,
|
||||
so the mirror stays browsable and every page also stands alone.
|
||||
Limitation: an inlined stylesheet becomes a data: URL, whose path is opaque,
|
||||
so an asset inside it that stayed a link (over the cap) no longer resolves.
|
||||
Raise --single-file-max-size past it to inline it too. */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#ifndef HTS_SINGLEFILE_DEFH
|
||||
#define HTS_SINGLEFILE_DEFH
|
||||
|
||||
#include "htsopt.h"
|
||||
#include "htsstrings.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --single-file-max-size default: a bigger asset stays an ordinary link. */
|
||||
#define SINGLEFILE_DEFAULT_MAX_SIZE (10 * 1024 * 1024)
|
||||
|
||||
/* Never base64 more than this, whatever the cap: code64() sizes in int. */
|
||||
#define SINGLEFILE_HARD_MAX_SIZE (256 * 1024 * 1024)
|
||||
|
||||
/* Total bytes one page may inline. Nested @import fans out multiplicatively,
|
||||
so a few hundred bytes of hostile CSS can otherwise ask for gigabytes. */
|
||||
#define SINGLEFILE_MAX_PAGE_SIZE (64 * 1024 * 1024)
|
||||
|
||||
/* Rewrite every HTML page the mirror produced. No-op unless opt->single_file;
|
||||
call once the tree is final, after the update purge. */
|
||||
void singlefile_process_mirror(httrackp *opt);
|
||||
|
||||
/* Rewrite one HTML document held in memory, appending the result to out.
|
||||
root is the mirror directory that references may not escape; page_path is
|
||||
the document's own path under it (both UTF-8, '/' or native separators).
|
||||
page_budget caps the total inlined bytes, since nested @import fans out
|
||||
multiplicatively; the mirror pass passes SINGLEFILE_MAX_PAGE_SIZE.
|
||||
Returns HTS_TRUE if at least one reference was replaced; out may still
|
||||
differ from the input when that is HTS_FALSE, since a style or srcset value
|
||||
is re-serialized in place. */
|
||||
hts_boolean singlefile_rewrite_html(httrackp *opt, const char *root,
|
||||
const char *page_path, const char *html,
|
||||
size_t html_len, LLint page_budget,
|
||||
String *out);
|
||||
|
||||
/* singlefile_rewrite_html() over the file at page_path, rewritten in place.
|
||||
Returns HTS_TRUE if the file changed. */
|
||||
hts_boolean singlefile_rewrite_file(httrackp *opt, const char *root,
|
||||
const char *page_path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -462,22 +462,6 @@ static void warc_make_id(warc_writer *w, char out[64]) {
|
||||
b[11], b[12], b[13], b[14], b[15]);
|
||||
}
|
||||
|
||||
static void warc_now_iso8601(char out[32]) {
|
||||
time_t t = time(NULL);
|
||||
struct tm tmv;
|
||||
#if defined(_WIN32)
|
||||
struct tm *g = gmtime(&t);
|
||||
if (g != NULL)
|
||||
tmv = *g;
|
||||
else
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#else
|
||||
if (gmtime_r(&t, &tmv) == NULL)
|
||||
memset(&tmv, 0, sizeof(tmv));
|
||||
#endif
|
||||
strftime(out, 32, "%Y-%m-%dT%H:%M:%SZ", &tmv);
|
||||
}
|
||||
|
||||
/* Case-insensitive "is this the header named name?" test, tolerating optional
|
||||
whitespace before the ':' (non-compliant "Name : value" is still matched). */
|
||||
static int header_is(const char *line, size_t line_len, const char *name) {
|
||||
@@ -1063,7 +1047,7 @@ static void warc_wacz_package(warc_writer *w) {
|
||||
wbuf_free(&pages);
|
||||
|
||||
/* datapackage.json listing every stored file with its sha256 + size. */
|
||||
warc_now_iso8601(created);
|
||||
hts_now_iso8601(created);
|
||||
memset(&dp, 0, sizeof(dp));
|
||||
if (!err &&
|
||||
(wbuf_printf(&dp,
|
||||
@@ -1166,7 +1150,7 @@ static int warc_emit(warc_writer *w, const char *type, const char *content_type,
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
warc_make_id(w, id);
|
||||
warc_now_iso8601(date);
|
||||
hts_now_iso8601(date);
|
||||
|
||||
#if HTS_USEOPENSSL
|
||||
/* Block digest over the whole block, in one streaming pass. */
|
||||
@@ -1670,7 +1654,7 @@ int warc_write_transaction(warc_writer *w, const char *target_uri,
|
||||
char date[32];
|
||||
char *slot;
|
||||
size_t need;
|
||||
warc_now_iso8601(date);
|
||||
hts_now_iso8601(date);
|
||||
need = strlen(target_uri) + 1 + strlen(date) + 1;
|
||||
slot = malloct(need);
|
||||
if (slot != NULL) {
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
<ClCompile Include="htsproxy.c" />
|
||||
<ClCompile Include="htsrobots.c" />
|
||||
<ClCompile Include="htsselftest.c" />
|
||||
<ClCompile Include="htssinglefile.c" />
|
||||
<ClCompile Include="htssniff.c" />
|
||||
<ClCompile Include="htsthread.c" />
|
||||
<ClCompile Include="htstools.c" />
|
||||
@@ -138,6 +139,7 @@
|
||||
<ClCompile Include="htswrap.c" />
|
||||
<ClCompile Include="htszlib.c" />
|
||||
<ClCompile Include="htswarc.c" />
|
||||
<ClCompile Include="htschanges.c" />
|
||||
<ClCompile Include="md5.c" />
|
||||
<ClCompile Include="minizip\ioapi.c" />
|
||||
<ClCompile Include="minizip\iowin32.c" />
|
||||
|
||||
30
tests/01_engine-changes.test
Normal file
30
tests/01_engine-changes.test
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_changes_st.XXXXXX") || exit 1
|
||||
trap 'rm -rf "$tmpdir"' EXIT HUP INT QUIT PIPE TERM
|
||||
|
||||
# No pipe into grep: SIGPIPE would mask a failing exit status.
|
||||
expect_ok() {
|
||||
local label="$1" out
|
||||
shift
|
||||
out=$("$@" 2>&1) || {
|
||||
echo "FAIL: ${label} exited non-zero: ${out}"
|
||||
exit 1
|
||||
}
|
||||
case "$out" in
|
||||
*"${label}: OK"*) ;;
|
||||
*)
|
||||
echo "FAIL: ${out}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# --changes bucket accounting and JSON escaping (#714).
|
||||
expect_ok "changes self-test" httrack -O "${tmpdir}/o1" -#test=changes run
|
||||
# The report must hold against a transfer thread the crawl never joins.
|
||||
expect_ok "changes-race self-test" httrack -O "${tmpdir}/o2" \
|
||||
-#test=changes-race "${tmpdir}/race"
|
||||
@@ -150,11 +150,13 @@ BOXES = [
|
||||
("toler", "TolerantRequests", "--tolerant", None),
|
||||
("http10", "HTTP10", "--http-10", None),
|
||||
("warc", "Warc", "--warc", None),
|
||||
("changes", "Changes", "--changes", None),
|
||||
("norecatch", "NoRecatch", "--do-not-recatch", None),
|
||||
("logf", "Log", "--single-log", None),
|
||||
("index", "Index", None, None),
|
||||
("index2", "WordIndex", "--search-index", None),
|
||||
("ftpprox", "UseHTTPProxyForFTP", "--httpproxy-ftp", None),
|
||||
("singlefile", "SingleFile", "--single-file", None),
|
||||
]
|
||||
|
||||
for field, key, when_set, when_clear in BOXES:
|
||||
|
||||
246
tests/93_local-changes.test
Normal file
246
tests/93_local-changes.test
Normal file
@@ -0,0 +1,246 @@
|
||||
#!/bin/bash
|
||||
# --changes (#714): the report must match the mirror's real deltas. Every route
|
||||
# answers 200 with no validators on both passes, so the transfer signal alone
|
||||
# would call the whole site changed.
|
||||
set -euo pipefail
|
||||
|
||||
: "${top_srcdir:=..}"
|
||||
testdir=$(cd "$(dirname "$0")" && pwd)
|
||||
# shellcheck source=tests/testlib.sh
|
||||
. "${testdir}/testlib.sh"
|
||||
server=$(nativepath "${testdir}/local-server.py")
|
||||
root=$(nativepath "${testdir}/server-root")
|
||||
|
||||
python=$(find_python) || ! echo "python3 not found; skipping" >&2 || exit 77
|
||||
|
||||
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_changes.XXXXXX") || exit 1
|
||||
serverpid=
|
||||
cleanup() {
|
||||
stop_server "$serverpid"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap cleanup EXIT HUP INT QUIT PIPE TERM
|
||||
|
||||
serverlog="${tmpdir}/server.log"
|
||||
: >"$serverlog"
|
||||
"$python" "$server" --root "$root" >"$serverlog" 2>&1 &
|
||||
serverpid=$!
|
||||
port=
|
||||
for _ in $(seq 1 50); do
|
||||
line=$(head -n1 "$serverlog" 2>/dev/null)
|
||||
if test "${line%% *}" == "PORT"; then
|
||||
port="${line#PORT }"
|
||||
break
|
||||
fi
|
||||
kill -0 "$serverpid" 2>/dev/null || {
|
||||
echo "server exited early: $(cat "$serverlog")"
|
||||
exit 1
|
||||
}
|
||||
sleep 0.1
|
||||
done
|
||||
test -n "$port" || {
|
||||
echo "could not discover server port"
|
||||
exit 1
|
||||
}
|
||||
base="http://127.0.0.1:${port}"
|
||||
|
||||
which httrack >/dev/null || {
|
||||
echo "could not find httrack"
|
||||
exit 1
|
||||
}
|
||||
out="${tmpdir}/crawl"
|
||||
mkdir "$out"
|
||||
report="${out}/hts-changes.json"
|
||||
# Purging off for the first two passes: the deleted set must be computed with
|
||||
# nothing acting on it.
|
||||
common=(--quiet --disable-security-limits --robots=0 --timeout=30 --changes --retries=2)
|
||||
|
||||
# Report field extractor: a scalar, and the files listed under a bucket.
|
||||
field() { sed -n 's/.*"'"$1"'": \([a-z0-9]*\).*/\1/p' "${2:-$report}" | head -1; }
|
||||
# tr: python prints CRLF on Windows, and the expectations below are LF.
|
||||
listed() {
|
||||
"$python" - "${2:-$report}" "$1" <<'EOF' | tr -d '\r'
|
||||
import json
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], encoding="utf-8") as fp:
|
||||
report = json.load(fp)
|
||||
for entry in report[sys.argv[2]]:
|
||||
print(entry["file"])
|
||||
EOF
|
||||
}
|
||||
expect() {
|
||||
local label="$1" want="$2" got="$3" rep="${4:-$report}"
|
||||
printf '[%s] ..\t' "$label"
|
||||
test "$want" == "$got" || {
|
||||
echo "FAIL: expected '${want}', got '${got}'"
|
||||
cat "$rep"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
}
|
||||
# Every count must equal the length of the list it counts.
|
||||
expect_counts_match() {
|
||||
local label="$1" rep="${2:-$report}" bucket n
|
||||
printf '[%s] ..\t' "$label"
|
||||
for bucket in new changed unchanged gone; do
|
||||
n=$(listed "$bucket" "$rep" | grep -c . || true)
|
||||
test "$(field "$bucket" "$rep")" == "$n" || {
|
||||
echo "FAIL: ${bucket} count $(field "$bucket" "$rep") but $n listed"
|
||||
cat "$rep"
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
echo "OK"
|
||||
}
|
||||
lines() { printf '%s\n' "$@" | sort; }
|
||||
# A connection killed before the status line surfaces differently per platform
|
||||
# (macOS truncates the file, #748; Linux leaves it), so reset.bin is asserted on
|
||||
# its own and kept out of the exact lists.
|
||||
listed_but_reset() { listed "$1" | grep -v '/reset\.bin$' | sort; }
|
||||
|
||||
# --- pass 1: nothing to compare against --------------------------------------
|
||||
httrack "${common[@]}" -O "$out" --purge-old=0 "${base}/changes/index.html" \
|
||||
>"${tmpdir}/log1" 2>&1
|
||||
test -s "$report" || {
|
||||
echo "FAIL: pass 1 wrote no ${report}"
|
||||
exit 1
|
||||
}
|
||||
expect "pass 1 declares a first crawl" "true" "$(field first_crawl)"
|
||||
# Every mirrored file: index, stable.html, moved.html, stable.bin, moved.bin,
|
||||
# doomed.html, redirtarget.html, flaky.bin, coded.bin, codedstable.bin,
|
||||
# reset.bin, sized.html and the redirect target it points at.
|
||||
expect "pass 1 counts 13 new" "13" "$(field new)"
|
||||
expect "pass 1 counts 0 changed" "0" "$(field changed)"
|
||||
expect "pass 1 counts 0 gone" "0" "$(field gone)"
|
||||
expect_counts_match "pass 1 counts match its lists"
|
||||
grep -aq "first crawl" "${out}/hts-log.txt" || {
|
||||
echo "FAIL: pass 1 log carries no first-crawl summary"
|
||||
exit 1
|
||||
}
|
||||
|
||||
host="127.0.0.1_${port}"
|
||||
# A leftover from some earlier failed attempt, at a name pass 2 fetches for the
|
||||
# first time: on disk, but never part of the previous mirror, so it is new.
|
||||
printf 'leftover junk' >"${out}/${host}/changes/fresh.html"
|
||||
|
||||
# --- pass 2: two bodies move, pages appear and disappear ---------------------
|
||||
httrack "${common[@]}" -O "$out" --purge-old=0 --update \
|
||||
"${base}/changes/index.html" >"${tmpdir}/log2" 2>&1
|
||||
expect "pass 2 is not a first crawl" "false" "$(field first_crawl)"
|
||||
|
||||
# The redirect behind sized.html now points at a much longer target name.
|
||||
long="${host}/changes/$(printf 's%.0s' $(seq 40)).html"
|
||||
expect "new is the two fresh pages and the renamed redirect target" \
|
||||
"$(lines "${host}/changes/fresh.html" "${host}/changes/transient.html" "$long")" \
|
||||
"$(listed new | sort)"
|
||||
expect "gone is doomed.html and the old redirect target" \
|
||||
"$(lines "${host}/changes/doomed.html" "${host}/changes/s.html")" \
|
||||
"$(listed gone | sort)"
|
||||
# index.html changes because its link list does; moved.* change their bodies.
|
||||
# coded.bin arrives gzipped and direct-to-disk, so its previous copy has to be
|
||||
# sampled before the decoded temp is renamed over it; it is the same length on
|
||||
# both passes, so only a digest separates it from codedstable.bin.
|
||||
expect "changed is exactly the four moved resources" \
|
||||
"$(lines "${host}/changes/coded.bin" "${host}/changes/index.html" \
|
||||
"${host}/changes/moved.bin" "${host}/changes/moved.html")" \
|
||||
"$(listed_but_reset changed)"
|
||||
# Re-served byte for byte, 200, no Last-Modified, no ETag. flaky.bin gets there
|
||||
# through a failed transfer and a retry, so its file is notified twice;
|
||||
# redirtarget.html arrives behind a 302. sized.html has a byte-identical
|
||||
# payload, but the rewritten link to the renamed redirect target makes the file
|
||||
# on disk change length.
|
||||
expect "unchanged is exactly the six stable resources" \
|
||||
"$(lines "${host}/changes/codedstable.bin" "${host}/changes/flaky.bin" \
|
||||
"${host}/changes/redirtarget.html" "${host}/changes/sized.html" \
|
||||
"${host}/changes/stable.bin" "${host}/changes/stable.html")" \
|
||||
"$(listed_but_reset unchanged)"
|
||||
# reset.bin never completes a transfer, so it drops out of new.lst with its
|
||||
# mirrored copy still there. Whatever else it is, it is not a deletion.
|
||||
expect "a failed re-fetch is never reported gone" "" \
|
||||
"$(listed gone | grep '/reset\.bin$' || true)"
|
||||
expect_counts_match "pass 2 counts match its lists"
|
||||
|
||||
# Every mirrored file appears once and only once, across all four buckets.
|
||||
printf '[each file in exactly one bucket] ..\t'
|
||||
dupes=$( (
|
||||
listed new
|
||||
listed changed
|
||||
listed unchanged
|
||||
listed gone
|
||||
) | sort | uniq -d)
|
||||
test -z "$dupes" || {
|
||||
echo "FAIL: listed in more than one bucket: ${dupes}"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
# The log summary is the report, rendered: it must not drift from the counts.
|
||||
summary="Change report: $(field new) new, $(field changed) changed, $(field unchanged) unchanged, $(field gone) gone (hts-changes.json)"
|
||||
printf '[the log summary matches the counts] ..\t'
|
||||
grep -aqF "$summary" "${out}/hts-log.txt" || {
|
||||
echo "FAIL: no '${summary}' in the log"
|
||||
grep -a "Change report" "${out}/hts-log.txt" || true
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
expect "the report says nothing was purged" "false" "$(field purged)"
|
||||
printf '[reporting gone did not delete it] ..\t'
|
||||
test -f "${out}/${host}/changes/doomed.html" || {
|
||||
echo "FAIL: doomed.html was deleted with --purge-old=0"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
printf '[a failed transfer keeps its file] ..\t'
|
||||
test -f "${out}/${host}/changes/reset.bin" || {
|
||||
echo "FAIL: reset.bin lost its previous copy"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
# --- pass 3: the same run with purging on ------------------------------------
|
||||
httrack "${common[@]}" -O "$out" --update "${base}/changes/index.html" \
|
||||
>"${tmpdir}/log3" 2>&1
|
||||
expect "the report says files were purged" "true" "$(field purged)"
|
||||
expect "gone is the page that only pass 2 linked" \
|
||||
"${host}/changes/transient.html" "$(listed_but_reset gone)"
|
||||
printf '[a purged file is off disk] ..\t'
|
||||
test ! -f "${out}/${host}/changes/transient.html" || {
|
||||
echo "FAIL: transient.html survived --purge-old"
|
||||
exit 1
|
||||
}
|
||||
echo "OK"
|
||||
|
||||
# --- cache off: the report degrades, it does not lie -------------------------
|
||||
nocache="${tmpdir}/nocache"
|
||||
mkdir "$nocache"
|
||||
ncreport="${nocache}/hts-changes.json"
|
||||
for pass in 1 2; do
|
||||
httrack "${common[@]}" -O "$nocache" -C0 "${base}/changes2/index.html" \
|
||||
>"${tmpdir}/lognc${pass}" 2>&1
|
||||
done
|
||||
expect "with no cache first_crawl is undetermined, not guessed" "null" \
|
||||
"$(field first_crawl "$ncreport")" "$ncreport"
|
||||
# The bodies on disk are still compared, so a constant one is not called
|
||||
# changed. index.html is: a parsed page is compared against the cached payload,
|
||||
# and there is no cache, which is the degradation the report declares.
|
||||
expect "the constant body is still recognised as unchanged" \
|
||||
"${host}/changes2/stable2.bin" "$(listed unchanged "$ncreport")" "$ncreport"
|
||||
expect "the moving body is still recognised as changed" \
|
||||
"$(lines "${host}/changes2/index.html" "${host}/changes2/ticker2.bin")" \
|
||||
"$(listed changed "$ncreport" | sort)" "$ncreport"
|
||||
expect_counts_match "cache-off counts match its lists" "$ncreport"
|
||||
printf '[every entry carries its size] ..\t'
|
||||
"$python" - "$ncreport" <<'EOF' || exit 1
|
||||
import json
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], encoding="utf-8") as fp:
|
||||
report = json.load(fp)
|
||||
for bucket in ("new", "changed", "unchanged"):
|
||||
for entry in report[bucket]:
|
||||
if "size" not in entry:
|
||||
sys.exit("FAIL: %s has no size in %s" % (entry["file"], bucket))
|
||||
EOF
|
||||
echo "OK"
|
||||
379
tests/94_local-single-file.test
Normal file
379
tests/94_local-single-file.test
Normal file
@@ -0,0 +1,379 @@
|
||||
#!/bin/bash
|
||||
# Issue #713: --single-file inlines each page's assets as data: URIs. End to
|
||||
# end over a real crawl, decoding the payloads against what the server served.
|
||||
set -e
|
||||
|
||||
: "${top_srcdir:=..}"
|
||||
testdir=$(cd "$(dirname "$0")" && pwd)
|
||||
# shellcheck source=tests/testlib.sh
|
||||
. "${testdir}/testlib.sh"
|
||||
server=$(nativepath "${testdir}/local-server.py")
|
||||
|
||||
python=$(find_python) || ! echo "python3 not found; skipping" >&2 || exit 77
|
||||
|
||||
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_713.XXXXXX") || exit 1
|
||||
serverpid=
|
||||
htssrv=
|
||||
cleanup() {
|
||||
stop_server "$serverpid"
|
||||
# htsserver keeps SIGTERM ignored across its exec, so only -9 reaps it.
|
||||
test -z "$htssrv" || kill -9 "$htssrv" 2>/dev/null || true
|
||||
wait "$htssrv" 2>/dev/null || true # absorb bash's async "Killed" notice
|
||||
htssrv=
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap cleanup EXIT HUP INT QUIT PIPE TERM
|
||||
|
||||
# --- the site ---------------------------------------------------------------
|
||||
doc="${tmpdir}/doc"
|
||||
mkdir -p "$doc"
|
||||
cat >"${doc}/index.html" <<'EOF'
|
||||
<html><head>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="canonical" href="other.html">
|
||||
</head><body>
|
||||
<img src="pixel.svg" alt="p">
|
||||
<img src="big.svg" alt="b">
|
||||
<img src="pixel.svg" data-src="lazy.svg" alt="l">
|
||||
<script src="app.js"></script>
|
||||
<a href="other.html">other</a>
|
||||
</body></html>
|
||||
EOF
|
||||
cat >"${doc}/other.html" <<'EOF'
|
||||
<html><body><a href="index.html">back</a></body></html>
|
||||
EOF
|
||||
cat >"${doc}/style.css" <<'EOF'
|
||||
@import "nested.css";
|
||||
body { background: url(pixel.svg); }
|
||||
EOF
|
||||
cat >"${doc}/nested.css" <<'EOF'
|
||||
div { background: url(pixel.svg); }
|
||||
EOF
|
||||
printf 'var app = 1;\n' >"${doc}/app.js"
|
||||
printf '<svg xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1"/></svg>\n' \
|
||||
>"${doc}/pixel.svg"
|
||||
printf '<svg xmlns="http://www.w3.org/2000/svg"><circle r="1"/></svg>\n' \
|
||||
>"${doc}/lazy.svg"
|
||||
{
|
||||
printf '<svg xmlns="http://www.w3.org/2000/svg"><!--'
|
||||
head -c 20000 /dev/zero | tr '\0' 'x'
|
||||
printf '%s\n' '--><rect width="1" height="1"/></svg>'
|
||||
} >"${doc}/big.svg"
|
||||
|
||||
# --- server -----------------------------------------------------------------
|
||||
serverlog="${tmpdir}/server.log"
|
||||
: >"$serverlog"
|
||||
"$python" "$server" --root "$(nativepath "$doc")" >"$serverlog" 2>&1 &
|
||||
serverpid=$!
|
||||
port=
|
||||
for _ in $(seq 1 50); do
|
||||
line=$(head -n1 "$serverlog" 2>/dev/null)
|
||||
if test "${line%% *}" == "PORT"; then
|
||||
port="${line#PORT }"
|
||||
break
|
||||
fi
|
||||
kill -0 "$serverpid" 2>/dev/null || {
|
||||
echo "server exited early: $(cat "$serverlog")"
|
||||
exit 1
|
||||
}
|
||||
sleep 0.1
|
||||
done
|
||||
test -n "$port" || {
|
||||
echo "could not discover server port"
|
||||
exit 1
|
||||
}
|
||||
base="http://127.0.0.1:${port}"
|
||||
|
||||
which httrack >/dev/null || {
|
||||
echo "could not find httrack"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- crawl ------------------------------------------------------------------
|
||||
# The cap sits between pixel.svg and big.svg, so one inlines and one must not.
|
||||
out="${tmpdir}/crawl"
|
||||
mkdir "$out"
|
||||
common=(-O "$out" --quiet --disable-security-limits --robots=0 --timeout=30 --retries=0)
|
||||
httrack "${common[@]}" --single-file --single-file-max-size 4096 \
|
||||
"${base}/index.html" >"${tmpdir}/log1" 2>&1
|
||||
|
||||
page="${out}/127.0.0.1_${port}/index.html"
|
||||
test -f "$page" || {
|
||||
echo "FAIL: no mirrored page at $page"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- what must be inlined, byte for byte ------------------------------------
|
||||
# The decoder is python, not httrack, so a broken encoder cannot agree with
|
||||
# itself here.
|
||||
extract() {
|
||||
"$python" - "$1" "$2" "$3" <<'PY'
|
||||
import base64, re, sys
|
||||
html = open(sys.argv[1], "rb").read().decode("utf-8", "replace")
|
||||
m = re.search(r'data:%s;base64,([A-Za-z0-9+/=]*)' % re.escape(sys.argv[2]), html)
|
||||
if m is None:
|
||||
sys.exit(1)
|
||||
open(sys.argv[3], "wb").write(base64.b64decode(m.group(1)))
|
||||
PY
|
||||
}
|
||||
|
||||
printf '[image inlined and identical] ..\t'
|
||||
extract "$page" "image/svg+xml" "${tmpdir}/got.svg" || {
|
||||
echo "FAIL: no inlined image"
|
||||
exit 1
|
||||
}
|
||||
cmp -s "${doc}/pixel.svg" "${tmpdir}/got.svg" || {
|
||||
echo "FAIL: inlined image differs from the served file"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[script inlined and identical] ..\t'
|
||||
extract "$page" "application/x-javascript" "${tmpdir}/got.js" || {
|
||||
echo "FAIL: no inlined script"
|
||||
exit 1
|
||||
}
|
||||
cmp -s "${doc}/app.js" "${tmpdir}/got.js" || {
|
||||
echo "FAIL: inlined script differs from the served file"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[lazy-loaded image inlined] ..\t'
|
||||
# src is the placeholder a real page ships; the asset rides data-src.
|
||||
grep -q 'data-src="data:image/svg+xml;base64,' "$page" || {
|
||||
echo "FAIL: data-src was not inlined"
|
||||
exit 1
|
||||
}
|
||||
if grep -q 'data-src="lazy.svg"' "$page"; then
|
||||
echo "FAIL: data-src kept its link"
|
||||
exit 1
|
||||
fi
|
||||
test -f "${out}/127.0.0.1_${port}/lazy.svg" || {
|
||||
echo "FAIL: the lazy image was never downloaded, so nothing was proven"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[stylesheet inlined, recursively] ..\t'
|
||||
extract "$page" "text/css" "${tmpdir}/got.css" || {
|
||||
echo "FAIL: no inlined stylesheet"
|
||||
exit 1
|
||||
}
|
||||
grep -q 'url(data:image/svg+xml;base64,' "${tmpdir}/got.css" || {
|
||||
echo "FAIL: url() inside the inlined stylesheet was not inlined"
|
||||
exit 1
|
||||
}
|
||||
extract "${tmpdir}/got.css" "text/css" "${tmpdir}/got2.css" || {
|
||||
echo "FAIL: @import was not inlined"
|
||||
exit 1
|
||||
}
|
||||
grep -q 'url(data:image/svg+xml;base64,' "${tmpdir}/got2.css" || {
|
||||
echo "FAIL: url() inside the @import'ed stylesheet was not inlined"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
# --- what must keep its link ------------------------------------------------
|
||||
printf '[page links stay relative] ..\t'
|
||||
grep -q 'href="other.html"' "$page" || {
|
||||
echo "FAIL: the link to another page was not left relative"
|
||||
exit 1
|
||||
}
|
||||
test -f "${out}/127.0.0.1_${port}/other.html" || {
|
||||
echo "FAIL: the linked page is missing from the mirror"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[over-cap asset stays a link] ..\t'
|
||||
grep -q 'src="big.svg"' "$page" || {
|
||||
echo "FAIL: the over-cap asset did not keep its link"
|
||||
exit 1
|
||||
}
|
||||
test -f "${out}/127.0.0.1_${port}/big.svg" || {
|
||||
echo "FAIL: the over-cap asset is missing from the mirror"
|
||||
exit 1
|
||||
}
|
||||
grep -q 'over the 4096-byte cap' "${out}/hts-log.txt" || {
|
||||
echo "FAIL: the over-cap asset was not reported in the log"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[the mirror still works] ..\t'
|
||||
if grep -q 'href="style.css"' "$page"; then
|
||||
echo "FAIL: the stylesheet link survived"
|
||||
exit 1
|
||||
fi
|
||||
test -f "${out}/127.0.0.1_${port}/style.css" || {
|
||||
echo "FAIL: the mirror lost the standalone stylesheet"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
# --- a second run must not re-encode ----------------------------------------
|
||||
printf '[idempotent under --update] ..\t'
|
||||
# HTTrack stamps the time into its own footer comment, so compare without it.
|
||||
grep -v 'Mirrored from' "$page" >"${tmpdir}/page1.html"
|
||||
httrack "${common[@]}" --single-file --single-file-max-size 4096 --update \
|
||||
"${base}/index.html" >"${tmpdir}/log2" 2>&1
|
||||
grep -v 'Mirrored from' "$page" >"${tmpdir}/page2.html"
|
||||
cmp -s "${tmpdir}/page1.html" "${tmpdir}/page2.html" || {
|
||||
echo "FAIL: the second run changed the page"
|
||||
exit 1
|
||||
}
|
||||
# A double-encoded payload would decode to another data: URI, not to the SVG.
|
||||
extract "$page" "image/svg+xml" "${tmpdir}/got2.svg" || {
|
||||
echo "FAIL: no inlined image after the second run"
|
||||
exit 1
|
||||
}
|
||||
cmp -s "${doc}/pixel.svg" "${tmpdir}/got2.svg" || {
|
||||
echo "FAIL: the second run re-encoded the inlined image"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[-%%Z0 and a bad cap] ..\t'
|
||||
# -%Z0 turns it back off, so the page must come out exactly as the crawl left
|
||||
# it; a non-numeric cap is rejected and the built-in default used instead.
|
||||
off="${tmpdir}/off"
|
||||
mkdir "$off"
|
||||
httrack -O "$off" --quiet --disable-security-limits --robots=0 --timeout=30 \
|
||||
--retries=0 -%Z0 "${base}/index.html" >"${tmpdir}/log3" 2>&1
|
||||
offpage="${off}/127.0.0.1_${port}/index.html"
|
||||
if grep -q 'base64,' "$offpage"; then
|
||||
echo "FAIL: -%Z0 still inlined"
|
||||
exit 1
|
||||
fi
|
||||
bad="${tmpdir}/bad"
|
||||
mkdir "$bad"
|
||||
httrack -O "$bad" --quiet --disable-security-limits --robots=0 --timeout=30 \
|
||||
--retries=0 --single-file-max-size notanumber "${base}/index.html" \
|
||||
>"${tmpdir}/log4" 2>&1
|
||||
badpage="${bad}/127.0.0.1_${port}/index.html"
|
||||
# The default cap is 10 MB, so everything here inlines, big.svg included.
|
||||
grep -q 'data:image/svg+xml;base64,' "$badpage" || {
|
||||
echo "FAIL: a rejected cap did not fall back to the default"
|
||||
exit 1
|
||||
}
|
||||
if grep -q 'src="big.svg"' "$badpage"; then
|
||||
echo "FAIL: the default cap did not cover big.svg"
|
||||
exit 1
|
||||
fi
|
||||
echo OK
|
||||
|
||||
printf '[the rewritten page keeps the mirror file mode] ..\t'
|
||||
# The rewrite spools to a temp and renames, bypassing the engine's chmod.
|
||||
if is_windows; then
|
||||
echo "SKIP (no POSIX file modes)"
|
||||
else
|
||||
umaskdir="${tmpdir}/umask"
|
||||
mkdir "$umaskdir"
|
||||
(
|
||||
umask 077
|
||||
httrack -O "$umaskdir" --quiet --disable-security-limits --robots=0 \
|
||||
--timeout=30 --retries=0 --single-file "${base}/index.html" \
|
||||
>"${tmpdir}/log5" 2>&1
|
||||
)
|
||||
umaskroot="${umaskdir}/127.0.0.1_${port}"
|
||||
mode() { "$python" -c 'import os,sys
|
||||
print("%04o" % (os.stat(sys.argv[1]).st_mode & 0o777))' "$1"; }
|
||||
pagemode=$(mode "${umaskroot}/index.html")
|
||||
assetmode=$(mode "${umaskroot}/big.svg")
|
||||
test "$pagemode" = "$assetmode" || {
|
||||
echo "FAIL: page is $pagemode, the asset beside it is $assetmode"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
fi
|
||||
|
||||
# --- the rewriter in isolation, over a hand-built mirror --------------------
|
||||
# After the crawl assertions, so a failure here cannot hide them: the two cover
|
||||
# different ground (this one reaches media, anchors and the mirror-root clamp).
|
||||
printf '[engine self-test] ..\t'
|
||||
st=$(httrack -O /dev/null "-#test=singlefile" "${tmpdir}/st/" 2>/dev/null)
|
||||
case "$st" in
|
||||
*": OK") echo OK ;;
|
||||
*)
|
||||
echo "FAIL: $st"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- the web GUI must emit the same options ---------------------------------
|
||||
distdir=$(cd "${top_srcdir}" && pwd)
|
||||
printf '[project reload maps the keys back] ..\t'
|
||||
grep -q 'do:copy:SingleFile:singlefile' "${distdir}/html/server/step2.html" || {
|
||||
echo "FAIL: step2.html does not restore SingleFile"
|
||||
exit 1
|
||||
}
|
||||
grep -q 'do:copy:SingleFileMaxSize:singlefilemax' "${distdir}/html/server/step2.html" || {
|
||||
echo "FAIL: step2.html does not restore SingleFileMaxSize"
|
||||
exit 1
|
||||
}
|
||||
echo OK
|
||||
|
||||
printf '[webhttrack renders the options] ..\t'
|
||||
# The Windows job builds httrack.exe only and reaches this file through its
|
||||
# *_local-*.test glob, so report a skip there rather than a pass.
|
||||
if ! command -v htsserver >/dev/null; then
|
||||
echo "SKIP (no htsserver in PATH)"
|
||||
exit 77
|
||||
fi
|
||||
sport=$("$python" -c 'import socket
|
||||
s = socket.socket()
|
||||
s.bind(("127.0.0.1", 0))
|
||||
print(s.getsockname()[1])
|
||||
s.close()')
|
||||
srvlog="${tmpdir}/htsserver.log"
|
||||
(
|
||||
trap '' TERM TTOU
|
||||
export HOME="${tmpdir}/home"
|
||||
mkdir -p "$HOME"
|
||||
exec htsserver "${distdir}/" --port "${sport}" >"${srvlog}" 2>&1
|
||||
) &
|
||||
htssrv=$!
|
||||
url=
|
||||
for _ in $(seq 1 40); do
|
||||
url=$(sed -n 's/^URL=//p' "$srvlog" 2>/dev/null) && test -n "$url" && break
|
||||
kill -0 "$htssrv" 2>/dev/null || break
|
||||
sleep 0.25
|
||||
done
|
||||
test -n "${url:-}" || {
|
||||
echo "FAIL: htsserver did not start: $(cat "$srvlog")"
|
||||
exit 1
|
||||
}
|
||||
"$python" - "$url" <<'PY' || exit 1
|
||||
import re, sys, urllib.parse, urllib.request
|
||||
|
||||
url = sys.argv[1]
|
||||
form = urllib.request.urlopen(url + "server/index.html", timeout=20).read()
|
||||
m = re.search(rb'name="sid" value="([0-9a-f]+)"', form)
|
||||
if not m:
|
||||
sys.exit("FAIL: no session id in server/index.html")
|
||||
fields = [("sid", m.group(1).decode()), ("singlefile", "on"),
|
||||
("singlefilemax", "5000")]
|
||||
body = "&".join("%s=%s" % (k, urllib.parse.quote(v)) for k, v in fields)
|
||||
req = urllib.request.Request(url + "server/step4.html",
|
||||
data=body.encode("latin-1"), method="POST")
|
||||
page = urllib.request.urlopen(req, timeout=20).read().decode("latin-1")
|
||||
|
||||
|
||||
def textarea(name):
|
||||
m = re.search(r'<textarea name="%s".*?>(.*?)</textarea>' % name, page, re.S)
|
||||
if m is None:
|
||||
sys.exit("FAIL: no %s textarea in the rendered step4.html" % name)
|
||||
return m.group(1)
|
||||
|
||||
|
||||
cmd = textarea("command")
|
||||
for want in ("--single-file", "--single-file-max-size=5000"):
|
||||
if want not in cmd:
|
||||
sys.exit("FAIL: %s missing from the command line\n%s" % (want, cmd))
|
||||
ini = textarea("winprofile").replace("\r\n", "\n")
|
||||
for want in ("\nSingleFile=1\n", "\nSingleFileMaxSize=5000\n"):
|
||||
if want not in ini:
|
||||
sys.exit("FAIL: %r missing from winprofile.ini\n%s" % (want, ini))
|
||||
PY
|
||||
echo OK
|
||||
@@ -30,6 +30,7 @@ TEST_EXTENSIONS = .test
|
||||
TEST_LOG_COMPILER = $(BASH)
|
||||
TESTS = \
|
||||
00_runnable.test \
|
||||
01_engine-changes.test \
|
||||
01_engine-charset.test \
|
||||
01_engine-cmdline.test \
|
||||
01_engine-cmdline-split.test \
|
||||
@@ -189,6 +190,8 @@ TESTS = \
|
||||
89_webhttrack-error-overflow.test \
|
||||
90_webhttrack-checkbox-clear.test \
|
||||
91_webhttrack-directory.test \
|
||||
92_local-proxytrack-ndx-fields.test
|
||||
92_local-proxytrack-ndx-fields.test \
|
||||
93_local-changes.test \
|
||||
94_local-single-file.test
|
||||
|
||||
CLEANFILES = check-network_sh.cache
|
||||
|
||||
@@ -1571,6 +1571,167 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
if self.command != "HEAD":
|
||||
self.wfile.write(body)
|
||||
|
||||
# --changes (#714). Every route answers 200 with no validators, so the
|
||||
# transfer signal alone would call the whole site changed on pass 2; only a
|
||||
# payload comparison can tell stable.html and stable.bin from moved.*.
|
||||
def route_changes_index(self):
|
||||
links = "".join(
|
||||
'\t<a href="%s">%s</a>\n' % (name, name)
|
||||
for name in (
|
||||
"stable.html",
|
||||
"moved.html",
|
||||
"stable.bin",
|
||||
"moved.bin",
|
||||
"redir.html",
|
||||
"flaky.bin",
|
||||
"coded.bin",
|
||||
"codedstable.bin",
|
||||
"sized.html",
|
||||
"reset.bin",
|
||||
)
|
||||
)
|
||||
seen = self.refetch_pass()
|
||||
if seen == 1:
|
||||
links += '\t<a href="doomed.html">doomed</a>\n'
|
||||
else:
|
||||
links += '\t<a href="fresh.html">fresh</a>\n'
|
||||
# transient.html appears on pass 2 only, so pass 3 has a deletion of
|
||||
# its own to purge.
|
||||
if seen == 2:
|
||||
links += '\t<a href="transient.html">transient</a>\n'
|
||||
self.send_html(links)
|
||||
|
||||
def route_changes_stable(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-STABLE</p></body></html>", "text/html")
|
||||
|
||||
def route_changes_moved(self):
|
||||
pass1 = self.refetch_pass() == 1
|
||||
self.send_raw(
|
||||
b"<html><body><p>CHANGES-MOVED-V%d</p></body></html>" % (1 if pass1 else 2),
|
||||
"text/html",
|
||||
)
|
||||
|
||||
def route_changes_stable_bin(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(
|
||||
b"CHANGES-STABLE-BIN\n" + b"\x00\x01\x02\xff" * 512,
|
||||
"application/octet-stream",
|
||||
)
|
||||
|
||||
def route_changes_moved_bin(self):
|
||||
pass1 = self.refetch_pass() == 1
|
||||
self.send_raw(
|
||||
b"CHANGES-MOVED-BIN-V%d\n" % (1 if pass1 else 2)
|
||||
+ b"\x03\x02\x01\xfe" * 512,
|
||||
"application/octet-stream",
|
||||
)
|
||||
|
||||
def route_changes_doomed(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-DOOMED</p></body></html>", "text/html")
|
||||
|
||||
def route_changes_fresh(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-FRESH</p></body></html>", "text/html")
|
||||
|
||||
def route_changes_redir(self):
|
||||
self.send_response(302)
|
||||
self.send_header("Location", "/changes/redirtarget.html")
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
|
||||
def route_changes_redirtarget(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>CHANGES-REDIR</p></body></html>", "text/html")
|
||||
|
||||
# Direct-to-disk, and the first body fetch of each pass dies mid-transfer:
|
||||
# the retry notifies the same file a second time, so the accumulator has to
|
||||
# keep the pre-run sample from the first notify.
|
||||
FLAKY = b"CHANGES-FLAKY\n" + b"\x07\x06\x05\x04" * 512
|
||||
|
||||
# A page whose payload never changes, linking through a redirect whose
|
||||
# target is renamed between passes: the rewritten link makes the file on
|
||||
# disk change length while the payload is byte-identical. Only a payload
|
||||
# comparison can call it unchanged.
|
||||
SIZED_SHORT = "s.html"
|
||||
SIZED_LONG = "s" * 40 + ".html"
|
||||
|
||||
def route_changes_sized(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(
|
||||
b'<html><body><a href="sizedredir.html">t</a></body></html>',
|
||||
"text/html",
|
||||
)
|
||||
|
||||
def route_changes_sizedredir(self):
|
||||
target = self.SIZED_SHORT if self.refetch_pass() == 1 else self.SIZED_LONG
|
||||
self.send_response(302)
|
||||
self.send_header("Location", "/changes/" + target)
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
|
||||
def route_changes_sizedtarget(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(b"<html><body><p>SIZED-TARGET</p></body></html>", "text/html")
|
||||
|
||||
# Content-Encoding on a direct-to-disk body: the decoded temp is renamed
|
||||
# over the mirror file, so the previous copy has to be sampled before the
|
||||
# rename. Same length on both passes, so only a digest can tell them apart.
|
||||
def route_changes_coded(self):
|
||||
pass1 = self.refetch_pass() == 1
|
||||
body = b"CHANGES-CODED-V%d\n" % (1 if pass1 else 2) + b"\x11\x22" * 1024
|
||||
self.send_coded(self.gzipped(body), "application/octet-stream")
|
||||
|
||||
# Control: same coding, same bytes on both passes.
|
||||
def route_changes_coded_stable(self):
|
||||
self.refetch_pass()
|
||||
body = b"CHANGES-CODED-STABLE\n" + b"\x33\x44" * 1024
|
||||
self.send_coded(self.gzipped(body), "application/octet-stream")
|
||||
|
||||
def route_changes_flaky(self):
|
||||
if self.refetch_pass() % 2 == 1:
|
||||
self.send_truncated(self.FLAKY, "application/octet-stream")
|
||||
else:
|
||||
self.send_raw(self.FLAKY, "application/octet-stream")
|
||||
|
||||
def route_changes_transient(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(
|
||||
b"<html><body><p>CHANGES-TRANSIENT</p></body></html>", "text/html"
|
||||
)
|
||||
|
||||
# Answers once, then hangs up before sending anything on every later
|
||||
# attempt, retries included: nothing is written, so the file never reaches
|
||||
# new.lst while its mirrored copy stays intact.
|
||||
RESET = b"CHANGES-RESET\n" + b"\x21\x22\x23\x24" * 512
|
||||
|
||||
def route_changes_reset(self):
|
||||
if self.refetch_pass() == 1:
|
||||
self.send_raw(self.RESET, "application/octet-stream")
|
||||
else:
|
||||
self.close_connection = True
|
||||
self.connection.close()
|
||||
|
||||
# A second, independent mirror crawled with the cache off: nothing but the
|
||||
# bytes on disk can tell stable2 from ticker2, whose body differs every
|
||||
# fetch at a constant length.
|
||||
def route_changes2_index(self):
|
||||
self.refetch_pass()
|
||||
self.send_html('\t<a href="stable2.bin">s</a>\n\t<a href="ticker2.bin">t</a>\n')
|
||||
|
||||
def route_changes2_stable(self):
|
||||
self.refetch_pass()
|
||||
self.send_raw(
|
||||
b"CHANGES2-STABLE-00\n" + b"\x55\xaa" * 512, "application/octet-stream"
|
||||
)
|
||||
|
||||
def route_changes2_ticker(self):
|
||||
self.send_raw(
|
||||
b"CHANGES2-TICKER-%02d\n" % (self.refetch_pass() % 100) + b"\x55\xaa" * 512,
|
||||
"application/octet-stream",
|
||||
)
|
||||
|
||||
ROUTES = {
|
||||
"/cookies/entrance.php": route_entrance,
|
||||
"/cookies/second.php": route_second,
|
||||
@@ -1588,6 +1749,27 @@ class Handler(SimpleHTTPRequestHandler):
|
||||
"/codec/bad.html": route_codec_bad,
|
||||
"/codec/bin.dat": route_codec_bin,
|
||||
"/codec/ae.html": route_codec_ae,
|
||||
"/changes/index.html": route_changes_index,
|
||||
"/changes/stable.html": route_changes_stable,
|
||||
"/changes/moved.html": route_changes_moved,
|
||||
"/changes/stable.bin": route_changes_stable_bin,
|
||||
"/changes/moved.bin": route_changes_moved_bin,
|
||||
"/changes/doomed.html": route_changes_doomed,
|
||||
"/changes/fresh.html": route_changes_fresh,
|
||||
"/changes/redir.html": route_changes_redir,
|
||||
"/changes/redirtarget.html": route_changes_redirtarget,
|
||||
"/changes/flaky.bin": route_changes_flaky,
|
||||
"/changes/coded.bin": route_changes_coded,
|
||||
"/changes/sized.html": route_changes_sized,
|
||||
"/changes/sizedredir.html": route_changes_sizedredir,
|
||||
"/changes/" + SIZED_SHORT: route_changes_sizedtarget,
|
||||
"/changes/" + SIZED_LONG: route_changes_sizedtarget,
|
||||
"/changes/codedstable.bin": route_changes_coded_stable,
|
||||
"/changes/transient.html": route_changes_transient,
|
||||
"/changes/reset.bin": route_changes_reset,
|
||||
"/changes2/index.html": route_changes2_index,
|
||||
"/changes2/stable2.bin": route_changes2_stable,
|
||||
"/changes2/ticker2.bin": route_changes2_ticker,
|
||||
"/upcodec/index.html": route_upcodec_index,
|
||||
"/upcodec/mem.html": route_upcodec_mem,
|
||||
"/upcodec/disk.bin": route_upcodec_disk,
|
||||
|
||||
@@ -46,12 +46,17 @@ cat >"$stubdir/x-www-browser" <<EOF
|
||||
echo "stub browser invoked with: \$1" >&2
|
||||
# Also fetch an option page and require a rendered title='' tooltip: proves the
|
||||
# option template expands and the \${html:} filter escapes into the attribute.
|
||||
# option9 additionally proves the WARC control renders with its expanded label.
|
||||
# option9 additionally proves the WARC and change-report controls render with
|
||||
# their expanded labels, and option2 the --single-file pair: on field names plus
|
||||
# the absence of an unexpanded key, since the default locale here is French.
|
||||
opturl="\${1%/}/server/option2.html"
|
||||
warcurl="\${1%/}/server/option9.html"
|
||||
if body="\$(curl -fsSL --max-time 20 "\$1")" && printf '%s' "\$body" | grep -qai httrack && printf '%s' "\$body" | grep -qaF step2.html &&
|
||||
opt="\$(curl -fsSL --max-time 20 "\$opturl")" && printf '%s' "\$opt" | grep -qaF "title='" &&
|
||||
warc="\$(curl -fsSL --max-time 20 "\$warcurl")" && printf '%s' "\$warc" | grep -qaF 'name="warcfile"' && printf '%s' "\$warc" | grep -qaF WARC; then
|
||||
printf '%s' "\$opt" | grep -qaF 'name="singlefile"' && printf '%s' "\$opt" | grep -qaF 'name="singlefilemax"' &&
|
||||
! printf '%s' "\$opt" | grep -qaF '\${LANG_SINGLEFILE}' &&
|
||||
warc="\$(curl -fsSL --max-time 20 "\$warcurl")" && printf '%s' "\$warc" | grep -qaF 'name="warcfile"' && printf '%s' "\$warc" | grep -qaF WARC &&
|
||||
printf '%s' "\$warc" | grep -qaF 'name="changes"' && printf '%s' "\$warc" | grep -qaF hts-changes.json; then
|
||||
echo PASS >"$marker"
|
||||
else
|
||||
echo "FAIL: unexpected response from \$1" >"$marker"
|
||||
|
||||
Reference in New Issue
Block a user