Skip to content

Commit 715d50d

Browse files
authored
fix(plugin): sanitize markdown and prevent horizontal overflow (#1782)
1 parent d6b77e5 commit 715d50d

File tree

3 files changed

+56
-10
lines changed

3 files changed

+56
-10
lines changed

src/pages/plugin/plugin.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,26 @@
268268
display: block;
269269
}
270270

271+
.content-section.md {
272+
overflow-x: hidden;
273+
overflow-wrap: break-word;
274+
275+
img {
276+
max-width: 100%;
277+
height: auto;
278+
}
279+
280+
pre {
281+
overflow-x: auto;
282+
max-width: 100%;
283+
}
284+
285+
* {
286+
max-width: 100%;
287+
box-sizing: border-box;
288+
}
289+
}
290+
271291
.contributor {
272292
display: flex;
273293
align-items: center;

src/pages/plugin/plugin.view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default (props) => {
186186
<div
187187
id="overview"
188188
className="content-section active md"
189-
innerHTML={DOMPurify.sanitize(body)}
189+
innerHTML={DOMPurify.sanitize(body, { FORBID_TAGS: ["style"] })}
190190
></div>
191191
<div id="contributors" className="content-section">
192192
{(() => {
@@ -223,7 +223,7 @@ export default (props) => {
223223
id="changelog"
224224
className="content-section md"
225225
innerHTML={
226-
DOMPurify.sanitize(changelogs) ||
226+
DOMPurify.sanitize(changelogs, { FORBID_TAGS: ["style"] }) ||
227227
`
228228
<div class="no-changelog">
229229
<i class="icon historyrestore"></i>

src/styles/markdown.scss

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,10 @@
119119

120120
hr {
121121
display: block;
122-
height: 2px;
122+
height: 0;
123123
border: 0;
124-
border-top: 1px solid #aaa;
125-
border-bottom: 1px solid #eee;
126-
margin: 1em 0;
124+
border-top: 1px solid var(--border-color, #3d444d);
125+
margin: 1.5em 0;
127126
padding: 0;
128127
}
129128

@@ -253,6 +252,30 @@
253252
table {
254253
border-collapse: collapse;
255254
border-spacing: 0;
255+
width: 100%;
256+
margin: 1em 0;
257+
display: block;
258+
overflow-x: auto;
259+
260+
th,
261+
td {
262+
padding: 8px 12px;
263+
border: 1px solid var(--border-color, #3d444d);
264+
text-align: left;
265+
}
266+
267+
th {
268+
background-color: rgba(255, 255, 255, 0.05);
269+
font-weight: 600;
270+
}
271+
272+
tr:nth-child(even) {
273+
background-color: rgba(255, 255, 255, 0.02);
274+
}
275+
276+
tr:hover {
277+
background-color: rgba(255, 255, 255, 0.05);
278+
}
256279
}
257280

258281
td {
@@ -344,18 +367,19 @@
344367
page-break-after: avoid;
345368
}
346369
}
370+
347371
.markdown-alert {
348372
padding: 0.5rem 1rem;
349373
margin-bottom: 16px;
350374
color: inherit;
351375
border-left: 0.25em solid #888;
352376
}
353377

354-
.markdown-alert > :first-child {
378+
.markdown-alert> :first-child {
355379
margin-top: 0;
356380
}
357381

358-
.markdown-alert > :last-child {
382+
.markdown-alert> :last-child {
359383
margin-bottom: 0;
360384
}
361385

@@ -413,6 +437,7 @@
413437
.markdown-alert.markdown-alert-caution .markdown-alert-title {
414438
color: var(--color-caution);
415439
}
440+
416441
.task-list-item {
417442
list-style-type: none;
418443

@@ -424,7 +449,7 @@
424449
cursor: pointer;
425450
}
426451

427-
& + .task-list-item {
452+
&+.task-list-item {
428453
margin-top: 0.25rem;
429454
}
430455

@@ -446,6 +471,7 @@
446471
}
447472

448473
.contains-task-list {
474+
449475
&:hover .task-list-item-convert-container,
450476
&:focus-within .task-list-item-convert-container {
451477
display: block;
@@ -455,4 +481,4 @@
455481
clip: auto;
456482
}
457483
}
458-
}
484+
}

0 commit comments

Comments
 (0)