dnl Process this file with autoconf to produce a configure script.
 dnl
-dnl $Id: configure.in,v 1.159 2011/07/03 17:53:00 fabiankeil Exp $
+dnl $Id: configure.in,v 1.160 2011/09/04 11:11:17 fabiankeil Exp $
 dnl
 dnl Written by and Copyright (C) 2001-2010 the
 dnl Privoxy team. http://www.privoxy.org/
 dnl AutoConf Initialization
 dnl =================================================================
 
-AC_REVISION($Revision: 1.159 $)
+AC_REVISION($Revision: 1.160 $)
 AC_INIT(jcc.c)
 
 if test ! -f config.h.in; then
 AC_CHECK_FUNCS([bcopy])
 AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([access atexit getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r gettimeofday inet_ntoa localtime_r memchr memmove memset poll putenv random regcomp select setlocale snprintf socket strchr strdup strerror strftime strlcat strlcpy strptime strstr strtoul timegm tzset])
+AC_CHECK_FUNCS([access atexit getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r gettimeofday inet_ntoa localtime_r memchr memmove memset poll putenv random regcomp select setlocale snprintf socket strchr strdup strerror strtok strftime strlcat strlcpy strptime strstr strtoul timegm tzset])
 
 dnl Checks for RFC 2553 resolver and socket functions
 AC_ARG_ENABLE(ipv6-support,
 
-const char filters_rcs[] = "$Id: filters.c,v 1.151 2011/10/30 16:17:57 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.152 2011/10/30 16:18:12 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
 #include "urlmatch.h"
 #include "loaders.h"
 
+#ifdef HAVE_STRTOK
+/* Only used for locks */
+#include "jcc.h"
+#endif /* def HAVE_STRTOK */
+
 #ifdef _WIN32
 #include "win32.h"
 #endif
    {  
       log_error(LOG_LEVEL_REDIRECTS,
          "Checking \"%s\" for encoded redirects.", subject);
+
+#if defined(MUTEX_LOCKS_AVAILABLE) && defined(HAVE_STRTOK)
       /*
        * Check each parameter in the URL separately.
        * Sectionize the URL at "?" and "&",
        * Keep the last one we spot.
        */
       char *found = NULL;
+
+      privoxy_mutex_lock(&strtok_mutex);
       char *token = strtok(subject, "?&");
       while (token)
       {
             {
                log_error(LOG_LEVEL_ERROR,
                   "Out of memory while searching for redirects.");
+               privoxy_mutex_unlock(&strtok_mutex);
                return NULL;
             }
          }
          freez(dtoken);
          token = strtok(NULL, "?&");
       }
+      privoxy_mutex_unlock(&strtok_mutex);
       freez(subject);
 
       return found;
+#else
+      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);
+      }
+#endif /* defined(MUTEX_LOCKS_AVAILABLE) && defined(HAVE_STRTOK) */
    }
 
    /* Else, just look for a URL inside this one, without decoding anything. */
 
-const char jcc_rcs[] = "$Id: jcc.c,v 1.370 2011/10/23 11:23:35 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.371 2011/10/23 11:24:33 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.c,v $
 privoxy_mutex_t rand_mutex;
 #endif /* ndef HAVE_RANDOM */
 
+#ifdef HAVE_STRTOK
+privoxy_mutex_t strtok_mutex;
+#endif /* def HAVE_STRTOK */
+
 #endif /* def MUTEX_LOCKS_AVAILABLE */
 
 #if defined(unix)
 #ifndef HAVE_RANDOM
    privoxy_mutex_init(&rand_mutex);
 #endif /* ndef HAVE_RANDOM */
+
+#ifdef HAVE_STRTOK
+   privoxy_mutex_init(&strtok_mutex);
+#endif /* def HAVE_STRTOK */
 #endif /* def MUTEX_LOCKS_AVAILABLE */
 }
 
 
 #ifndef JCC_H_INCLUDED
 #define JCC_H_INCLUDED
-#define JCC_H_VERSION "$Id: jcc.h,v 1.29 2010/07/21 14:35:09 fabiankeil Exp $"
+#define JCC_H_VERSION "$Id: jcc.h,v 1.30 2011/09/04 11:10:56 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jcc.h,v $
 extern privoxy_mutex_t rand_mutex;
 #endif /* ndef HAVE_RANDOM */
 
+#ifdef HAVE_STRTOK
+extern privoxy_mutex_t strtok_mutex;
+#endif /* ndef HAVE_STRTOK */
+
 #endif /* FEATURE_PTHREAD */
 
 /* Functions */