mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 03:25:56 +01:00
use userAgentStartsWith method for user agent check
This commit is contained in:
@@ -60,6 +60,7 @@ import org.eclipse.jgit.util.FS;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -98,9 +99,6 @@ public final class GitUtil
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_REFS = "refs";
|
||||
|
||||
/** Field description */
|
||||
private static final String HEADER_USERAGENT = "User-Agent";
|
||||
|
||||
/** Field description */
|
||||
private static final String PREFIX_HEADS = "refs/heads/";
|
||||
|
||||
@@ -672,8 +670,7 @@ public final class GitUtil
|
||||
*/
|
||||
public static boolean isGitClient(HttpServletRequest request)
|
||||
{
|
||||
return Strings.nullToEmpty(request.getHeader(HEADER_USERAGENT)).toLowerCase(
|
||||
Locale.ENGLISH).startsWith(USERAGENT_GIT);
|
||||
return HttpUtil.userAgentStartsWith(request, USERAGENT_GIT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,7 @@ import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.repository.HgPythonScript;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.spi.javahg.HgFileviewExtension;
|
||||
import sonia.scm.util.HttpUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -58,8 +59,6 @@ import java.io.File;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
@@ -72,9 +71,6 @@ public final class HgUtil
|
||||
/** Field description */
|
||||
public static final String REVISION_TIP = "tip";
|
||||
|
||||
/** Field description */
|
||||
private static final String HEADER_USERAGENT = "User-Agent";
|
||||
|
||||
/** Field description */
|
||||
private static final String USERAGENT_HG = "mercurial/";
|
||||
|
||||
@@ -201,7 +197,6 @@ public final class HgUtil
|
||||
*/
|
||||
public static boolean isHgClient(HttpServletRequest request)
|
||||
{
|
||||
return Strings.nullToEmpty(request.getHeader(HEADER_USERAGENT)).toLowerCase(
|
||||
Locale.ENGLISH).startsWith(USERAGENT_HG);
|
||||
return HttpUtil.userAgentStartsWith(request, USERAGENT_HG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -78,9 +77,6 @@ public final class SvnUtil
|
||||
/** Field description */
|
||||
public static final String XML_CONTENT_TYPE = "text/xml; charset=\"utf-8\"";
|
||||
|
||||
/** Field description */
|
||||
private static final String HEADER_USERAGENT = "User-Agent";
|
||||
|
||||
/** Field description */
|
||||
private static final String ID_TRANSACTION_PREFIX = "-1:";
|
||||
|
||||
@@ -410,8 +406,7 @@ public final class SvnUtil
|
||||
*/
|
||||
public static boolean isSvnClient(HttpServletRequest request)
|
||||
{
|
||||
return Strings.nullToEmpty(request.getHeader(HEADER_USERAGENT)).toLowerCase(
|
||||
Locale.ENGLISH).startsWith(USERAGENT_SVN);
|
||||
return HttpUtil.userAgentStartsWith(request, USERAGENT_SVN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user