From 2eb685c5d0da7e8e392366748fa32204ed3bbacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Wed, 19 Sep 2018 10:47:26 +0200 Subject: [PATCH] Delete EscapeUtil and dependencies --- .../java/sonia/scm/repository/EscapeUtil.java | 207 ------------------ .../scm/repository/PreProcessorUtil.java | 87 +------- .../repository/api/BlameCommandBuilder.java | 23 +- .../repository/api/BrowseCommandBuilder.java | 23 +- .../repository/api/HookChangesetBuilder.java | 24 +- .../scm/repository/api/LogCommandBuilder.java | 23 +- .../api/ModificationsCommandBuilder.java | 5 +- .../sonia/scm/web/GitRepositoryViewer.java | 1 - 8 files changed, 7 insertions(+), 386 deletions(-) delete mode 100644 scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java diff --git a/scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java b/scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java deleted file mode 100644 index 979ea0056d..0000000000 --- a/scm-core/src/main/java/sonia/scm/repository/EscapeUtil.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright (c) 2010, Sebastian Sdorra - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of SCM-Manager; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://bitbucket.org/sdorra/scm-manager - * - */ - - - -package sonia.scm.repository; - -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.collect.Lists; -import org.apache.commons.lang.StringEscapeUtils; -import sonia.scm.util.Util; - -import java.util.List; - -//~--- JDK imports ------------------------------------------------------------ - -/** - * - * @author Sebastian Sdorra - * @since 1.15 - */ -public final class EscapeUtil -{ - - /** - * Constructs ... - * - */ - private EscapeUtil() {} - - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param result - */ - public static void escape(BrowserResult result) - { - result.setBranch(escape(result.getBranch())); - result.setTag(escape(result.getTag())); - - for (FileObject fo : result) - { - escape(fo); - } - } - - /** - * Method description - * - * - * @param result - * @since 1.17 - */ - public static void escape(BlameResult result) - { - for (BlameLine line : result.getBlameLines()) - { - escape(line); - } - } - - /** - * Method description - * - * - * @param line - * @since 1.17 - */ - public static void escape(BlameLine line) - { - line.setDescription(escape(line.getDescription())); - escape(line.getAuthor()); - } - - /** - * Method description - * - * - * @param fo - */ - public static void escape(FileObject fo) - { - fo.setDescription(escape(fo.getDescription())); - fo.setName(fo.getName()); - fo.setPath(fo.getPath()); - } - - /** - * Method description - * - * - * @param changeset - */ - public static void escape(Changeset changeset) - { - changeset.setDescription(escape(changeset.getDescription())); - escape(changeset.getAuthor()); - changeset.setBranches(escapeList(changeset.getBranches())); - changeset.setTags(escapeList(changeset.getTags())); - } - - /** - * Method description - * - * - * @param person - * @since 1.17 - */ - public static void escape(Person person) - { - if (person != null) - { - person.setName(escape(person.getName())); - person.setMail(escape(person.getMail())); - } - } - - /** - * Method description - * - * - * @param result - */ - public static void escape(ChangesetPagingResult result) - { - for (Changeset c : result) - { - escape(c); - } - } - - /** - * Method description - * - * - * @param value - * - * @return - */ - public static String escape(String value) - { - return StringEscapeUtils.escapeHtml(value); - } - - /** - * Method description - * - * - * @param values - * - * @return - */ - public static List escapeList(List values) - { - if (Util.isNotEmpty(values)) - { - List newList = Lists.newArrayList(); - - for (String v : values) - { - newList.add(StringEscapeUtils.escapeHtml(v)); - } - - values = newList; - } - - return values; - } - - public static void escape(Modifications modifications) { - modifications.setAdded(escapeList(modifications.getAdded())); - modifications.setModified(escapeList(modifications.getModified())); - modifications.setRemoved(escapeList(modifications.getRemoved())); - } -} diff --git a/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java b/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java index 98730c2039..2a1d9c0340 100644 --- a/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java +++ b/scm-core/src/main/java/sonia/scm/repository/PreProcessorUtil.java @@ -111,7 +111,6 @@ public class PreProcessorUtil blameLine.getLineNumber(), repository.getName()); } - EscapeUtil.escape(blameLine); handlePreProcess(repository,blameLine,blameLinePreProcessorFactorySet, blameLinePreProcessorSet); } @@ -123,22 +122,6 @@ public class PreProcessorUtil * @param blameResult */ public void prepareForReturn(Repository repository, BlameResult blameResult) - { - prepareForReturn(repository, blameResult, true); - } - - /** - * Method description - * - * - * @param repository - * @param blameResult - * @param escape - * - * @since 1.35 - */ - public void prepareForReturn(Repository repository, BlameResult blameResult, - boolean escape) { if (logger.isTraceEnabled()) { @@ -146,10 +129,6 @@ public class PreProcessorUtil repository.getName()); } - if (escape) - { - EscapeUtil.escape(blameResult); - } handlePreProcessForIterable(repository, blameResult.getBlameLines(),blameLinePreProcessorFactorySet, blameLinePreProcessorSet); } @@ -162,32 +141,12 @@ public class PreProcessorUtil */ public void prepareForReturn(Repository repository, Changeset changeset) { - prepareForReturn(repository, changeset, true); - } - - /** - * Method description - * - * - * @param repository - * @param changeset - * @param escape - * - * @since 1.35 - */ - public void prepareForReturn(Repository repository, Changeset changeset, boolean escape){ logger.trace("prepare changeset {} of repository {} for return", changeset.getId(), repository.getName()); - if (escape) { - EscapeUtil.escape(changeset); - } handlePreProcess(repository, changeset, changesetPreProcessorFactorySet, changesetPreProcessorSet); } - public void prepareForReturn(Repository repository, Modifications modifications, boolean escape) { + public void prepareForReturn(Repository repository, Modifications modifications) { logger.trace("prepare modifications {} of repository {} for return", modifications, repository.getName()); - if (escape) { - EscapeUtil.escape(modifications); - } handlePreProcess(repository, modifications, modificationsPreProcessorFactorySet, modificationsPreProcessorSet); } @@ -199,22 +158,6 @@ public class PreProcessorUtil * @param result */ public void prepareForReturn(Repository repository, BrowserResult result) - { - prepareForReturn(repository, result, true); - } - - /** - * Method description - * - * - * @param repository - * @param result - * @param escape - * - * @since 1.35 - */ - public void prepareForReturn(Repository repository, BrowserResult result, - boolean escape) { if (logger.isTraceEnabled()) { @@ -222,10 +165,6 @@ public class PreProcessorUtil repository.getName()); } - if (escape) - { - EscapeUtil.escape(result); - } handlePreProcessForIterable(repository, result,fileObjectPreProcessorFactorySet, fileObjectPreProcessorSet); } @@ -235,12 +174,8 @@ public class PreProcessorUtil * * @param repository * @param result - * @param escape - * - * @since 1.35 */ - public void prepareForReturn(Repository repository, - ChangesetPagingResult result, boolean escape) + public void prepareForReturn(Repository repository, ChangesetPagingResult result) { if (logger.isTraceEnabled()) { @@ -248,27 +183,9 @@ public class PreProcessorUtil repository.getName()); } - if (escape) - { - EscapeUtil.escape(result); - } handlePreProcessForIterable(repository,result,changesetPreProcessorFactorySet, changesetPreProcessorSet); } - /** - * Method description - * - * - * @param repository - * @param result - */ - public void prepareForReturn(Repository repository, - ChangesetPagingResult result) - { - prepareForReturn(repository, result, true); - } - - private , P extends PreProcessor> void handlePreProcess(Repository repository, T processedObject, Collection factories, Collection

