Skip to content

Commit

Permalink
Fix js injection in message input
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Oct 9, 2023
1 parent ce6501e commit a050135
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const Disabled = Template.bind({})

const args: ChannelInputProps = {
channelId: 'channelId',
channelParticipants: [{ nickname: 'john' }, { nickname: 'emily' }],
inputPlaceholder: '#general as @alice',
onChange: function (_arg: string): void {},
onKeyPress: function (input: string): void {
Expand All @@ -34,7 +33,6 @@ const args: ChannelInputProps = {

const argsDisabledInput: ChannelInputProps = {
channelId: 'channelId',
channelParticipants: [{ nickname: 'john' }, { nickname: 'emily' }],
inputPlaceholder: '#general as @alice',
onChange: function (_arg: string): void {},
onKeyPress: function (input: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,22 +529,6 @@ export const ChannelInputComponent: React.FC<ChannelInputProps> = ({
direction='column'
justifyContent='center'
>
{/* <MentionPoper anchorEl={anchorEl} selected={selected}>
{mentionsToSelect.map((target, index) => (
<MentionElement
key={index}
name={target.nickname}
highlight={index === selected}
onMouseEnter={() => {
setSelected(index)
}}
channelName={channelName}
onClick={e => {
mentionSelectAction(e)
}}
/>
))}
</MentionPoper> */}
<Grid
container
direction='row'
Expand Down Expand Up @@ -586,18 +570,14 @@ export const ChannelInputComponent: React.FC<ChannelInputProps> = ({
onChange={onChangeCb}
onKeyDown={onKeyDownCb}
onPaste={async e => {
e.preventDefault()
const files = e.clipboardData.files
if (files.length) e.preventDefault()
for (let i = 0; i < files.length; i++) {
const fileExt = path.extname(files[i].name).toLowerCase()
const fileName = path.basename(files[i].name, fileExt)
const arrayBuffer = await files[i].arrayBuffer()
handleClipboardFiles(arrayBuffer, fileExt, fileName)
}
if (!files.length) {
const text = e.clipboardData.getData('text/plain').replace(/(\r\n|\r|\n)/g, '<br />')
document.execCommand('insertHTML', false, text)
}
}}
data-testid='messageInput'
/>
Expand Down

0 comments on commit a050135

Please sign in to comment.