]> source.dussan.org Git - gitblit.git/commitdiff
Merge branch 'ticket/164' into develop
authorJames Moger <james.moger@gitblit.com>
Sun, 7 Sep 2014 16:53:08 +0000 (12:53 -0400)
committerJames Moger <james.moger@gitblit.com>
Sun, 7 Sep 2014 16:53:08 +0000 (12:53 -0400)
12 files changed:
1  2 
.classpath
build.moxie
gitblit.iml
src/main/java/com/gitblit/FederationClient.java
src/main/java/com/gitblit/guice/CoreModule.java
src/main/java/com/gitblit/manager/GitblitManager.java
src/main/java/com/gitblit/manager/IRuntimeManager.java
src/main/java/com/gitblit/manager/RuntimeManager.java
src/main/java/com/gitblit/utils/JSoupXssFilter.java
src/main/java/com/gitblit/wicket/GitBlitWebApp.java
src/main/java/com/gitblit/wicket/GitblitWicketApp.java
src/test/java/com/gitblit/tests/mock/MockRuntimeManager.java

diff --cc .classpath
index 53faa53619abe6fe36a9bffc5c0baf58440a198f,a6b40100e51779dca5798a0640275779aeb96a00..61f3a9704e58e0fa4c724f1e98d3a6b57b77afdb
@@@ -75,8 -75,9 +75,9 @@@
        <classpathentry kind="lib" path="ext/args4j-2.0.26.jar" sourcepath="ext/src/args4j-2.0.26.jar" />
        <classpathentry kind="lib" path="ext/jedis-2.3.1.jar" sourcepath="ext/src/jedis-2.3.1.jar" />
        <classpathentry kind="lib" path="ext/commons-pool2-2.0.jar" sourcepath="ext/src/commons-pool2-2.0.jar" />
 -      <classpathentry kind="lib" path="ext/pf4j-0.8.0.jar" sourcepath="ext/src/pf4j-0.8.0.jar" />
 +      <classpathentry kind="lib" path="ext/pf4j-0.9.0.jar" sourcepath="ext/src/pf4j-0.9.0.jar" />
        <classpathentry kind="lib" path="ext/tika-core-1.5.jar" sourcepath="ext/src/tika-core-1.5.jar" />
+       <classpathentry kind="lib" path="ext/jsoup-1.7.3.jar" sourcepath="ext/src/jsoup-1.7.3.jar" />
        <classpathentry kind="lib" path="ext/junit-4.11.jar" sourcepath="ext/src/junit-4.11.jar" />
        <classpathentry kind="lib" path="ext/hamcrest-core-1.3.jar" sourcepath="ext/src/hamcrest-core-1.3.jar" />
        <classpathentry kind="lib" path="ext/selenium-java-2.28.0.jar" sourcepath="ext/src/selenium-java-2.28.0.jar" />
diff --cc build.moxie
index ea2763c47599fb712961de0d1bc27d9ac17aa7ae,c558c5204ea452041fa39ca96ec43e118c20e173..6b6c00854b35084b9723a456922973e4d264d767
@@@ -170,14 -168,15 +170,15 @@@ dependencies
  - compile 'org.apache.commons:commons-compress:1.4.1' :war
  - compile 'commons-io:commons-io:2.2' :war
  - compile 'com.force.api:force-partner-api:24.0.0' :war
 -- compile 'org.freemarker:freemarker:2.3.19' :war
 +- compile 'org.freemarker:freemarker:2.3.20' :war
  - compile 'com.github.dblock.waffle:waffle-jna:1.5' :war
  - compile 'org.kohsuke:libpam4j:1.7' :war
 -- compile 'args4j:args4j:2.0.26' :war :fedclient :authority
 +- compile 'args4j:args4j:2.0.26' :war :fedclient
  - compile 'commons-codec:commons-codec:1.7' :war
  - compile 'redis.clients:jedis:2.3.1' :war
 -- compile 'ro.fortsoft.pf4j:pf4j:0.8.0' :war
 +- compile 'ro.fortsoft.pf4j:pf4j:0.9.0' :war
  - compile 'org.apache.tika:tika-core:1.5' :war
+ - compile 'org.jsoup:jsoup:1.7.3' :war
  - test 'junit'
  # Dependencies for Selenium web page testing
  - test 'org.seleniumhq.selenium:selenium-java:${selenium.version}' @jar