preProcessors) { diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java index 5a34345dce..f55abd4598 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/BlameCommandBuilder.java @@ -185,7 +185,7 @@ public final class BlameCommandBuilder if (!disablePreProcessors && (result != null)) { - preProcessorUtil.prepareForReturn(repository, result, !disableEscaping); + preProcessorUtil.prepareForReturn(repository, result); } return result; @@ -210,24 +210,6 @@ public final class BlameCommandBuilder return this; } - /** - * Disable html escaping for the returned blame lines. By default all - * blame lines are html escaped. - * - * - * @param disableEscaping true to disable the html escaping - * - * @return {@code this} - * - * @since 1.35 - */ - public BlameCommandBuilder setDisableEscaping(boolean disableEscaping) - { - this.disableEscaping = disableEscaping; - - return this; - } - /** * Disable the execution of pre processors. * @@ -362,9 +344,6 @@ public final class BlameCommandBuilder /** the cache */ private final Cache cache; - /** disable escaping */ - private boolean disableEscaping = false; - /** disable change */ private boolean disableCache = false; diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java index eeae45b893..fe39aa0a05 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java @@ -179,7 +179,7 @@ public final class BrowseCommandBuilder if (!disablePreProcessors && (result != null)) { - preProcessorUtil.prepareForReturn(repository, result, !disableEscaping); + preProcessorUtil.prepareForReturn(repository, result); List fileObjects = result.getFiles(); @@ -212,24 +212,6 @@ public final class BrowseCommandBuilder return this; } - /** - * Disable html escaping for the returned file objects. By default all - * file objects are html escaped. - * - * - * @param disableEscaping true to disable the html escaping - * - * @return {@code this} - * - * @since 1.35 - */ - public BrowseCommandBuilder setDisableEscaping(boolean disableEscaping) - { - this.disableEscaping = disableEscaping; - - return this; - } - /** * Disabling the last commit means that every call to * {@link FileObject#getDescription()} and @@ -433,9 +415,6 @@ public final class BrowseCommandBuilder /** cache */ private final Cache cache; - /** disable escaping */ - private boolean disableEscaping = false; - /** disables the cache */ private boolean disableCache = false; diff --git a/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java index c06e227d5f..fe43fee038 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/HookChangesetBuilder.java @@ -132,8 +132,7 @@ public final class HookChangesetBuilder try { copy = DeepCopy.copy(c); - preProcessorUtil.prepareForReturn(repository, copy, - !disableEscaping); + preProcessorUtil.prepareForReturn(repository, copy); } catch (IOException ex) { @@ -156,24 +155,6 @@ public final class HookChangesetBuilder //~--- set methods ---------------------------------------------------------- - /** - * Disable html escaping for the returned changesets. By default all - * changesets are html escaped. - * - * - * @param disableEscaping true to disable the html escaping - * - * @return {@code this} - * - * @since 1.35 - */ - public HookChangesetBuilder setDisableEscaping(boolean disableEscaping) - { - this.disableEscaping = disableEscaping; - - return this; - } - /** * Disable the execution of pre processors. * @@ -192,9 +173,6 @@ public final class HookChangesetBuilder //~--- fields --------------------------------------------------------------- - /** disable escaping */ - private boolean disableEscaping = false; - /** disable pre processors marker */ private boolean disablePreProcessors = false; diff --git a/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java index 1450cf687a..9c782a781b 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/LogCommandBuilder.java @@ -264,7 +264,7 @@ public final class LogCommandBuilder if (!disablePreProcessors && (cpr != null)) { - preProcessorUtil.prepareForReturn(repository, cpr, !disableEscaping); + preProcessorUtil.prepareForReturn(repository, cpr); } return cpr; @@ -306,24 +306,6 @@ public final class LogCommandBuilder return this; } - /** - * Disable html escaping for the returned changesets. By default all - * changesets are html escaped. - * - * - * @param disableEscaping true to disable the html escaping - * - * @return {@code this} - * - * @since 1.35 - */ - public LogCommandBuilder setDisableEscaping(boolean disableEscaping) - { - this.disableEscaping = disableEscaping; - - return this; - } - /** * Disable the execution of pre processors. * @@ -545,9 +527,6 @@ public final class LogCommandBuilder /** repository to query */ private final Repository repository; - /** disable escaping */ - private boolean disableEscaping = false; - /** disable cache */ private boolean disableCache = false; diff --git a/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java index d81088bd33..6459b47cd5 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/ModificationsCommandBuilder.java @@ -43,9 +43,6 @@ public final class ModificationsCommandBuilder { private final PreProcessorUtil preProcessorUtil; - @Setter - private boolean disableEscaping = false; - @Setter private boolean disableCache = false; @@ -90,7 +87,7 @@ public final class ModificationsCommandBuilder { } } if (!disablePreProcessors && (modifications != null)) { - preProcessorUtil.prepareForReturn(repository, modifications, !disableEscaping); + preProcessorUtil.prepareForReturn(repository, modifications); } return modifications; } diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java index 162e3db489..773e09aada 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitRepositoryViewer.java @@ -278,7 +278,6 @@ public class GitRepositoryViewer { //J- ChangesetPagingResult cpr = service.getLogCommand() - .setDisableEscaping(true) .setBranch(name) .setPagingLimit(CHANGESET_PER_BRANCH) .getChangesets();