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

Validate URL to prevent XSS #727

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion packages/yoga/src/Header/web/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ const StyledHeader = styled(Box)`
`}
`;

const Header = ({ link, logo, children, ...props }) => {
const Header = ({ link, logo, children, allowJavaScriptUrls = True, ...props }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ·link,·logo,·children,·allowJavaScriptUrls·=·True,·...props· with ⏎··link,⏎··logo,⏎··children,⏎··allowJavaScriptUrls·=·True,⏎··...props⏎

Suggested change
const Header = ({ link, logo, children, allowJavaScriptUrls = True, ...props }) => {
const Header = ({

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ·link,·logo,·children,·allowJavaScriptUrls·=·True,·...props· with ⏎··link,⏎··logo,⏎··children,⏎··allowJavaScriptUrls·=·True,⏎··...props⏎

Suggested change
const Header = ({ link, logo, children, allowJavaScriptUrls = True, ...props }) => {
const Header = ({

const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Unnecessary escape character: :.

Suggested change
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Unnecessary escape character: :.

Suggested change
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ·/^[\u0000-\u001F·]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i with ⏎····/^[\u0000-\u001F·]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;

Suggested change
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
const isJavaScriptProtocol =

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ·/^[\u0000-\u001F·]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i with ⏎····/^[\u0000-\u001F·]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;

Suggested change
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
const isJavaScriptProtocol =

if (isJavaScriptProtocol.test(link) && !allowJavaScriptUrls) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ···· with ··

Suggested change
if (isJavaScriptProtocol.test(link) && !allowJavaScriptUrls) {
if (isJavaScriptProtocol.test(link) && !allowJavaScriptUrls) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ···· with ··

Suggested change
if (isJavaScriptProtocol.test(link) && !allowJavaScriptUrls) {
if (isJavaScriptProtocol.test(link) && !allowJavaScriptUrls) {

console.warn(`Header has blocked a javascript: URL as a security precaution`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ··console.warn(Header·has·blocked·a·javascript:·URL·as·a·security·precaution); with console.warn(⏎······Header·has·blocked·a·javascript:·URL·as·a·security·precaution,

Suggested change
console.warn(`Header has blocked a javascript: URL as a security precaution`);
console.warn(

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Unexpected console statement.

Suggested change
console.warn(`Header has blocked a javascript: URL as a security precaution`);

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ··console.warn(Header·has·blocked·a·javascript:·URL·as·a·security·precaution); with console.warn(⏎······Header·has·blocked·a·javascript:·URL·as·a·security·precaution,

Suggested change
console.warn(`Header has blocked a javascript: URL as a security precaution`);
console.warn(

return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ·· with ····);⏎

Suggested change
return null;
);

Copy link
Contributor

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Replace ·· with ····);⏎

Suggested change
return null;
);

}
return (
<StyledHeader
as="header"
Expand Down
Loading