Skip to content

Commit 275264b

Browse files
authored
Merge branch 'master' into payload_size_limit
2 parents 3db9d0e + 4924ee4 commit 275264b

File tree

21 files changed

+63
-34
lines changed

21 files changed

+63
-34
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"array-move": "^4.0.0",
4848
"browserfs": "^1.4.3",
4949
"classnames": "^2.3.2",
50+
"dompurify": "^3.1.6",
5051
"flexboxgrid": "^6.3.1",
5152
"flexboxgrid-helpers": "^1.1.3",
5253
"hastscript": "^9.0.0",
@@ -109,6 +110,7 @@
109110
"@testing-library/jest-dom": "^6.0.0",
110111
"@testing-library/react": "^14.0.0",
111112
"@testing-library/user-event": "^14.4.3",
113+
"@types/dompurify": "^3.0.5",
112114
"@types/estree": "^1.0.5",
113115
"@types/gapi": "^0.0.44",
114116
"@types/gapi.auth2": "^0.0.57",

src/commons/Markdown.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Classes } from '@blueprintjs/core';
22
import classNames from 'classnames';
3+
import DOMPurify from 'dompurify';
34
import React from 'react';
45
import { Converter } from 'showdown';
56

@@ -24,7 +25,12 @@ const Markdown: React.FC<Props> = props => {
2425
return (
2526
<div
2627
className={classNames(props.className ? props.className : 'md', Classes.RUNNING_TEXT)}
27-
dangerouslySetInnerHTML={{ __html: converter.makeHtml(props.content) }}
28+
dangerouslySetInnerHTML={{
29+
__html: DOMPurify.sanitize(converter.makeHtml(props.content), {
30+
USE_PROFILES: { html: true },
31+
ADD_ATTR: ['target']
32+
})
33+
}}
2834
/>
2935
);
3036
};

src/commons/__tests__/__snapshots__/Markdown.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ exports[`Markdown page renders correctly 1`] = `
66
dangerouslySetInnerHTML={
77
Object {
88
"__html": "<p>Welcome to the Source Academy playground!</p>
9-
<p>The book <a href=\\"https://sourceacademy.org/sicpjs/\\" rel=\\"noopener noreferrer\\" target=\\"_blank\\"><em>Structure and Interpretation of Computer Programs, JavaScript Edition</em></a>
10-
uses JavaScript sublanguages that we call <a href=\\"https://docs.sourceacademy.org/\\" rel=\\"noopener noreferrer\\" target=\\"_blank\\"><em>Source</em></a>. You have chosen the sublanguage <a href=\\"https://docs.sourceacademy.org/source_1/\\" rel=\\"noopener noreferrer\\" target=\\"_blank\\"><em>Source §1</em></a>.</p>
11-
<p>In the editor on the left, you can use the <a href=\\"https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts\\" rel=\\"noopener noreferrer\\" target=\\"_blank\\"><em>Ace keyboard shortcuts</em></a>
12-
and also the <a href=\\"https://github.com/source-academy/frontend/wiki/Source-Academy-Keyboard-Shortcuts\\" rel=\\"noopener noreferrer\\" target=\\"_blank\\"><em>Source Academy keyboard shortcuts</em></a>.</p>",
9+
<p>The book <a target=\\"_blank\\" rel=\\"noopener noreferrer\\" href=\\"https://sourceacademy.org/sicpjs/\\"><em>Structure and Interpretation of Computer Programs, JavaScript Edition</em></a>
10+
uses JavaScript sublanguages that we call <a target=\\"_blank\\" rel=\\"noopener noreferrer\\" href=\\"https://docs.sourceacademy.org/\\"><em>Source</em></a>. You have chosen the sublanguage <a target=\\"_blank\\" rel=\\"noopener noreferrer\\" href=\\"https://docs.sourceacademy.org/source_1/\\"><em>Source §1</em></a>.</p>
11+
<p>In the editor on the left, you can use the <a target=\\"_blank\\" rel=\\"noopener noreferrer\\" href=\\"https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts\\"><em>Ace keyboard shortcuts</em></a>
12+
and also the <a target=\\"_blank\\" rel=\\"noopener noreferrer\\" href=\\"https://github.com/source-academy/frontend/wiki/Source-Academy-Keyboard-Shortcuts\\"><em>Source Academy keyboard shortcuts</em></a>.</p>",
1313
}
1414
}
1515
/>

src/commons/assessment/__tests__/Assessment.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Store } from '@reduxjs/toolkit';
2-
import { act, render, screen } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
3+
import { act } from 'react';
34
import { Provider } from 'react-redux';
45
import { createMemoryRouter, RouterProvider } from 'react-router';
56
import { OverallState, Role } from 'src/commons/application/ApplicationTypes';

src/commons/assessmentWorkspace/__tests__/AssessmentWorkspace.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { act, render, screen } from '@testing-library/react';
1+
import { render, screen } from '@testing-library/react';
2+
import { act } from 'react';
23
import { Provider } from 'react-redux';
34
import { createMemoryRouter, RouterProvider } from 'react-router';
45
import { mockInitialStore } from 'src/commons/mocks/StoreMocks';

src/commons/gitHubOverlay/__tests__/FileExplorerDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Octokit } from '@octokit/rest';
2-
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
2+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3+
import { act } from 'react';
34

45
import * as GitHubUtils from '../../../features/github/GitHubUtils';
56
import FileExplorerDialog from '../FileExplorerDialog';

src/commons/gitHubOverlay/__tests__/RepositoryDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { act, fireEvent, render, screen } from '@testing-library/react';
1+
import { fireEvent, render, screen } from '@testing-library/react';
2+
import { act } from 'react';
23

34
import * as NotificationHelper from '../../utils/notifications/NotificationsHelper';
45
import RepositoryDialog from '../RepositoryDialog';

src/commons/navigationBar/subcomponents/AcademyNavigationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const getStaffNavlinkInfo = ({
9191
to: `/courses/${courseId}/groundcontrol`,
9292
icon: IconNames.SATELLITE,
9393
text: 'Ground Control',
94-
disabled: !isStaffOrAdmin,
94+
disabled: !isAdmin,
9595
hiddenInBreakpoints: ['xs', 'sm']
9696
},
9797
{

src/commons/navigationBar/subcomponents/__tests__/AcademyNavigationBar.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@ jest.mock('react-redux', () => ({
1111
const useSelectorMock = useTypedSelector as jest.Mock;
1212

1313
const assessmentTypes = ['Missions', 'Quests', 'Paths', 'Contests', 'Others'];
14-
const staffRoutes = [
15-
'grading',
16-
'groundcontrol',
17-
'sourcereel',
18-
'gamesimulator',
19-
'dashboard',
20-
'teamformation'
21-
];
22-
const adminRoutes = ['adminpanel'];
14+
const staffRoutes = ['grading', 'sourcereel', 'gamesimulator', 'dashboard', 'teamformation'];
15+
const adminRoutes = ['groundcontrol', 'adminpanel'];
2316
const courseId = 0;
2417
const createCoursePath = (path: string) => `/courses/${courseId}/${path}`;
2518

src/commons/navigationBar/subcomponents/__tests__/__snapshots__/AcademyNavigationBar.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ exports[`MissionControl, GroundControl, Sourcereel, GameSimulator, Dashboard, Te
419419
align="right"
420420
>
421421
<DesktopNavLink
422-
disabled={false}
422+
disabled={true}
423423
hiddenInBreakpoints={
424424
Array [
425425
"xs",

0 commit comments

Comments
 (0)