diff --cc gitblit.iml
Simple merge
index 822e8a7fd366a4d0c30f0de5a0117273a28e6e29,079355efa9f89a6f27bfe0409e9c78e0280a34d9..487080e565448f750b30287b99ec3493c35ffd8e
 -/*\r
 - * Copyright 2011 gitblit.com.\r
 - *\r
 - * Licensed under the Apache License, Version 2.0 (the "License");\r
 - * you may not use this file except in compliance with the License.\r
 - * You may obtain a copy of the License at\r
 - *\r
 - *     http://www.apache.org/licenses/LICENSE-2.0\r
 - *\r
 - * Unless required by applicable law or agreed to in writing, software\r
 - * distributed under the License is distributed on an "AS IS" BASIS,\r
 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 - * See the License for the specific language governing permissions and\r
 - * limitations under the License.\r
 - */\r
 -package com.gitblit;\r
 -\r
 -import java.io.File;\r
 -import java.util.ArrayList;\r
 -import java.util.Collection;\r
 -import java.util.List;\r
 -\r
 -import org.kohsuke.args4j.CmdLineException;\r
 -import org.kohsuke.args4j.CmdLineParser;\r
 -import org.kohsuke.args4j.Option;\r
 -\r
 -import com.gitblit.manager.FederationManager;\r
 -import com.gitblit.manager.GitblitManager;\r
 -import com.gitblit.manager.IGitblit;\r
 -import com.gitblit.manager.INotificationManager;\r
 -import com.gitblit.manager.RepositoryManager;\r
 -import com.gitblit.manager.RuntimeManager;\r
 -import com.gitblit.manager.UserManager;\r
 -import com.gitblit.models.FederationModel;\r
 -import com.gitblit.models.Mailing;\r
 -import com.gitblit.service.FederationPullService;\r
 -import com.gitblit.utils.FederationUtils;\r
 -import com.gitblit.utils.StringUtils;\r
 -import com.gitblit.utils.XssFilter;\r
 -import com.gitblit.utils.XssFilter.AllowXssFilter;\r
 -\r
 -/**\r
 - * Command-line client to pull federated Gitblit repositories.\r
 - *\r
 - * @author James Moger\r
 - *\r
 - */\r
 -public class FederationClient {\r
 -\r
 -      public static void main(String[] args) {\r
 -              Params params = new Params();\r
 -              CmdLineParser parser = new CmdLineParser(params);\r
 -              try {\r
 -                      parser.parseArgument(args);\r
 -              } catch (CmdLineException t) {\r
 -                      usage(parser, t);\r
 -              }\r
 -\r
 -              System.out.println("Gitblit Federation Client v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");\r
 -\r
 -              // command-line specified base folder\r
 -              File baseFolder = new File(System.getProperty("user.dir"));\r
 -              if (!StringUtils.isEmpty(params.baseFolder)) {\r
 -                      baseFolder = new File(params.baseFolder);\r
 -              }\r
 -\r
 -              File regFile = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.registrationsFile);\r
 -              FileSettings settings = new FileSettings(regFile.getAbsolutePath());\r
 -              List<FederationModel> registrations = new ArrayList<FederationModel>();\r
 -              if (StringUtils.isEmpty(params.url)) {\r
 -                      registrations.addAll(FederationUtils.getFederationRegistrations(settings));\r
 -              } else {\r
 -                      if (StringUtils.isEmpty(params.token)) {\r
 -                              System.out.println("Must specify --token parameter!");\r
 -                              System.exit(0);\r
 -                      }\r
 -                      FederationModel model = new FederationModel("Gitblit");\r
 -                      model.url = params.url;\r
 -                      model.token = params.token;\r
 -                      model.mirror = params.mirror;\r
 -                      model.bare = params.bare;\r
 -                      model.folder = "";\r
 -                      registrations.add(model);\r
 -              }\r
 -              if (registrations.size() == 0) {\r
 -                      System.out.println("No Federation Registrations!  Nothing to do.");\r
 -                      System.exit(0);\r
 -              }\r
 -\r
 -              // command-line specified repositories folder\r
 -              if (!StringUtils.isEmpty(params.repositoriesFolder)) {\r
 -                      settings.overrideSetting(Keys.git.repositoriesFolder, new File(\r
 -                                      params.repositoriesFolder).getAbsolutePath());\r
 -              }\r
 -\r
 -              // configure the Gitblit singleton for minimal, non-server operation\r
 -              XssFilter xssFilter = new AllowXssFilter();\r
 -              RuntimeManager runtime = new RuntimeManager(settings, xssFilter, baseFolder).start();\r
 -              NoopNotificationManager notifications = new NoopNotificationManager().start();\r
 -              UserManager users = new UserManager(runtime, null).start();\r
 -              RepositoryManager repositories = new RepositoryManager(runtime, null, users).start();\r
 -              FederationManager federation = new FederationManager(runtime, notifications, repositories).start();\r
 -              IGitblit gitblit = new GitblitManager(runtime, null, notifications, users, null, null, repositories, null, federation);\r
 -\r
 -              FederationPullService puller = new FederationPullService(gitblit, federation.getFederationRegistrations()) {\r
 -                      @Override\r
 -                      public void reschedule(FederationModel registration) {\r
 -                              // NOOP\r
 -                      }\r
 -              };\r
 -              puller.run();\r
 -\r
 -              System.out.println("Finished.");\r
 -              System.exit(0);\r
 -      }\r
 -\r
 -      private static void usage(CmdLineParser parser, CmdLineException t) {\r
 -              System.out.println(Constants.getGitBlitVersion());\r
 -              System.out.println();\r
 -              if (t != null) {\r
 -                      System.out.println(t.getMessage());\r
 -                      System.out.println();\r
 -              }\r
 -\r
 -              if (parser != null) {\r
 -                      parser.printUsage(System.out);\r
 -              }\r
 -              System.exit(0);\r
 -      }\r
 -\r
 -      /**\r
 -       * Parameters class for FederationClient.\r
 -       */\r
 -      private static class Params {\r
 -\r
 -              @Option(name = "--registrations", usage = "Gitblit Federation Registrations File", metaVar = "FILE")\r
 -              public String registrationsFile = "${baseFolder}/federation.properties";\r
 -\r
 -              @Option(name = "--url", usage = "URL of Gitblit instance to mirror from", metaVar = "URL")\r
 -              public String url;\r
 -\r
 -              @Option(name = "--mirror", usage = "Mirror repositories")\r
 -              public boolean mirror;\r
 -\r
 -              @Option(name = "--bare", usage = "Create bare repositories")\r
 -              public boolean bare;\r
 -\r
 -              @Option(name = "--token", usage = "Federation Token", metaVar = "TOKEN")\r
 -              public String token;\r
 -\r
 -              @Option(name = "--baseFolder", usage = "Base folder for received data", metaVar = "PATH")\r
 -              public String baseFolder;\r
 -\r
 -              @Option(name = "--repositoriesFolder", usage = "Destination folder for cloned repositories", metaVar = "PATH")\r
 -              public String repositoriesFolder;\r
 -\r
 -      }\r
 -\r
 -      private static class NoopNotificationManager implements INotificationManager {\r
 -\r
 -              @Override\r
 -              public NoopNotificationManager start() {\r
 -                      return this;\r
 -              }\r
 -\r
 -              @Override\r
 -              public NoopNotificationManager stop() {\r
 -                      return this;\r
 -              }\r
 -\r
 -              @Override\r
 -              public boolean isSendingMail() {\r
 -                      return false;\r
 -              }\r
 -\r
 -              @Override\r
 -              public void sendMailToAdministrators(String subject, String message) {\r
 -              }\r
 -\r
 -              @Override\r
 -              public void sendMail(String subject, String message, Collection<String> toAddresses) {\r
 -              }\r
 -\r
 -              @Override\r
 -              public void sendHtmlMail(String subject, String message, Collection<String> toAddresses) {\r
 -              }\r
 -\r
 -              @Override\r
 -              public void send(Mailing mailing) {\r
 -              }\r
 -      }\r
 -}\r
 +/*
 + * Copyright 2011 gitblit.com.
 + *
 + * Licensed under the Apache License, Version 2.0 (the "License");
 + * you may not use this file except in compliance with the License.
 + * You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package com.gitblit;
 +
 +import java.io.File;
 +import java.util.ArrayList;
 +import java.util.Collection;
 +import java.util.List;
 +
 +import org.kohsuke.args4j.CmdLineException;
 +import org.kohsuke.args4j.CmdLineParser;
 +import org.kohsuke.args4j.Option;
 +
 +import com.gitblit.manager.FederationManager;
 +import com.gitblit.manager.GitblitManager;
 +import com.gitblit.manager.IGitblit;
 +import com.gitblit.manager.INotificationManager;
 +import com.gitblit.manager.RepositoryManager;
 +import com.gitblit.manager.RuntimeManager;
 +import com.gitblit.manager.UserManager;
 +import com.gitblit.models.FederationModel;
 +import com.gitblit.models.Mailing;
 +import com.gitblit.service.FederationPullService;
 +import com.gitblit.utils.FederationUtils;
 +import com.gitblit.utils.StringUtils;
++import com.gitblit.utils.XssFilter;
++import com.gitblit.utils.XssFilter.AllowXssFilter;
 +
 +/**
 + * Command-line client to pull federated Gitblit repositories.
 + *
 + * @author James Moger
 + *
 + */
 +public class FederationClient {
 +
 +      public static void main(String[] args) {
 +              Params params = new Params();
 +              CmdLineParser parser = new CmdLineParser(params);
 +              try {
 +                      parser.parseArgument(args);
 +              } catch (CmdLineException t) {
 +                      usage(parser, t);
 +              }
 +
 +              System.out.println("Gitblit Federation Client v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
 +
 +              // command-line specified base folder
 +              File baseFolder = new File(System.getProperty("user.dir"));
 +              if (!StringUtils.isEmpty(params.baseFolder)) {
 +                      baseFolder = new File(params.baseFolder);
 +              }
 +
 +              File regFile = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.registrationsFile);
 +              FileSettings settings = new FileSettings(regFile.getAbsolutePath());
 +              List<FederationModel> registrations = new ArrayList<FederationModel>();
 +              if (StringUtils.isEmpty(params.url)) {
 +                      registrations.addAll(FederationUtils.getFederationRegistrations(settings));
 +              } else {
 +                      if (StringUtils.isEmpty(params.token)) {
 +                              System.out.println("Must specify --token parameter!");
 +                              System.exit(0);
 +                      }
 +                      FederationModel model = new FederationModel("Gitblit");
 +                      model.url = params.url;
 +                      model.token = params.token;
 +                      model.mirror = params.mirror;
 +                      model.bare = params.bare;
 +                      model.folder = "";
 +                      registrations.add(model);
 +              }
 +              if (registrations.size() == 0) {
 +                      System.out.println("No Federation Registrations!  Nothing to do.");
 +                      System.exit(0);
 +              }
 +
 +              // command-line specified repositories folder
 +              if (!StringUtils.isEmpty(params.repositoriesFolder)) {
 +                      settings.overrideSetting(Keys.git.repositoriesFolder, new File(
 +                                      params.repositoriesFolder).getAbsolutePath());
 +              }
 +
 +              // configure the Gitblit singleton for minimal, non-server operation
-               RuntimeManager runtime = new RuntimeManager(settings, baseFolder).start();
++              XssFilter xssFilter = new AllowXssFilter();
++              RuntimeManager runtime = new RuntimeManager(settings, xssFilter, baseFolder).start();
 +              NoopNotificationManager notifications = new NoopNotificationManager().start();
 +              UserManager users = new UserManager(runtime, null).start();
 +              RepositoryManager repositories = new RepositoryManager(runtime, null, users).start();
 +              FederationManager federation = new FederationManager(runtime, notifications, repositories).start();
 +              IGitblit gitblit = new GitblitManager(null, null, runtime, null, notifications, users, null, repositories, null, federation);
 +
 +              FederationPullService puller = new FederationPullService(gitblit, federation.getFederationRegistrations()) {
 +                      @Override
 +                      public void reschedule(FederationModel registration) {
 +                              // NOOP
 +                      }
 +              };
 +              puller.run();
 +
 +              System.out.println("Finished.");
 +              System.exit(0);
 +      }
 +
 +      private static void usage(CmdLineParser parser, CmdLineException t) {
 +              System.out.println(Constants.getGitBlitVersion());
 +              System.out.println();
 +              if (t != null) {
 +                      System.out.println(t.getMessage());
 +                      System.out.println();
 +              }
 +
 +              if (parser != null) {
 +                      parser.printUsage(System.out);
 +              }
 +              System.exit(0);
 +      }
 +
 +      /**
 +       * Parameters class for FederationClient.
 +       */
 +      private static class Params {
 +
 +              @Option(name = "--registrations", usage = "Gitblit Federation Registrations File", metaVar = "FILE")
 +              public String registrationsFile = "${baseFolder}/federation.properties";
 +
 +              @Option(name = "--url", usage = "URL of Gitblit instance to mirror from", metaVar = "URL")
 +              public String url;
 +
 +              @Option(name = "--mirror", usage = "Mirror repositories")
 +              public boolean mirror;
 +
 +              @Option(name = "--bare", usage = "Create bare repositories")
 +              public boolean bare;
 +
 +              @Option(name = "--token", usage = "Federation Token", metaVar = "TOKEN")
 +              public String token;
 +
 +              @Option(name = "--baseFolder", usage = "Base folder for received data", metaVar = "PATH")
 +              public String baseFolder;
 +
 +              @Option(name = "--repositoriesFolder", usage = "Destination folder for cloned repositories", metaVar = "PATH")
 +              public String repositoriesFolder;
 +
 +      }
 +
 +      private static class NoopNotificationManager implements INotificationManager {
 +
 +              @Override
 +              public NoopNotificationManager start() {
 +                      return this;
 +              }
 +
 +              @Override
 +              public NoopNotificationManager stop() {
 +                      return this;
 +              }
 +
 +              @Override
 +              public boolean isSendingMail() {
 +                      return false;
 +              }
 +
 +              @Override
 +              public void sendMailToAdministrators(String subject, String message) {
 +              }
 +
 +              @Override
 +              public void sendMail(String subject, String message, Collection<String> toAddresses) {
 +              }
 +
 +              @Override
 +              public void sendHtmlMail(String subject, String message, Collection<String> toAddresses) {
 +              }
 +
 +              @Override
 +              public void send(Mailing mailing) {
 +              }
 +      }
 +}
