Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize data in addUser #10089

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import Meetings from '/imports/api/meetings';
import VoiceUsers from '/imports/api/voice-users/';
import _ from 'lodash';
import SanitizeHTML from 'sanitize-html';

import stringHash from 'string-hash';
import flat from 'flat';
Expand All @@ -15,7 +17,17 @@ const COLOR_LIST = [
'#0d47a1', '#0277bd', '#01579b',
];

export default function addUser(meetingId, user) {
export default function addUser(meetingId, userData) {
const user = userData;
const sanitizedName = SanitizeHTML(userData.name, {
allowedTags: [],
allowedAttributes: {},
});
// if user typed only tags
user.name = sanitizedName.length === 0
? _.escape(userData.name)
: sanitizedName;

check(meetingId, String);

check(user, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import fastdom from 'fastdom';
import SanitizeHTML from 'sanitize-html';

const propTypes = {
text: PropTypes.string.isRequired,
Expand Down Expand Up @@ -151,10 +152,17 @@ export default class MessageListItem extends PureComponent {
className,
} = this.props;

const sanitizedText = SanitizeHTML(text, {
allowedTags: ['b', 'strong', 'i', 'u', 'a'],
allowedAttributes: {
a: ['href', 'name', 'target'],
},
});

return (
<p
ref={(ref) => { this.text = ref; }}
dangerouslySetInnerHTML={{ __html: text }}
dangerouslySetInnerHTML={{ __html: sanitizedText }}
className={className}
/>
);
Expand Down
109 changes: 109 additions & 0 deletions bigbluebutton-html5/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bigbluebutton-html5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"react-transition-group": "^2.9.0",
"reconnecting-websocket": "~v4.1.10",
"redis": "~2.8.0",
"sanitize-html": "^1.27.1",
"sdp-transform": "2.7.0",
"string-hash": "~1.1.3",
"tippy.js": "^3.4.1",
Expand Down