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

prevent JS in link to github #114

Merged
merged 2 commits into from
Mar 17, 2016
Merged

prevent JS in link to github #114

merged 2 commits into from
Mar 17, 2016

Conversation

lanwen
Copy link
Member

@lanwen lanwen commented Mar 15, 2016

This change is Reviewable

@@ -33,7 +34,7 @@ public String getIconFileName() {

@Override
public String getUrlName() {
return projectProperty.getProjectUrl().baseUrl();
return XSSApi.asValidHref(projectProperty.getProjectUrl().baseUrl());
Copy link
Member

Choose a reason for hiding this comment

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

Functions.*escape* hudson.Util#escape

Copy link
Member Author

Choose a reason for hiding this comment

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

nope. They can't escape js

@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

*/
public static String asValidHref(String urlString) {
try {
return new URL(urlString).toExternalForm();
Copy link
Member

Choose a reason for hiding this comment

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

What happens to relative links? Protocol-relative URLs? Tests don't cover those.

Copy link
Member Author

Choose a reason for hiding this comment

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

Expecting github url is scheme + fqdn + project path all other urls will be filtered (added tests for such cases)

lanwen added a commit that referenced this pull request Mar 17, 2016
prevent JS in link to github
@lanwen lanwen merged commit b61b10d into jenkinsci:master Mar 17, 2016
@lanwen lanwen deleted the xss branch March 17, 2016 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants