Skip to content
Permalink
Browse files

Improved: Remove unused ‘UtilHttp#checkURLforSpiders’

(OFBIZ-11138)

It was not used anywhere in the framework or the official plugins.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863402 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jul 19, 2019
1 parent abf0a9a commit 4c72492d2691ecbc8cc46d5367e5f2a37fa3d43e
Showing with 0 additions and 43 deletions.
  1. +0 −43 framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
@@ -76,10 +76,6 @@
import org.apache.ofbiz.webapp.control.ConfigXMLReader;
import org.apache.ofbiz.webapp.event.FileUploadProgressListener;
import org.apache.ofbiz.widget.renderer.VisualTheme;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.Perl5Matcher;

import com.ibm.icu.util.Calendar;

@@ -1485,45 +1481,6 @@ public static String getSessionId(HttpServletRequest request) {
HttpSession session = request.getSession();
return (session == null ? "unknown" : session.getId());
}
/**
* checks, if the current request comes from a searchbot
*
* @param request
* @return whether the request is from a web searchbot
*/
public static boolean checkURLforSpiders(HttpServletRequest request) {
boolean result = false;

String spiderRequest = (String) request.getAttribute("_REQUEST_FROM_SPIDER_");
if (UtilValidate.isNotEmpty(spiderRequest)) {
return "Y".equals(spiderRequest);
}
String initialUserAgent = request.getHeader("User-Agent") != null ? request.getHeader("User-Agent") : "";
List<String> spiderList = StringUtil.split(UtilProperties.getPropertyValue("url", "link.remove_lsessionid.user_agent_list"), ",");

if (UtilValidate.isNotEmpty(spiderList)) {
for (String spiderNameElement : spiderList) {
Pattern pattern = null;
try {
pattern = PatternFactory.createOrGetPerl5CompiledPattern(spiderNameElement, false);
} catch (MalformedPatternException e) {
Debug.logError(e, module);
}
PatternMatcher matcher = new Perl5Matcher();
if (matcher.contains(initialUserAgent, pattern)) {
request.setAttribute("_REQUEST_FROM_SPIDER_", "Y");
result = true;
break;
}
}
}

if (!result) {
request.setAttribute("_REQUEST_FROM_SPIDER_", "N");
}

return result;
}

/** Returns true if the user has JavaScript enabled.
* @param request

0 comments on commit 4c72492

Please sign in to comment.
You can’t perform that action at this time.