Skip to content

Commit 664eb5a

Browse files
authored
Merge pull request #888 from pkgw/pipe-input-workaround
Warn on attempted pipe inputs
2 parents 5397e4e + 5df1bf6 commit 664eb5a

5 files changed

Lines changed: 53 additions & 25 deletions

File tree

crates/bundles/src/itar.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,35 +159,40 @@ impl CacheBackend for IndexedTarBackend {
159159
let mut overall_failed = true;
160160
let mut any_failed = false;
161161

162-
for _ in 0..MAX_HTTP_ATTEMPTS {
163-
let mut stream = match self.reader.read_range(info.offset, n) {
164-
Ok(r) => r,
165-
Err(e) => {
166-
tt_warning!(status, "failure requesting \"{}\" from network", name; e);
162+
// Our HTTP implementation actually has problems with zero-sized ranged
163+
// reads (Azure gives us a 200 response, which we don't properly
164+
// handle), but when the file is 0-sized we're all set anyway!
165+
if n > 0 {
166+
for _ in 0..MAX_HTTP_ATTEMPTS {
167+
let mut stream = match self.reader.read_range(info.offset, n) {
168+
Ok(r) => r,
169+
Err(e) => {
170+
tt_warning!(status, "failure requesting \"{}\" from network", name; e);
171+
any_failed = true;
172+
continue;
173+
}
174+
};
175+
176+
if let Err(e) = stream.read_to_end(&mut buf) {
177+
tt_warning!(status, "failure downloading \"{}\" from network", name; e.into());
167178
any_failed = true;
168179
continue;
169180
}
170-
};
171181

172-
if let Err(e) = stream.read_to_end(&mut buf) {
173-
tt_warning!(status, "failure downloading \"{}\" from network", name; e.into());
174-
any_failed = true;
175-
continue;
182+
overall_failed = false;
183+
break;
176184
}
177185

178-
overall_failed = false;
179-
break;
180-
}
181-
182-
if overall_failed {
183-
bail!(
184-
"failed to retrieve \"{}\" from the network; \
185-
this most probably is not Tectonic's fault \
186-
-- please check your network connection.",
187-
name
188-
);
189-
} else if any_failed {
190-
tt_note!(status, "download succeeded after retry");
186+
if overall_failed {
187+
bail!(
188+
"failed to retrieve \"{}\" from the network; \
189+
this most probably is not Tectonic's fault \
190+
-- please check your network connection.",
191+
name
192+
);
193+
} else if any_failed {
194+
tt_note!(status, "download succeeded after retry");
195+
}
191196
}
192197

193198
Ok(buf)

crates/engine_xetex/xetex/xetex-io.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@ tt_xetex_open_input (int filefmt)
2424
{
2525
rust_input_handle_t handle;
2626

27-
if (filefmt == TTBC_FILE_FORMAT_TECTONIC_PRIMARY)
27+
if (filefmt == TTBC_FILE_FORMAT_TECTONIC_PRIMARY) {
2828
handle = ttstub_input_open_primary ();
29-
else
29+
} else if (name_of_file[0] == '|') {
30+
// Tectonic TODO: issue #859. In mainline XeTeX, a pipe symbol indicates
31+
// piped input from an external command via `popen()`. Now that we have
32+
// shell-escape support we could also support this, but we don't have a
33+
// real implementation yet. For now, issue a warning.
34+
print_nl_cstr("Warning: ");
35+
diagnostic_begin_capture_warning_here();
36+
print_cstr("piped inputs from external commands are not implemented in Tectonic");
37+
capture_to_diagnostic(NULL);
38+
return NULL;
39+
} else {
3040
handle = ttstub_input_open (name_of_file, (ttbc_file_format) filefmt, 0);
41+
}
3142

3243
if (handle == NULL)
3344
return NULL;

tests/tex-outputs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ fn pdfoutput() {
288288
TestCase::new("pdfoutput").go()
289289
}
290290

291+
#[test]
292+
fn pipe_input() {
293+
TestCase::new("pipe_input")
294+
.expect_msg("failed to open input file \"|pipeproblems\"")
295+
.go()
296+
}
297+
291298
#[test]
292299
fn png_formats() {
293300
TestCase::new("png_formats").check_pdf(true).go()

tests/tex-outputs/pipe_input.log

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**
2+
(pipe_input.tex
3+
Warning: piped inputs from external commands are not implemented in Tectonic

tests/tex-outputs/pipe_input.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
\input{|pipeproblems}
2+
\end

0 commit comments

Comments
 (0)