index c0d39e9975d45af338bb9a431010bd9f41825a71,0000000000000000000000000000000000000000..a942b2eca51f6888c2c91a1557d1a976bdac1663
mode 100644,000000..100644
--- /dev/null
@@@ -1,79 -1,0 +1,82 @@@
 +/*
 + * Copyright 2014 gitblit.com.
 + *
 + * Licensed under the Apache License, Version 2.0 (the "License");
 + * you may not use this file except in compliance with the License.
 + * You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package com.gitblit.guice;
 +
 +import com.gitblit.FileSettings;
 +import com.gitblit.GitBlit;
 +import com.gitblit.IStoredSettings;
 +import com.gitblit.manager.AuthenticationManager;
 +import com.gitblit.manager.FederationManager;
 +import com.gitblit.manager.IAuthenticationManager;
 +import com.gitblit.manager.IFederationManager;
 +import com.gitblit.manager.IGitblit;
 +import com.gitblit.manager.INotificationManager;
 +import com.gitblit.manager.IPluginManager;
 +import com.gitblit.manager.IProjectManager;
 +import com.gitblit.manager.IRepositoryManager;
 +import com.gitblit.manager.IRuntimeManager;
 +import com.gitblit.manager.IServicesManager;
 +import com.gitblit.manager.IUserManager;
 +import com.gitblit.manager.NotificationManager;
 +import com.gitblit.manager.PluginManager;
 +import com.gitblit.manager.ProjectManager;
 +import com.gitblit.manager.RepositoryManager;
 +import com.gitblit.manager.RuntimeManager;
 +import com.gitblit.manager.ServicesManager;
 +import com.gitblit.manager.UserManager;
 +import com.gitblit.tickets.ITicketService;
 +import com.gitblit.transport.ssh.IPublicKeyManager;
++import com.gitblit.utils.JSoupXssFilter;
 +import com.gitblit.utils.WorkQueue;
++import com.gitblit.utils.XssFilter;
 +import com.google.inject.AbstractModule;
 +
 +/**
 + * CoreModule references all the core business objects.
 + *
 + * @author James Moger
 + *
 + */
 +public class CoreModule extends AbstractModule {
 +
 +      @Override
 +      protected void configure() {
 +
 +              bind(IStoredSettings.class).toInstance(new FileSettings());
++              bind(XssFilter.class).to(JSoupXssFilter.class);
 +
 +              // bind complex providers
 +              bind(IPublicKeyManager.class).toProvider(IPublicKeyManagerProvider.class);
 +              bind(ITicketService.class).toProvider(ITicketServiceProvider.class);
 +              bind(WorkQueue.class).toProvider(WorkQueueProvider.class);
 +
 +              // core managers
 +              bind(IRuntimeManager.class).to(RuntimeManager.class);
 +              bind(IPluginManager.class).to(PluginManager.class);
 +              bind(INotificationManager.class).to(NotificationManager.class);
 +              bind(IUserManager.class).to(UserManager.class);
 +              bind(IAuthenticationManager.class).to(AuthenticationManager.class);
 +              bind(IRepositoryManager.class).to(RepositoryManager.class);
 +              bind(IProjectManager.class).to(ProjectManager.class);
 +              bind(IFederationManager.class).to(FederationManager.class);
 +
 +              // the monolithic manager
 +              bind(IGitblit.class).to(GitBlit.class);
 +
 +              // manager for long-running daemons and services
 +              bind(IServicesManager.class).to(ServicesManager.class);
 +      }
 +}
