PLT-3181 Added crossorigin='anonymous' to all external images (#5774)
* PLT-3181 Added crossorigin='anonymous' to all external images * Fixed image unit tests * Added crossorigin='anonymous' to a few more places
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
d757645c24
Коммит
24848f9d6a
@@ -184,6 +184,7 @@ class PostAttachment extends React.Component {
|
|||||||
author.push(
|
author.push(
|
||||||
<img
|
<img
|
||||||
className='attachment__author-icon'
|
className='attachment__author-icon'
|
||||||
|
crossOrigin='anonymous'
|
||||||
src={data.author_icon}
|
src={data.author_icon}
|
||||||
key={'attachment__author-icon'}
|
key={'attachment__author-icon'}
|
||||||
height='14'
|
height='14'
|
||||||
@@ -257,6 +258,7 @@ class PostAttachment extends React.Component {
|
|||||||
image = (
|
image = (
|
||||||
<img
|
<img
|
||||||
className='attachment__image'
|
className='attachment__image'
|
||||||
|
crossOrigin='anonymous'
|
||||||
src={data.image_url}
|
src={data.image_url}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -269,6 +271,7 @@ class PostAttachment extends React.Component {
|
|||||||
className='attachment__thumb-container'
|
className='attachment__thumb-container'
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
|
crossOrigin='anonymous'
|
||||||
src={data.thumb_url}
|
src={data.thumb_url}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ export default class PostAttachmentOpenGraph extends React.Component {
|
|||||||
element = this.wrapInSmallImageContainer(
|
element = this.wrapInSmallImageContainer(
|
||||||
<img
|
<img
|
||||||
className={'attachment__image attachment__image--openraph'}
|
className={'attachment__image attachment__image--openraph'}
|
||||||
|
crossOrigin='anonymous'
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
ref={(img) => {
|
ref={(img) => {
|
||||||
this.smallImageElement = img;
|
this.smallImageElement = img;
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export default class PostImageEmbed extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
className='img-div placeholder'
|
className='img-div placeholder'
|
||||||
|
crossOrigin='anonymous'
|
||||||
height='500px'
|
height='500px'
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -75,6 +76,7 @@ export default class PostImageEmbed extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
className='img-div'
|
className='img-div'
|
||||||
|
crossOrigin='anonymous'
|
||||||
src={this.props.link}
|
src={this.props.link}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export default class ProfilePicture extends React.Component {
|
|||||||
width={this.props.width}
|
width={this.props.width}
|
||||||
height={this.props.width}
|
height={this.props.width}
|
||||||
src={this.props.src}
|
src={this.props.src}
|
||||||
|
crossOrigin='anonymous'
|
||||||
/>
|
/>
|
||||||
<StatusIcon status={this.props.status}/>
|
<StatusIcon status={this.props.status}/>
|
||||||
</span>
|
</span>
|
||||||
@@ -82,6 +83,7 @@ export default class ProfilePicture extends React.Component {
|
|||||||
width={this.props.width}
|
width={this.props.width}
|
||||||
height={this.props.width}
|
height={this.props.width}
|
||||||
src={this.props.src}
|
src={this.props.src}
|
||||||
|
crossOrigin='anonymous'
|
||||||
/>
|
/>
|
||||||
<StatusIcon status={this.props.status}/>
|
<StatusIcon status={this.props.status}/>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export default class ProfilePopover extends React.Component {
|
|||||||
height='128'
|
height='128'
|
||||||
width='128'
|
width='128'
|
||||||
key='user-popover-image'
|
key='user-popover-image'
|
||||||
|
crossOrigin='anonymous'
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ describe('Markdown.Imgs', function() {
|
|||||||
it('Inline mage', function(done) {
|
it('Inline mage', function(done) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Markdown.format('').trim(),
|
Markdown.format('').trim(),
|
||||||
'<p><img src="/images/icon.png" alt="Mattermost" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"></p>'
|
'<p><img src="/images/icon.png" alt="Mattermost" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img" crossorigin="anonymous"></p>'
|
||||||
);
|
);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
@@ -20,7 +20,7 @@ describe('Markdown.Imgs', function() {
|
|||||||
it('Image with hover text', function(done) {
|
it('Image with hover text', function(done) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Markdown.format('').trim(),
|
Markdown.format('').trim(),
|
||||||
'<p><img src="/images/icon.png" alt="Mattermost" title="Mattermost Icon" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"></p>'
|
'<p><img src="/images/icon.png" alt="Mattermost" title="Mattermost Icon" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img" crossorigin="anonymous"></p>'
|
||||||
);
|
);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
@@ -29,7 +29,7 @@ describe('Markdown.Imgs', function() {
|
|||||||
it('Image with link', function(done) {
|
it('Image with link', function(done) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Markdown.format('[](https://github.com/mattermost/platform)').trim(),
|
Markdown.format('[](https://github.com/mattermost/platform)').trim(),
|
||||||
'<p><a class="theme markdown__link" href="https://github.com/mattermost/platform" rel="noreferrer" target="_blank"><img src="../../images/icon-76x76.png" alt="Mattermost" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"></a></p>'
|
'<p><a class="theme markdown__link" href="https://github.com/mattermost/platform" rel="noreferrer" target="_blank"><img src="../../images/icon-76x76.png" alt="Mattermost" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img" crossorigin="anonymous"></a></p>'
|
||||||
);
|
);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
@@ -38,7 +38,7 @@ describe('Markdown.Imgs', function() {
|
|||||||
it('Image with width and height', function(done) {
|
it('Image with width and height', function(done) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Markdown.format('').trim(),
|
Markdown.format('').trim(),
|
||||||
'<p><img src="../../images/icon-76x76.png" alt="Mattermost" title="Mattermost Icon" width="50" height="76" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"></p>'
|
'<p><img src="../../images/icon-76x76.png" alt="Mattermost" title="Mattermost Icon" width="50" height="76" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img" crossorigin="anonymous"></p>'
|
||||||
);
|
);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
@@ -47,7 +47,7 @@ describe('Markdown.Imgs', function() {
|
|||||||
it('Image with width', function(done) {
|
it('Image with width', function(done) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
Markdown.format('').trim(),
|
Markdown.format('').trim(),
|
||||||
'<p><img src="../../images/icon-76x76.png" alt="Mattermost" title="Mattermost Icon" width="50" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"></p>'
|
'<p><img src="../../images/icon-76x76.png" alt="Mattermost" title="Mattermost Icon" width="50" onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img" crossorigin="anonymous"></p>'
|
||||||
);
|
);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class MattermostMarkdownRenderer extends marked.Renderer {
|
|||||||
out += ' height="' + dimensions[1] + '"';
|
out += ' height="' + dimensions[1] + '"';
|
||||||
}
|
}
|
||||||
out += ' onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"';
|
out += ' onload="window.markdownImageLoaded(this)" onerror="window.markdownImageLoaded(this)" class="markdown-inline-img"';
|
||||||
|
out += ' crossorigin="anonymous"';
|
||||||
out += this.options.xhtml ? '/>' : '>';
|
out += this.options.xhtml ? '/>' : '>';
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user