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
This commit is contained in:
@@ -76,10 +76,6 @@ import org.apache.ofbiz.entity.util.EntityUtilProperties;
|
||||
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 final class UtilHttp {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user