index da081276dfeffc1678e5340acd64ad3e74a6c32d,2ed52d67d2e92135f204864ac7623181bc2de5dd..6edac453af58671fa0d34f678c33f2a95cd4db2d
@@@ -586,11 -664,11 +588,16 @@@ public class GitblitManager implements 
                return runtimeManager.getStatus();
        }
  
 +      @Override
 +      public Injector getInjector() {
 +              return runtimeManager.getInjector();
 +      }
 +
+       @Override
+       public XssFilter getXssFilter() {
+               return runtimeManager.getXssFilter();
+       }
        /*
         * NOTIFICATION MANAGER
         */
index 8322d34fa7d0dd7b453a3087dd45f999b1839e65,132534c389a7f410f26cb7783f933e15d3377aa7..2203b7ff2c80dbd5dbe400b40e12ff43a6749887
@@@ -24,7 -24,7 +24,8 @@@ import java.util.TimeZone
  import com.gitblit.IStoredSettings;
  import com.gitblit.models.ServerSettings;
  import com.gitblit.models.ServerStatus;
+ import com.gitblit.utils.XssFilter;
 +import com.google.inject.Injector;
  
  public interface IRuntimeManager extends IManager {
  
index 95a363f69a7e16af05b985245c79edc82971fb8a,219bf8019cc773cba50449d939c0e6a3d5c5c31c..18d6b9c20a95ef95cc03f4ccc3ca2b7379eb0844
@@@ -32,11 -32,8 +32,12 @@@ import com.gitblit.models.ServerSetting
  import com.gitblit.models.ServerStatus;
  import com.gitblit.models.SettingModel;
  import com.gitblit.utils.StringUtils;
+ import com.gitblit.utils.XssFilter;
 +import com.google.inject.Inject;
 +import com.google.inject.Injector;
 +import com.google.inject.Singleton;
  
 +@Singleton
  public class RuntimeManager implements IRuntimeManager {
  
        private final Logger logger = LoggerFactory.getLogger(getClass());
  
        private TimeZone timezone;
  
-       public RuntimeManager(IStoredSettings settings) {
-               this(settings, null);
 +      @Inject
 +      private Injector injector;
 +
 +      @Inject
+       public RuntimeManager(IStoredSettings settings, XssFilter xssFilter) {
+               this(settings, xssFilter, null);
        }
  
-       public RuntimeManager(IStoredSettings settings, File baseFolder) {
+       public RuntimeManager(IStoredSettings settings, XssFilter xssFilter, File baseFolder) {
                this.settings = settings;
                this.settingsModel = new ServerSettings();
                this.serverStatus = new ServerStatus();
index 0000000000000000000000000000000000000000,b07bcb9d612920c303585a608a67c4d65f60b1d0..a0b3da21d4181e524fdca33c4b0bce6230d34252
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,87 +1,92 @@@
+ /*
+  * Copyright 2014 gitblit.com.
+  *
+  * Licensed under the Apache License, Version 2.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package com.gitblit.utils;
+ import org.jsoup.Jsoup;
+ import org.jsoup.nodes.Document;
+ import org.jsoup.safety.Cleaner;
+ import org.jsoup.safety.Whitelist;
++import com.google.inject.Inject;
++import com.google.inject.Singleton;
++
+ /**
+  * Implementation of an XSS filter based on JSoup.
+  *
+  * @author James Moger
+  *
+  */
++@Singleton
+ public class JSoupXssFilter implements XssFilter {
+        private final Cleaner none;
+        private final Cleaner relaxed;
++       @Inject
+        public JSoupXssFilter() {
+                none = new Cleaner(Whitelist.none());
+                relaxed = new Cleaner(getRelaxedWhiteList());
+       }
+       @Override
+       public String none(String input) {
+               return clean(input, none);
+       }
+       @Override
+       public String relaxed(String input) {
+               return clean(input, relaxed);
+       }
+       protected String clean(String input, Cleaner cleaner) {
+               Document unsafe = Jsoup.parse(input);
+               Document safe = cleaner.clean(unsafe);
+               return safe.body().html();
+       }
+       /**
+        * Builds & returns a loose HTML whitelist similar to Github.
+        *
+        * https://github.com/github/markup/tree/master#html-sanitization
+        * @return a loose HTML whitelist
+        */
+       protected Whitelist getRelaxedWhiteList() {
+               return new Whitelist()
+         .addTags(
+                 "a", "b", "blockquote", "br", "caption", "cite", "code", "col",
+                 "colgroup", "dd", "del", "div", "dl", "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "hr",
+                 "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "samp", "small", "strike", "strong",
+                 "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "tt", "u",
+                 "ul", "var")
+         .addAttributes("a", "href", "title")
+         .addAttributes("blockquote", "cite")
+         .addAttributes("col", "span", "width")
+         .addAttributes("colgroup", "span", "width")
+         .addAttributes("img", "align", "alt", "height", "src", "title", "width")
+         .addAttributes("ol", "start", "type")
+         .addAttributes("q", "cite")
+         .addAttributes("table", "summary", "width")
+         .addAttributes("td", "abbr", "axis", "colspan", "rowspan", "width")
+         .addAttributes("th", "abbr", "axis", "colspan", "rowspan", "scope", "width")
+         .addAttributes("ul", "type")
+         .addEnforcedAttribute("a", "rel", "nofollow")
+         ;
+       }
+ }
index 036a05a57d394031b4af4d5882d7a5640da24a3c,38dbf57d73870eb62dcfaed81e2ba5cd66f22f6a..922e2045fa1ca27c6aaa490a13930e43c012a9e3
@@@ -103,12 -99,10 +104,14 @@@ public class GitBlitWebApp extends WebA
  
        private final Map<String, CacheControl> cacheablePages = new HashMap<String, CacheControl>();
  
 +      private final Provider<IPublicKeyManager> publicKeyManagerProvider;
 +
 +      private final Provider<ITicketService> ticketServiceProvider;
 +
        private final IStoredSettings settings;
  
+       private final XssFilter xssFilter;
        private final IRuntimeManager runtimeManager;
  
        private final IPluginManager pluginManager;
                        IRepositoryManager repositoryManager,
                        IProjectManager projectManager,
                        IFederationManager federationManager,
 -                      IGitblit gitblit) {
 +                      IGitblit gitblit,
 +                      IServicesManager services) {
  
                super();
 +              this.publicKeyManagerProvider = publicKeyManagerProvider;
 +              this.ticketServiceProvider = ticketServiceProvider;
                this.settings = runtimeManager.getSettings();
+               this.xssFilter = runtimeManager.getXssFilter();
                this.runtimeManager = runtimeManager;
                this.pluginManager = pluginManager;
                this.notificationManager = notificationManager;
index 9a71c884c5831c1d29aafaa1686da69b0d64ef50,7b563622420203a3c625327962af5eb67a290c75..8897ef7e1ecad6e8e0f5f99c1bde3cd14b021e7c
@@@ -28,7 -28,8 +28,9 @@@ import com.gitblit.manager.IRuntimeMana
  import com.gitblit.models.ServerSettings;
  import com.gitblit.models.ServerStatus;
  import com.gitblit.models.SettingModel;
+ import com.gitblit.utils.XssFilter;
+ import com.gitblit.utils.XssFilter.AllowXssFilter;
 +import com.google.inject.Injector;
  
  public class MockRuntimeManager implements IRuntimeManager {