You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Strip <img src="https?://..">s when transforming imgs instead of using allowedSchemesByTag
This commit is contained in:
@@ -151,9 +151,6 @@ const sanitizeHtmlParams = {
|
|||||||
// URL schemes we permit
|
// URL schemes we permit
|
||||||
allowedSchemes: ['http', 'https', 'ftp', 'mailto'],
|
allowedSchemes: ['http', 'https', 'ftp', 'mailto'],
|
||||||
|
|
||||||
allowedSchemesByTag: {
|
|
||||||
img: ['http', 'https'],
|
|
||||||
},
|
|
||||||
allowProtocolRelative: false,
|
allowProtocolRelative: false,
|
||||||
|
|
||||||
transformTags: { // custom to matrix
|
transformTags: { // custom to matrix
|
||||||
@@ -187,13 +184,14 @@ const sanitizeHtmlParams = {
|
|||||||
return { tagName: tagName, attribs : attribs };
|
return { tagName: tagName, attribs : attribs };
|
||||||
},
|
},
|
||||||
'img': function(tagName, attribs) {
|
'img': function(tagName, attribs) {
|
||||||
if (attribs.src.startsWith('mxc://')) {
|
if (!attribs.src.startsWith('mxc://')) {
|
||||||
attribs.src = MatrixClientPeg.get().mxcUrlToHttp(
|
return { tagName, attribs: {}};
|
||||||
attribs.src,
|
|
||||||
attribs.width || 800,
|
|
||||||
attribs.height || 600,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
attribs.src = MatrixClientPeg.get().mxcUrlToHttp(
|
||||||
|
attribs.src,
|
||||||
|
attribs.width || 800,
|
||||||
|
attribs.height || 600,
|
||||||
|
);
|
||||||
return { tagName: tagName, attribs: attribs };
|
return { tagName: tagName, attribs: attribs };
|
||||||
},
|
},
|
||||||
'code': function(tagName, attribs) {
|
'code': function(tagName, attribs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user