Skip to content

Commit 120baf4

Browse files
authored
python3Packages.django-mdeditor: patch out polyfill.io usage, bump KaTeX (#347565)
2 parents af65342 + ced695a commit 120baf4

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From c5af641cccf663dffb4a47d32e28404f609badce Mon Sep 17 00:00:00 2001
2+
From: Tomo <tomodachi94@protonmail.com>
3+
Date: Sat, 12 Oct 2024 03:39:12 +0000
4+
Subject: [PATCH 1/2] chore(KaTeX): bump to 0.7.1
5+
6+
Many bugfixes. This KaTeX is still quite old,
7+
but versions beyond this have backwards-incompatibilities
8+
(starting in 0.8).
9+
---
10+
mdeditor/static/mdeditor/js/editormd.js | 4 ++--
11+
1 file changed, 2 insertions(+), 2 deletions(-)
12+
13+
diff --git a/mdeditor/static/mdeditor/js/editormd.js b/mdeditor/static/mdeditor/js/editormd.js
14+
index be0005d..8aacb56 100644
15+
--- a/mdeditor/static/mdeditor/js/editormd.js
16+
+++ b/mdeditor/static/mdeditor/js/editormd.js
17+
@@ -4179,8 +4179,8 @@
18+
// 使用国外的CDN,加载速度有时会很慢,或者自定义URL
19+
// You can custom KaTeX load url.
20+
editormd.katexURL = {
21+
- css : "//cdn.bootcdn.net/ajax/libs/KaTeX/0.3.0/katex.min",
22+
- js : "//cdn.bootcdn.net/ajax/libs/KaTeX/0.3.0/katex.min"
23+
+ css : "//cdn.bootcdn.net/ajax/libs/KaTeX/0.7.1/katex.min",
24+
+ js : "//cdn.bootcdn.net/ajax/libs/KaTeX/0.7.1/katex.min"
25+
};
26+
27+
editormd.kaTeXLoaded = false;
28+
--
29+
2.46.2
30+
31+
32+
From 3d082a738262b057d33b9aa8c777d50113143952 Mon Sep 17 00:00:00 2001
33+
From: Tomo <tomodachi94@protonmail.com>
34+
Date: Mon, 7 Oct 2024 17:44:39 -0700
35+
Subject: [PATCH 2/2] fix(KaTeX): Use jsdelivr instead of bootcdn
36+
37+
Bootcdn was compromised by a malicious actor:
38+
https://sansec.io/research/polyfill-supply-chain-attack
39+
40+
KaTeX recommends using jsdelivr, so I used that:
41+
https://katex.org/docs/browser
42+
---
43+
mdeditor/static/mdeditor/js/editormd.js | 4 ++--
44+
1 file changed, 2 insertions(+), 2 deletions(-)
45+
46+
diff --git a/mdeditor/static/mdeditor/js/editormd.js b/mdeditor/static/mdeditor/js/editormd.js
47+
index 8aacb56..a31e817 100644
48+
--- a/mdeditor/static/mdeditor/js/editormd.js
49+
+++ b/mdeditor/static/mdeditor/js/editormd.js
50+
@@ -4179,8 +4179,8 @@
51+
// 使用国外的CDN,加载速度有时会很慢,或者自定义URL
52+
// You can custom KaTeX load url.
53+
editormd.katexURL = {
54+
- css : "//cdn.bootcdn.net/ajax/libs/KaTeX/0.7.1/katex.min",
55+
- js : "//cdn.bootcdn.net/ajax/libs/KaTeX/0.7.1/katex.min"
56+
+ css : "//cdn.jsdelivr.net/npm/katex@0.7.1/dist/katex.min.css",
57+
+ js : "//cdn.jsdelivr.net/npm/katex@0.7.1/dist/katex.min.js"
58+
};
59+
60+
editormd.kaTeXLoaded = false;
61+
--
62+
2.46.2
63+

pkgs/development/python-modules/django-mdeditor/default.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ buildPythonPackage {
1818
hash = "sha256-t57j1HhjNQtBwlbqe4mAHQ9WiNcIhMKYmrZkiqh+k5k=";
1919
};
2020

21+
patches = [
22+
./Bump-KaTeX-and-replace-bootcdn-with-jsdelivr.patch
23+
];
24+
2125
propagatedBuildInputs = [ django ];
2226

2327
# no tests

0 commit comments

Comments
 (0)