- redirect_mode = csp->action->string[ACTION_STRING_FAST_REDIRECTS];
- if (0 == strcmpic(redirect_mode, "check-decoded-url"))
- {
- p = q = csp->http->path;
- log_error(LOG_LEVEL_REDIRECTS, "Decoding path: %s if necessary.", p);
- while (*p)
- {
- if (*p == '%') /* Escape sequence? */
- {
- /* Yes, translate from hexadecimal to decimal */
- p++;
- /* First byte */
- x=((int)*p++)-48;
- if (x>9) x-=7;
- x<<=4;
- /* Second byte */
- y=((int)*p++)-48;
- if (y>9)y-=7;
- /* Merge */
- *q++=(char)(x|y);
- }
- else
- {
- /* No, forward character. */
- *q++=*p++;
- }
- }
- *q='\0';
+ log_error(LOG_LEVEL_REDIRECTS,
+ "pcrs command \"%s\" changed \"%s\" to \"%s\" (%u hi%s).",
+ pcrs_command, old_url, new_url, hits, (hits == 1) ? "t" : "ts");
+ }
+
+ return new_url;
+
+}
+
+
+#ifdef FEATURE_FAST_REDIRECTS
+/*********************************************************************
+ *
+ * Function : get_last_url
+ *
+ * Description : Search for the last URL inside a string.
+ * If the string already is a URL, it will
+ * be the first URL found.
+ *
+ * Parameters :
+ * 1 : subject = the string to check
+ * 2 : redirect_mode = +fast-redirect{} mode
+ *
+ * Returns : NULL if no URL was found, or
+ * the last URL found.
+ *
+ *********************************************************************/
+char *get_last_url(char *subject, const char *redirect_mode)
+{
+ char *new_url = NULL;
+ char *tmp;
+
+ assert(subject);
+ assert(redirect_mode);
+
+ subject = strdup(subject);
+ if (subject == NULL)
+ {
+ log_error(LOG_LEVEL_ERROR, "Out of memory while searching for redirects.");
+ return NULL;
+ }
+
+ if (0 == strcmpic(redirect_mode, "check-decoded-url"))
+ {
+ log_error(LOG_LEVEL_REDIRECTS, "Decoding \"%s\" if necessary.", subject);
+ new_url = url_decode(subject);
+ if (new_url != NULL)
+ {
+ freez(subject);
+ subject = new_url;
+ }
+ else
+ {
+ log_error(LOG_LEVEL_ERROR, "Unable to decode \"%s\".", subject);