mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
[breaking] trust setting to indicate whether input text is trusted (#1794)
* trust option to indicate whether input text is trusted * Revamp into trust contexts beyond just command * Document new trust function style * Fix screenshot testing * Use trust setting in \url and \href * Check `isTrusted` in `\url` and `\href` (so now disabled by default) * Automatically compute `protocol` from `url` in `isTrusted`, so it doesn't need to be passed into every context. * Document untrusted features in support list/table * Existing tests trust by default * remove allowedProtocols and fix flow errors * remove 'allowedProtocols' from documentation * add a comment about a flow error, rename urlToProtocol to protocolFromUrl * add tests test that use function version of trust option * default trust to false in MathML tests * fix test title, remove 'trust: false' from test settings since it's the default
This commit is contained in:
committed by
Kevin Barabash
parent
fc79f79c78
commit
3800dc49c1
@@ -970,6 +970,151 @@ exports[`Newlines via \\\\ and \\newline \\\\ causes newline, even after mrel an
|
||||
|
||||
`;
|
||||
|
||||
exports[`href and url commands should allow all protocols when trust option is true 1`] = `
|
||||
[
|
||||
{
|
||||
"type": "href",
|
||||
"body": [
|
||||
{
|
||||
"type": "mathord",
|
||||
"loc": {
|
||||
"end": 16,
|
||||
"lexer": {
|
||||
"input": "\\\\href{ftp://x}{foo}",
|
||||
"lastIndex": 19
|
||||
},
|
||||
"start": 15
|
||||
},
|
||||
"mode": "math",
|
||||
"text": "f"
|
||||
},
|
||||
{
|
||||
"type": "mathord",
|
||||
"loc": {
|
||||
"end": 17,
|
||||
"lexer": {
|
||||
"input": "\\\\href{ftp://x}{foo}",
|
||||
"lastIndex": 19
|
||||
},
|
||||
"start": 16
|
||||
},
|
||||
"mode": "math",
|
||||
"text": "o"
|
||||
},
|
||||
{
|
||||
"type": "mathord",
|
||||
"loc": {
|
||||
"end": 18,
|
||||
"lexer": {
|
||||
"input": "\\\\href{ftp://x}{foo}",
|
||||
"lastIndex": 19
|
||||
},
|
||||
"start": 17
|
||||
},
|
||||
"mode": "math",
|
||||
"text": "o"
|
||||
}
|
||||
],
|
||||
"href": "ftp://x",
|
||||
"mode": "math"
|
||||
}
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`href and url commands should allow explicitly allowed protocols 1`] = `
|
||||
[
|
||||
{
|
||||
"type": "href",
|
||||
"body": [
|
||||
{
|
||||
"type": "mathord",
|
||||
"loc": {
|
||||
"end": 16,
|
||||
"lexer": {
|
||||
"input": "\\\\href{ftp://x}{foo}",
|
||||
"lastIndex": 19
|
||||
},
|
||||
"start": 15
|
||||
},
|
||||
"mode": "math",
|
||||
"text": "f"
|
||||
},
|
||||
{
|
||||
"type": "mathord",
|
||||
"loc": {
|
||||
"end": 17,
|
||||
"lexer": {
|
||||
"input": "\\\\href{ftp://x}{foo}",
|
||||
"lastIndex": 19
|
||||
},
|
||||
"start": 16
|
||||
},
|
||||
"mode": "math",
|
||||
"text": "o"
|
||||
},
|
||||
{
|
||||
"type": "mathord",
|
||||
"loc": {
|
||||
"end": 18,
|
||||
"lexer": {
|
||||
"input": "\\\\href{ftp://x}{foo}",
|
||||
"lastIndex": 19
|
||||
},
|
||||
"start": 17
|
||||
},
|
||||
"mode": "math",
|
||||
"text": "o"
|
||||
}
|
||||
],
|
||||
"href": "ftp://x",
|
||||
"mode": "math"
|
||||
}
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`href and url commands should forbid relative URLs when trust option is false 1`] = `
|
||||
[
|
||||
{
|
||||
"type": "color",
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"body": [
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "\\\\"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "h"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "r"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "e"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "f"
|
||||
}
|
||||
],
|
||||
"mode": "math"
|
||||
}
|
||||
],
|
||||
"color": "#cc0000",
|
||||
"mode": "math"
|
||||
}
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`href and url commands should not affect spacing around 1`] = `
|
||||
[
|
||||
{
|
||||
@@ -1062,3 +1207,46 @@ exports[`href and url commands should not affect spacing around 1`] = `
|
||||
}
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`href and url commands should not allow explicitly disallow protocols 1`] = `
|
||||
[
|
||||
{
|
||||
"type": "color",
|
||||
"body": [
|
||||
{
|
||||
"type": "text",
|
||||
"body": [
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "\\\\"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "h"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "r"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "e"
|
||||
},
|
||||
{
|
||||
"type": "textord",
|
||||
"mode": "text",
|
||||
"text": "f"
|
||||
}
|
||||
],
|
||||
"mode": "math"
|
||||
}
|
||||
],
|
||||
"color": "#cc0000",
|
||||
"mode": "math"
|
||||
}
|
||||
]
|
||||
`;
|
||||
|
Reference in New Issue
Block a user