Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-090
A link is an anchor, external, local or blocked
When a link request is followed or looked up, the extension SHALL classify it before any file access as an anchor, an external link or a relative or wiki path, and block it with a reason when it is an invalid anchor, a query-only target, an undecodable path, a scheme other than http, https or mailto, or an absolute path. The scheme is read on the raw link, and the host re-checks the parsed URI before opening it.
Another outcome at step 3 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-011, in the state “The tooltip names where the link leads”.
Scenarios 3
The situations the tests check; open one to read it.
nominalAccepted requests
| Request | Class |
|---|---|
| #section-2 | anchor with that value (a # followed by at least one character and no space, # or ?) |
| https://example.test/docs | external |
| MAILTO:a@b.c | external (http, https and mailto in any letter case) |
| ../docs/target.md | relative, not blocked at this step |
| tmp/secret.md | relative |
| other.md?view=1 | relative, keeps its query |
refusalBlocked requests
| Request | Outcome |
|---|---|
| #, #not a valid anchor, #a#b | blocked with The preview anchor is invalid. |
| javascript:alert(1), file:///tmp/secret | blocked with The navigation scheme is not allowed in the preview. |
| wiki:https://example.test | blocked, because a wiki link is never external |
| https%3A/../../System/Applications/Calculator.app, mailto%3Aa@b.c | blocked with The navigation scheme is not allowed in the preview. (the scheme is read on the raw link; a percent sign before the first colon is never external) |
| /tmp/secret, //example.test | blocked with Absolute navigation targets are not allowed. |
| ?x=1 | blocked with Query-only navigation targets are not valid file links. |
| %5Csecret, %00.md (backslash or NUL after decoding) | blocked with The navigation target could not be decoded safely. |
| a%zz.md (malformed escape) | blocked with The navigation target could not be decoded safely. |
A blocked request causes no file access.
boundaryDecoding once
| Request | Outcome |
|---|---|
| docs%20file.md | relative with the path docs file.md |
| docs%2520file.md | relative with the path docs%20file.md (the escaped percent is a literal percent in the file name, it is not decoded again) |
| 100%25.md | relative with the path 100%.md |
| a%2541.md | relative with the path a%41.md |
| %255Csecret | relative with the path %5Csecret (only a backslash decoded from the link itself is refused) |