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

feat(v2): prevent using remote image urls in showcase #3560

Merged
merged 5 commits into from
Oct 8, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions website-1.x/core/Showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@

const React = require('react');
const PropTypes = require('prop-types');
const users = require('../data/users');

users.forEach((user) => {
if (!user.image.startsWith('/img/users')) {
throw new Error(
`User image should be self-hosted in /img/users folder. This was not the case for ${user.image}`,
);
}
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seen this check just after, but does not. look like the appropriate place to do it.


const UserLink = ({infoLink, image, caption}) => (
<a className="link" href={infoLink} key={infoLink}>
Expand Down
12 changes: 11 additions & 1 deletion website-1.x/data/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

module.exports = [
const users = [
// Please add your logo in alphabetical order of caption.
{
caption: '1Hive',
Expand Down Expand Up @@ -892,3 +892,13 @@ module.exports = [

// Please add your logo in alphabetical order of caption.
];

users.forEach((user) => {
if (!user.image || !user.image.startsWith('/img/users/')) {
throw new Error(
`Bad user site image = ${user.image}. The image should be hosted on Docusaurus site, in /static/img/users/ folder, and not use remote http or https urls`,
);
}
});

module.exports = users;
12 changes: 12 additions & 0 deletions website/src/data/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,16 @@ const users = [
},
];

users.forEach((user) => {
if (
!user.preview ||
(user.preview instanceof String &&
(user.preview.startsWith('http') || user.preview.startsWith('//')))
) {
throw new Error(
`Bad user site image preview = ${user.preview}. The image should be hosted on Docusaurus site, and not use remote http or https urls`,
);
}
});

export default users;