1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! AppleScript double-quoted string-literal escaping.
//!
//! The grammar (Apple TN2065, *do shell script in AppleScript*) is small: inside a
//! `"…"` literal, `\"` is a quote and `\\` is a backslash, and `\n`/`\r`/`\t` are
//! the three character escapes.
//!
//! AppleScript source is decoded as UTF-8, so this operates on text, not bytes;
//! non-UTF-8 input is a typed error.
use crate;
/// Escape `bytes` as the BODY of an AppleScript double-quoted string literal. The
/// surrounding quotes are the caller's to add.
///
/// Only NUL is refused. It is the one byte with no representation anywhere on this
/// path — it cannot appear in argv at all, since exec takes NUL-terminated strings.
/// Every other control passes through raw: `\n` and `\r` are escaped above for a
/// MEASURED reason (a raw newline ends an AppleScript statement), but nothing shows
/// ESC/BEL/VT/FF/DEL failing inside a literal, and "no numeric escape exists" does
/// not imply "no representation exists". Refusing them would refuse an
/// ANSI-coloured argument that succeeds under sudo, pkexec and UAC, on an
/// inference; `both_quoting_layers_survive_a_real_osascript_round_trip` drives them
/// through real `osascript` instead.