katex 0.16.9 → 0.16.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils.js CHANGED
@@ -93,11 +93,30 @@ export const assert = function<T>(value: ?T): T {
93
93
 
94
94
  /**
95
95
  * Return the protocol of a URL, or "_relative" if the URL does not specify a
96
- * protocol (and thus is relative).
96
+ * protocol (and thus is relative), or `null` if URL has invalid protocol
97
+ * (so should be outright rejected).
97
98
  */
98
- export const protocolFromUrl = function(url: string): string {
99
- const protocol = /^\s*([^\\/#]*?)(?::|&#0*58|&#x0*3a)/i.exec(url);
100
- return (protocol != null ? protocol[1] : "_relative");
99
+ export const protocolFromUrl = function(url: string): string | null {
100
+ // Check for possible leading protocol.
101
+ // https://url.spec.whatwg.org/#url-parsing strips leading whitespace
102
+ // (U+20) or C0 control (U+00-U+1F) characters.
103
+ // eslint-disable-next-line no-control-regex
104
+ const protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i
105
+ .exec(url);
106
+ if (!protocol) {
107
+ return "_relative";
108
+ }
109
+ // Reject weird colons
110
+ if (protocol[2] !== ":") {
111
+ return null;
112
+ }
113
+ // Reject invalid characters in scheme according to
114
+ // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1
115
+ if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) {
116
+ return null;
117
+ }
118
+ // Lowercase the protocol
119
+ return protocol[1].toLowerCase();
101
120
  };
102
121
 
103
122
  export default {
package/src/fonts.less DELETED
@@ -1,64 +0,0 @@
1
- @font-folder: "../fonts";
2
- @use-ttf: true;
3
- @use-woff: true;
4
- @use-woff2: true;
5
-
6
- .use-woff2(@family, @family-suffix) when (@use-woff2 = true) {
7
- src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff2') format('woff2')
8
- }
9
-
10
- .use-woff(@family, @family-suffix) when (@use-woff = true) {
11
- src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff') format('woff')
12
- }
13
-
14
- .use-ttf(@family, @family-suffix) when (@use-ttf = true) {
15
- src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.ttf') format('truetype')
16
- }
17
-
18
- .generate-suffix(@weight, @style) when (@weight = normal) and (@style = normal) {
19
- @suffix: 'Regular';
20
- }
21
- .generate-suffix(@weight, @style) when (@weight = normal) and (@style = italic) {
22
- @suffix: 'Italic';
23
- }
24
- .generate-suffix(@weight, @style) when (@weight = bold) and (@style = normal) {
25
- @suffix: 'Bold';
26
- }
27
- .generate-suffix(@weight, @style) when (@weight = bold) and (@style = italic) {
28
- @suffix: 'BoldItalic';
29
- }
30
-
31
- .font-face(@family, @weight, @style) {
32
- .generate-suffix(@weight, @style);
33
- @font-face {
34
- font-family: 'KaTeX_@{family}';
35
- .use-woff2(@family, @suffix);
36
- .use-woff(@family, @suffix);
37
- .use-ttf(@family, @suffix);
38
- font-weight: @weight;
39
- font-style: @style;
40
- }
41
- }
42
-
43
- .font-face('AMS', normal, normal);
44
- .font-face('Caligraphic', bold, normal);
45
- .font-face('Caligraphic', normal, normal);
46
- .font-face('Fraktur', bold, normal);
47
- .font-face('Fraktur', normal, normal);
48
- .font-face('Main', bold, normal);
49
- .font-face('Main', bold, italic);
50
- .font-face('Main', normal, italic);
51
- .font-face('Main', normal, normal);
52
- //.font-face('Math', bold, normal);
53
- .font-face('Math', bold, italic);
54
- .font-face('Math', normal, italic);
55
- //.font-face('Math', normal, normal);
56
- .font-face('SansSerif', bold, normal);
57
- .font-face('SansSerif', normal, italic);
58
- .font-face('SansSerif', normal, normal);
59
- .font-face('Script', normal, normal);
60
- .font-face('Size1', normal, normal);
61
- .font-face('Size2', normal, normal);
62
- .font-face('Size3', normal, normal);
63
- .font-face('Size4', normal, normal);
64
- .font-face('Typewriter', normal, normal);