| 1 |
Absolute paths cause an error. |
| 2 |
|
| 3 |
$ set_version () { |
| 4 |
> sed -i.bak "s/using mdx .../using mdx $1/" dune-project |
| 5 |
> } |
| 6 |
|
| 7 |
$ cat > dune-project << EOF |
| 8 |
> (lang dune 3.2) |
| 9 |
> (using mdx ---) |
| 10 |
> EOF |
| 11 |
$ set_version 0.2 |
| 12 |
$ cat > dune << EOF |
| 13 |
> (mdx) |
| 14 |
> EOF |
| 15 |
|
| 16 |
$ cat > README.md << 'EOF' |
| 17 |
> ```ocaml file=/etc/passwd |
| 18 |
> ``` |
| 19 |
> EOF |
| 20 |
|
| 21 |
$ dune runtest |
| 22 |
File "dune", line 1, characters 0-5: |
| 23 |
1 | (mdx) |
| 24 |
^^^^^ |
| 25 |
Error: Paths referenced in mdx files must be relative. This stanza refers to |
| 26 |
the following absolute path: |
| 27 |
Source path: README.md |
| 28 |
Included path: /etc/passwd |
| 29 |
[1] |
| 30 |
|
| 31 |
Relative paths that go over the root cause an error. |
| 32 |
|
| 33 |
$ cat > README.md << 'EOF' |
| 34 |
> ```ocaml file=../x |
| 35 |
> ``` |
| 36 |
> EOF |
| 37 |
|
| 38 |
$ dune runtest |
| 39 |
File "dune", line 1, characters 0-5: |
| 40 |
1 | (mdx) |
| 41 |
^^^^^ |
| 42 |
Error: Paths referenced in mdx files must stay within the workspace. This |
| 43 |
stanza refers to the following path which escapes: |
| 44 |
Source path: README.md |
| 45 |
Included path: ../x |
| 46 |
[1] |
| 47 |
|
| 48 |
Relative paths within the workspace do not work. |
| 49 |
|
| 50 |
$ mkdir a b |
| 51 |
$ mv dune a/ |
| 52 |
$ rm README.md |
| 53 |
$ cat > b/src.ml << EOF |
| 54 |
> let x = 1 |
| 55 |
> EOF |
| 56 |
|
| 57 |
$ cat > a/README.md << 'EOF' |
| 58 |
> ```ocaml file=../b/src.ml |
| 59 |
> ``` |
| 60 |
> EOF |
| 61 |
|
| 62 |
$ dune runtest |
| 63 |
File "a/dune", line 1, characters 0-5: |
| 64 |
1 | (mdx) |
| 65 |
^^^^^ |
| 66 |
Error: Paths referenced in mdx files cannot escape the directory. This stanza |
| 67 |
refers to the following path which escapes: |
| 68 |
Source path: a/README.md |
| 69 |
Included path: ../b/src.ml |
| 70 |
[1] |
| 71 |
|
| 72 |
But this works with stanza 0.3: |
| 73 |
|
| 74 |
$ set_version 0.3 |
| 75 |
$ dune runtest |
| 76 |
File "a/README.md", line 1, characters 0-0: |
| 77 |
--- a/README.md |
| 78 |
+++ a/.mdx/README.md.corrected |
| 79 |
@@ -1,2 +1,3 @@ |
| 80 |
```ocaml file=../b/src.ml |
| 81 |
+let x = 1 |
| 82 |
``` |
| 83 |
[1] |
| 84 |
$ set_version 0.2 |
| 85 |
|
| 86 |
Files in the same directory work. |
| 87 |
|
| 88 |
$ mv b/src.ml a/ |
| 89 |
$ cat > a/README.md << 'EOF' |
| 90 |
> ```ocaml file=src.ml |
| 91 |
> ``` |
| 92 |
> EOF |
| 93 |
|
| 94 |
$ dune runtest |
| 95 |
File "a/README.md", line 1, characters 0-0: |
| 96 |
--- a/README.md |
| 97 |
+++ a/.mdx/README.md.corrected |
| 98 |
@@ -1,2 +1,3 @@ |
| 99 |
```ocaml file=src.ml |
| 100 |
+let x = 1 |
| 101 |
``` |
| 102 |
[1] |
| 103 |
|
| 104 |
From a subdirectory too: |
| 105 |
|
| 106 |
$ mkdir a/sub/ |
| 107 |
$ mv a/src.ml a/sub/ |
| 108 |
$ cat > a/README.md << 'EOF' |
| 109 |
> ```ocaml file=sub/src.ml |
| 110 |
> ``` |
| 111 |
> EOF |
| 112 |
|
| 113 |
$ dune runtest |
| 114 |
File "a/README.md", line 1, characters 0-0: |
| 115 |
--- a/README.md |
| 116 |
+++ a/.mdx/README.md.corrected |
| 117 |
@@ -1,2 +1,3 @@ |
| 118 |
```ocaml file=sub/src.ml |
| 119 |
+let x = 1 |
| 120 |
``` |
| 121 |
[1] |