/* removeparam_filter.c generated by valac 0.56.19, the Vala compiler
 * generated from removeparam_filter.vala, do not modify */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <gobject/gvaluecollector.h>

#define DC_REMOVE_PARAM_FILTER_DEFAULT_EXPIRES ((gint64) ((5 * 24) * 3600))
#define DC_REMOVE_PARAM_FILTER_DEFAULT_URL "https://filters.adtidy.org/extension/ublock/filters/17.txt"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define DC_TYPE_REMOVE_PARAM_FILTER (dc_remove_param_filter_get_type ())
#define DC_REMOVE_PARAM_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_REMOVE_PARAM_FILTER, DcRemoveParamFilter))
#define DC_REMOVE_PARAM_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_REMOVE_PARAM_FILTER, DcRemoveParamFilterClass))
#define DC_IS_REMOVE_PARAM_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_REMOVE_PARAM_FILTER))
#define DC_IS_REMOVE_PARAM_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_REMOVE_PARAM_FILTER))
#define DC_REMOVE_PARAM_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_REMOVE_PARAM_FILTER, DcRemoveParamFilterClass))

typedef struct _DcRemoveParamFilter DcRemoveParamFilter;
typedef struct _DcRemoveParamFilterClass DcRemoveParamFilterClass;
typedef struct _DcRemoveParamFilterPrivate DcRemoveParamFilterPrivate;

#define DC_REMOVE_PARAM_FILTER_TYPE_RULE (dc_remove_param_filter_rule_get_type ())
#define DC_REMOVE_PARAM_FILTER_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_REMOVE_PARAM_FILTER_TYPE_RULE, DcRemoveParamFilterRule))
#define DC_REMOVE_PARAM_FILTER_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_REMOVE_PARAM_FILTER_TYPE_RULE, DcRemoveParamFilterRuleClass))
#define DC_REMOVE_PARAM_FILTER_IS_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_REMOVE_PARAM_FILTER_TYPE_RULE))
#define DC_REMOVE_PARAM_FILTER_IS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_REMOVE_PARAM_FILTER_TYPE_RULE))
#define DC_REMOVE_PARAM_FILTER_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_REMOVE_PARAM_FILTER_TYPE_RULE, DcRemoveParamFilterRuleClass))

typedef struct _DcRemoveParamFilterRule DcRemoveParamFilterRule;
typedef struct _DcRemoveParamFilterRuleClass DcRemoveParamFilterRuleClass;
enum  {
	DC_REMOVE_PARAM_FILTER_0_PROPERTY,
	DC_REMOVE_PARAM_FILTER_TITLE_PROPERTY,
	DC_REMOVE_PARAM_FILTER_VERSION_PROPERTY,
	DC_REMOVE_PARAM_FILTER_EXPIRES_SECONDS_PROPERTY,
	DC_REMOVE_PARAM_FILTER_RULE_COUNT_PROPERTY,
	DC_REMOVE_PARAM_FILTER_NUM_PROPERTIES
};
static GParamSpec* dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _dc_remove_param_filter_rule_unref0(var) ((var == NULL) ? NULL : (var = (dc_remove_param_filter_rule_unref (var), NULL)))
typedef struct _DcRemoveParamFilterRulePrivate DcRemoveParamFilterRulePrivate;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _DcRemoveParamFilterParamSpecRule DcRemoveParamFilterParamSpecRule;

struct _DcRemoveParamFilter {
	GObject parent_instance;
	DcRemoveParamFilterPrivate * priv;
};

struct _DcRemoveParamFilterClass {
	GObjectClass parent_class;
};

struct _DcRemoveParamFilterPrivate {
	gchar* _title;
	gchar* _version;
	gint64 _expires_seconds;
	DcRemoveParamFilterRule** rules;
	gint rules_length1;
	gint _rules_size_;
};

struct _DcRemoveParamFilterRule {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcRemoveParamFilterRulePrivate * priv;
	gboolean exception;
	gboolean remove_all;
	gboolean inverse;
	gchar* param_name;
	GRegex* param_regex;
	GRegex* pattern;
	gchar* host_hint;
	gchar** domains;
	gint domains_length1;
	gint _domains_size_;
	gchar** not_domains;
	gint not_domains_length1;
	gint _not_domains_size_;
	gchar** denyallow;
	gint denyallow_length1;
	gint _denyallow_size_;
};

struct _DcRemoveParamFilterRuleClass {
	GTypeClass parent_class;
	void (*finalize) (DcRemoveParamFilterRule *self);
};

struct _DcRemoveParamFilterParamSpecRule {
	GParamSpec parent_instance;
};

static gint DcRemoveParamFilter_private_offset;
static gpointer dc_remove_param_filter_parent_class = NULL;
VALA_EXTERN DcRemoveParamFilter* dc_remove_param_filter_active;
DcRemoveParamFilter* dc_remove_param_filter_active = NULL;
static gpointer dc_remove_param_filter_rule_parent_class = NULL;

VALA_EXTERN GType dc_remove_param_filter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRemoveParamFilter, g_object_unref)
static gpointer dc_remove_param_filter_rule_ref (gpointer instance);
static void dc_remove_param_filter_rule_unref (gpointer instance);
static GParamSpec* dc_remove_param_filter_param_spec_rule (const gchar* name,
                                                    const gchar* nick,
                                                    const gchar* blurb,
                                                    GType object_type,
                                                    GParamFlags flags) G_GNUC_UNUSED ;
static void dc_remove_param_filter_value_set_rule (GValue* value,
                                            gpointer v_object) G_GNUC_UNUSED ;
static void dc_remove_param_filter_value_take_rule (GValue* value,
                                             gpointer v_object) G_GNUC_UNUSED ;
static gpointer dc_remove_param_filter_value_get_rule (const GValue* value) G_GNUC_UNUSED ;
static GType dc_remove_param_filter_rule_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRemoveParamFilterRule, dc_remove_param_filter_rule_unref)
VALA_EXTERN gchar* dc_remove_param_filter_cache_path (void);
VALA_EXTERN DcRemoveParamFilter* dc_remove_param_filter_from_text (const gchar* text);
VALA_EXTERN DcRemoveParamFilter* dc_remove_param_filter_new (void);
VALA_EXTERN DcRemoveParamFilter* dc_remove_param_filter_construct (GType object_type);
static void dc_remove_param_filter_parse (DcRemoveParamFilter* self,
                                   const gchar* text);
VALA_EXTERN DcRemoveParamFilter* dc_remove_param_filter_load_cached (void);
VALA_EXTERN gboolean dc_remove_param_filter_save_cached (const gchar* text);
VALA_EXTERN GDateTime* dc_remove_param_filter_cache_time (void);
VALA_EXTERN gboolean dc_remove_param_filter_cache_is_stale (DcRemoveParamFilter* self,
                                                gint64 min_age);
VALA_EXTERN gint64 dc_remove_param_filter_get_expires_seconds (DcRemoveParamFilter* self);
static void dc_remove_param_filter_parse_header (DcRemoveParamFilter* self,
                                          const gchar* line);
static DcRemoveParamFilterRule* dc_remove_param_filter_parse_rule (const gchar* input);
static void _vala_array_add26 (DcRemoveParamFilterRule** * array,
                        gint* length,
                        gint* size,
                        DcRemoveParamFilterRule* value);
static void dc_remove_param_filter_set_title (DcRemoveParamFilter* self,
                                       const gchar* value);
static void dc_remove_param_filter_set_version (DcRemoveParamFilter* self,
                                         const gchar* value);
static void dc_remove_param_filter_set_expires_seconds (DcRemoveParamFilter* self,
                                                 gint64 value);
static DcRemoveParamFilterRule* dc_remove_param_filter_rule_new (void);
static DcRemoveParamFilterRule* dc_remove_param_filter_rule_construct (GType object_type);
static gint dc_remove_param_filter_find_options_separator (const gchar* line);
static gchar** dc_remove_param_filter_split_unescaped (const gchar* s,
                                                gchar sep,
                                                gint* result_length1);
static gboolean dc_remove_param_filter_parse_removeparam_value (DcRemoveParamFilterRule* r,
                                                         const gchar* value);
static gchar* dc_remove_param_filter_unescape (const gchar* s);
static void _vala_array_add27 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add28 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add29 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static gboolean dc_remove_param_filter_compile_pattern (DcRemoveParamFilterRule* r,
                                                 const gchar* pattern,
                                                 gboolean match_case);
static void _vala_array_add30 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add31 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN gchar* dc_remove_param_filter_clean_url (DcRemoveParamFilter* self,
                                         const gchar* url);
static gchar* dc_remove_param_filter_host_of (const gchar* url);
static gboolean dc_remove_param_filter_rule_matches (DcRemoveParamFilterRule* r,
                                              const gchar* url,
                                              const gchar* host);
static gboolean dc_remove_param_filter_param_selected (DcRemoveParamFilterRule* r,
                                                const gchar* pair);
static gboolean dc_remove_param_filter_host_matches (const gchar* host,
                                              const gchar* domain);
static gboolean dc_remove_param_filter_in_domain_list (const gchar* host,
                                                gchar** list,
                                                gint list_length1);
VALA_EXTERN const gchar* dc_remove_param_filter_get_title (DcRemoveParamFilter* self);
VALA_EXTERN const gchar* dc_remove_param_filter_get_version (DcRemoveParamFilter* self);
VALA_EXTERN gint dc_remove_param_filter_get_rule_count (DcRemoveParamFilter* self);
static void dc_remove_param_filter_rule_finalize (DcRemoveParamFilterRule * obj);
static GType dc_remove_param_filter_rule_get_type_once (void);
static void dc_remove_param_filter_finalize (GObject * obj);
static GType dc_remove_param_filter_get_type_once (void);
static void _vala_dc_remove_param_filter_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_dc_remove_param_filter_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_remove_param_filter_get_instance_private (DcRemoveParamFilter* self)
{
	return G_STRUCT_MEMBER_P (self, DcRemoveParamFilter_private_offset);
}

gchar*
dc_remove_param_filter_cache_path (void)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	_tmp0_ = g_get_user_config_dir ();
	_tmp1_ = g_build_filename (_tmp0_, "parla", "tracking_filter.txt", NULL);
	result = _tmp1_;
	return result;
}

/** Parses a filter list; returns null when it holds no usable rule. */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

DcRemoveParamFilter*
dc_remove_param_filter_from_text (const gchar* text)
{
	DcRemoveParamFilter* f = NULL;
	DcRemoveParamFilter* _tmp0_;
	DcRemoveParamFilter* _tmp1_;
	DcRemoveParamFilter* _tmp2_ = NULL;
	DcRemoveParamFilter* _tmp3_;
	DcRemoveParamFilterRule** _tmp4_;
	gint _tmp4__length1;
	DcRemoveParamFilter* _tmp6_;
	DcRemoveParamFilter* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = dc_remove_param_filter_new ();
	f = _tmp0_;
	_tmp1_ = f;
	dc_remove_param_filter_parse (_tmp1_, text);
	_tmp3_ = f;
	_tmp4_ = _tmp3_->priv->rules;
	_tmp4__length1 = _tmp3_->priv->rules_length1;
	if (_tmp4__length1 > 0) {
		DcRemoveParamFilter* _tmp5_;
		_tmp5_ = f;
		_tmp2_ = _tmp5_;
	} else {
		_tmp2_ = NULL;
	}
	_tmp6_ = _g_object_ref0 (_tmp2_);
	result = _tmp6_;
	_g_object_unref0 (f);
	return result;
}

DcRemoveParamFilter*
dc_remove_param_filter_load_cached (void)
{
	gchar* text = NULL;
	const gchar* _tmp3_;
	DcRemoveParamFilter* _tmp4_;
	GError* _inner_error0_ = NULL;
	DcRemoveParamFilter* result;
	{
		gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_ = NULL;
		_tmp0_ = dc_remove_param_filter_cache_path ();
		_tmp1_ = _tmp0_;
		g_file_get_contents (_tmp1_, &_tmp2_, NULL, &_inner_error0_);
		_g_free0 (text);
		text = _tmp2_;
		_g_free0 (_tmp1_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		_g_free0 (text);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (text);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp3_ = text;
	_tmp4_ = dc_remove_param_filter_from_text (_tmp3_);
	result = _tmp4_;
	_g_free0 (text);
	return result;
}

gboolean
dc_remove_param_filter_save_cached (const gchar* text)
{
	gboolean _tmp8_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (text != NULL, FALSE);
	{
		gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp0_ = dc_remove_param_filter_cache_path ();
		_tmp1_ = _tmp0_;
		_tmp2_ = g_path_get_dirname (_tmp1_);
		_tmp3_ = _tmp2_;
		g_mkdir_with_parents (_tmp3_, 0755);
		_g_free0 (_tmp3_);
		_g_free0 (_tmp1_);
		_tmp4_ = dc_remove_param_filter_cache_path ();
		_tmp5_ = _tmp4_;
		g_file_set_contents (_tmp5_, text, (gssize) -1, &_inner_error0_);
		_g_free0 (_tmp5_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		result = TRUE;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_warning ("removeparam_filter.vala:87: tracking filter: cannot save list: %s", _tmp7_);
		result = FALSE;
		_g_error_free0 (e);
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return _tmp8_;
}

/** Modification time of the cached list, null when absent. */
GDateTime*
dc_remove_param_filter_cache_time (void)
{
	GError* _inner_error0_ = NULL;
	GDateTime* result;
	{
		GFileInfo* info = NULL;
		gchar* _tmp0_;
		gchar* _tmp1_;
		GFile* _tmp2_;
		GFile* _tmp3_;
		GFileInfo* _tmp4_;
		GFileInfo* _tmp5_;
		GDateTime* _tmp6_;
		_tmp0_ = dc_remove_param_filter_cache_path ();
		_tmp1_ = _tmp0_;
		_tmp2_ = g_file_new_for_path (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_file_query_info (_tmp3_, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_g_free0 (_tmp1_);
		info = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = g_file_info_get_modification_date_time (info);
		result = _tmp6_;
		_g_object_unref0 (info);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

/** True when the cache is missing or older than the list's own
            expiry (or `min_age` seconds, whichever is larger). */
gboolean
dc_remove_param_filter_cache_is_stale (DcRemoveParamFilter* self,
                                       gint64 min_age)
{
	GDateTime* t = NULL;
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gint64 age = 0LL;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	GDateTime* _tmp4_;
	gint64 _tmp5_;
	gint64 _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = dc_remove_param_filter_cache_time ();
	t = _tmp0_;
	_tmp1_ = t;
	if (_tmp1_ == NULL) {
		result = TRUE;
		_g_date_time_unref0 (t);
		return result;
	}
	_tmp2_ = g_date_time_new_now_utc ();
	_tmp3_ = _tmp2_;
	_tmp4_ = t;
	_tmp5_ = g_date_time_to_unix (_tmp3_) - g_date_time_to_unix (_tmp4_);
	_g_date_time_unref0 (_tmp3_);
	age = _tmp5_;
	_tmp6_ = self->priv->_expires_seconds;
	result = age > MAX (_tmp6_, min_age);
	_g_date_time_unref0 (t);
	return result;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gpointer
_dc_remove_param_filter_rule_ref0 (gpointer self)
{
	return self ? dc_remove_param_filter_rule_ref (self) : NULL;
}

static void
_vala_array_add26 (DcRemoveParamFilterRule** * array,
                   gint* length,
                   gint* size,
                   DcRemoveParamFilterRule* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (DcRemoveParamFilterRule*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
dc_remove_param_filter_parse (DcRemoveParamFilter* self,
                              const gchar* text)
{
	gchar** _tmp0_;
	gchar** _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp1_ = _tmp0_ = g_strsplit (text, "\n", 0);
	{
		gchar** raw_collection = NULL;
		gint raw_collection_length1 = 0;
		gint _raw_collection_size_ = 0;
		gint raw_it = 0;
		raw_collection = _tmp1_;
		raw_collection_length1 = _vala_array_length (_tmp0_);
		for (raw_it = 0; raw_it < raw_collection_length1; raw_it = raw_it + 1) {
			gchar* _tmp2_;
			gchar* raw = NULL;
			_tmp2_ = g_strdup (raw_collection[raw_it]);
			raw = _tmp2_;
			{
				gchar* line = NULL;
				const gchar* _tmp3_;
				gchar* _tmp4_;
				const gchar* _tmp5_;
				gint _tmp6_;
				gint _tmp7_;
				gboolean _tmp8_ = FALSE;
				const gchar* _tmp9_;
				gboolean _tmp12_ = FALSE;
				const gchar* _tmp13_;
				gboolean _tmp19_ = FALSE;
				gboolean _tmp20_ = FALSE;
				gboolean _tmp21_ = FALSE;
				gboolean _tmp22_ = FALSE;
				const gchar* _tmp23_;
				DcRemoveParamFilterRule* r = NULL;
				const gchar* _tmp28_;
				DcRemoveParamFilterRule* _tmp29_;
				DcRemoveParamFilterRule* _tmp30_;
				_tmp3_ = raw;
				_tmp4_ = string_strip (_tmp3_);
				line = _tmp4_;
				_tmp5_ = line;
				_tmp6_ = strlen (_tmp5_);
				_tmp7_ = _tmp6_;
				if (_tmp7_ == 0) {
					_g_free0 (line);
					_g_free0 (raw);
					continue;
				}
				_tmp9_ = line;
				if (string_get (_tmp9_, (glong) 0) == '!') {
					_tmp8_ = TRUE;
				} else {
					const gchar* _tmp10_;
					_tmp10_ = line;
					_tmp8_ = string_get (_tmp10_, (glong) 0) == '[';
				}
				if (_tmp8_) {
					const gchar* _tmp11_;
					_tmp11_ = line;
					dc_remove_param_filter_parse_header (self, _tmp11_);
					_g_free0 (line);
					_g_free0 (raw);
					continue;
				}
				_tmp13_ = line;
				if (string_get (_tmp13_, (glong) 0) == '#') {
					gboolean _tmp14_ = FALSE;
					const gchar* _tmp15_;
					gint _tmp16_;
					gint _tmp17_;
					_tmp15_ = line;
					_tmp16_ = strlen (_tmp15_);
					_tmp17_ = _tmp16_;
					if (_tmp17_ == 1) {
						_tmp14_ = TRUE;
					} else {
						const gchar* _tmp18_;
						_tmp18_ = line;
						_tmp14_ = string_get (_tmp18_, (glong) 1) == ' ';
					}
					_tmp12_ = _tmp14_;
				} else {
					_tmp12_ = FALSE;
				}
				if (_tmp12_) {
					_g_free0 (line);
					_g_free0 (raw);
					continue;
				}
				_tmp23_ = line;
				if (string_contains (_tmp23_, "##")) {
					_tmp22_ = TRUE;
				} else {
					const gchar* _tmp24_;
					_tmp24_ = line;
					_tmp22_ = string_contains (_tmp24_, "#@#");
				}
				if (_tmp22_) {
					_tmp21_ = TRUE;
				} else {
					const gchar* _tmp25_;
					_tmp25_ = line;
					_tmp21_ = string_contains (_tmp25_, "#?#");
				}
				if (_tmp21_) {
					_tmp20_ = TRUE;
				} else {
					const gchar* _tmp26_;
					_tmp26_ = line;
					_tmp20_ = string_contains (_tmp26_, "#$#");
				}
				if (_tmp20_) {
					_tmp19_ = TRUE;
				} else {
					const gchar* _tmp27_;
					_tmp27_ = line;
					_tmp19_ = string_contains (_tmp27_, "$$");
				}
				if (_tmp19_) {
					_g_free0 (line);
					_g_free0 (raw);
					continue;
				}
				_tmp28_ = line;
				_tmp29_ = dc_remove_param_filter_parse_rule (_tmp28_);
				r = _tmp29_;
				_tmp30_ = r;
				if (_tmp30_ != NULL) {
					DcRemoveParamFilterRule* _tmp31_;
					DcRemoveParamFilterRule* _tmp32_;
					_tmp31_ = r;
					_tmp32_ = _dc_remove_param_filter_rule_ref0 (_tmp31_);
					_vala_array_add26 (&self->priv->rules, &self->priv->rules_length1, &self->priv->_rules_size_, _tmp32_);
				}
				_dc_remove_param_filter_rule_unref0 (r);
				_g_free0 (line);
				_g_free0 (raw);
			}
		}
		raw_collection = (_vala_array_free (raw_collection, raw_collection_length1, (GDestroyNotify) g_free), NULL);
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static void
dc_remove_param_filter_parse_header (DcRemoveParamFilter* self,
                                     const gchar* line)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (line != NULL);
	if (g_str_has_prefix (line, "! Title:")) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp0_ = string_substring (line, (glong) 8, (glong) -1);
		_tmp1_ = _tmp0_;
		_tmp2_ = string_strip (_tmp1_);
		_tmp3_ = _tmp2_;
		dc_remove_param_filter_set_title (self, _tmp3_);
		_g_free0 (_tmp3_);
		_g_free0 (_tmp1_);
	} else {
		if (g_str_has_prefix (line, "! Version:")) {
			gchar* _tmp4_;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			_tmp4_ = string_substring (line, (glong) 10, (glong) -1);
			_tmp5_ = _tmp4_;
			_tmp6_ = string_strip (_tmp5_);
			_tmp7_ = _tmp6_;
			dc_remove_param_filter_set_version (self, _tmp7_);
			_g_free0 (_tmp7_);
			_g_free0 (_tmp5_);
		} else {
			if (g_str_has_prefix (line, "! Expires:")) {
				gchar* v = NULL;
				gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				gint n = 0;
				const gchar* _tmp14_;
				_tmp8_ = string_substring (line, (glong) 10, (glong) -1);
				_tmp9_ = _tmp8_;
				_tmp10_ = string_strip (_tmp9_);
				_tmp11_ = _tmp10_;
				_tmp12_ = g_utf8_strdown (_tmp11_, (gssize) -1);
				_tmp13_ = _tmp12_;
				_g_free0 (_tmp11_);
				_g_free0 (_tmp9_);
				v = _tmp13_;
				_tmp14_ = v;
				n = atoi (_tmp14_);
				if (n > 0) {
					const gchar* _tmp15_;
					_tmp15_ = v;
					if (string_contains (_tmp15_, "hour")) {
						dc_remove_param_filter_set_expires_seconds (self, (gint64) (n * 3600));
					} else {
						dc_remove_param_filter_set_expires_seconds (self, (gint64) ((n * 24) * 3600));
					}
				}
				_g_free0 (v);
			}
		}
	}
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gint
string_index_of_char (const gchar* self,
                      gunichar c,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_strchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static void
_vala_array_add27 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add28 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add29 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static DcRemoveParamFilterRule*
dc_remove_param_filter_parse_rule (const gchar* input)
{
	gchar* line = NULL;
	gchar* _tmp0_;
	DcRemoveParamFilterRule* r = NULL;
	DcRemoveParamFilterRule* _tmp1_;
	const gchar* _tmp2_;
	gint sep = 0;
	const gchar* _tmp6_;
	gchar* pattern = NULL;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* options = NULL;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gboolean has_removeparam = FALSE;
	gboolean match_case = FALSE;
	gboolean type_restricted = FALSE;
	gboolean allows_document = FALSE;
	const gchar* _tmp11_;
	gint _tmp12_ = 0;
	gchar** _tmp13_;
	gboolean _tmp70_ = FALSE;
	DcRemoveParamFilterRule* _tmp71_;
	const gchar* _tmp72_;
	DcRemoveParamFilterRule* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = g_strdup (input);
	line = _tmp0_;
	_tmp1_ = dc_remove_param_filter_rule_new ();
	r = _tmp1_;
	_tmp2_ = line;
	if (g_str_has_prefix (_tmp2_, "@@")) {
		DcRemoveParamFilterRule* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = r;
		_tmp3_->exception = TRUE;
		_tmp4_ = line;
		_tmp5_ = string_substring (_tmp4_, (glong) 2, (glong) -1);
		_g_free0 (line);
		line = _tmp5_;
	}
	_tmp6_ = line;
	sep = dc_remove_param_filter_find_options_separator (_tmp6_);
	if (sep < 0) {
		result = NULL;
		_dc_remove_param_filter_rule_unref0 (r);
		_g_free0 (line);
		return result;
	}
	_tmp7_ = line;
	_tmp8_ = string_slice (_tmp7_, (glong) 0, (glong) sep);
	pattern = _tmp8_;
	_tmp9_ = line;
	_tmp10_ = string_substring (_tmp9_, (glong) (sep + 1), (glong) -1);
	options = _tmp10_;
	has_removeparam = FALSE;
	match_case = FALSE;
	type_restricted = FALSE;
	allows_document = FALSE;
	_tmp11_ = options;
	_tmp13_ = dc_remove_param_filter_split_unescaped (_tmp11_, ',', &_tmp12_);
	{
		gchar** opt_collection = NULL;
		gint opt_collection_length1 = 0;
		gint _opt_collection_size_ = 0;
		gint opt_it = 0;
		opt_collection = _tmp13_;
		opt_collection_length1 = _tmp12_;
		for (opt_it = 0; opt_it < opt_collection_length1; opt_it = opt_it + 1) {
			gchar* _tmp14_;
			gchar* opt = NULL;
			_tmp14_ = g_strdup (opt_collection[opt_it]);
			opt = _tmp14_;
			{
				gchar* o = NULL;
				const gchar* _tmp15_;
				gchar* _tmp16_;
				const gchar* _tmp17_;
				gint _tmp18_;
				gint _tmp19_;
				gint eq = 0;
				const gchar* _tmp20_;
				gchar* _tmp21_ = NULL;
				gchar* key = NULL;
				gchar* _tmp26_;
				gchar* _tmp27_ = NULL;
				gchar* val = NULL;
				gchar* _tmp31_;
				const gchar* _tmp32_;
				const gchar* _tmp33_;
				GQuark _tmp35_ = 0U;
				static GQuark _tmp34_label0 = 0;
				static GQuark _tmp34_label1 = 0;
				static GQuark _tmp34_label2 = 0;
				static GQuark _tmp34_label3 = 0;
				static GQuark _tmp34_label4 = 0;
				static GQuark _tmp34_label5 = 0;
				static GQuark _tmp34_label6 = 0;
				static GQuark _tmp34_label7 = 0;
				static GQuark _tmp34_label8 = 0;
				static GQuark _tmp34_label9 = 0;
				static GQuark _tmp34_label10 = 0;
				static GQuark _tmp34_label11 = 0;
				static GQuark _tmp34_label12 = 0;
				static GQuark _tmp34_label13 = 0;
				static GQuark _tmp34_label14 = 0;
				static GQuark _tmp34_label15 = 0;
				static GQuark _tmp34_label16 = 0;
				static GQuark _tmp34_label17 = 0;
				static GQuark _tmp34_label18 = 0;
				static GQuark _tmp34_label19 = 0;
				static GQuark _tmp34_label20 = 0;
				static GQuark _tmp34_label21 = 0;
				static GQuark _tmp34_label22 = 0;
				static GQuark _tmp34_label23 = 0;
				static GQuark _tmp34_label24 = 0;
				static GQuark _tmp34_label25 = 0;
				static GQuark _tmp34_label26 = 0;
				static GQuark _tmp34_label27 = 0;
				static GQuark _tmp34_label28 = 0;
				static GQuark _tmp34_label29 = 0;
				static GQuark _tmp34_label30 = 0;
				static GQuark _tmp34_label31 = 0;
				static GQuark _tmp34_label32 = 0;
				static GQuark _tmp34_label33 = 0;
				static GQuark _tmp34_label34 = 0;
				static GQuark _tmp34_label35 = 0;
				static GQuark _tmp34_label36 = 0;
				static GQuark _tmp34_label37 = 0;
				static GQuark _tmp34_label38 = 0;
				static GQuark _tmp34_label39 = 0;
				static GQuark _tmp34_label40 = 0;
				static GQuark _tmp34_label41 = 0;
				static GQuark _tmp34_label42 = 0;
				static GQuark _tmp34_label43 = 0;
				static GQuark _tmp34_label44 = 0;
				static GQuark _tmp34_label45 = 0;
				static GQuark _tmp34_label46 = 0;
				static GQuark _tmp34_label47 = 0;
				static GQuark _tmp34_label48 = 0;
				static GQuark _tmp34_label49 = 0;
				_tmp15_ = opt;
				_tmp16_ = string_strip (_tmp15_);
				o = _tmp16_;
				_tmp17_ = o;
				_tmp18_ = strlen (_tmp17_);
				_tmp19_ = _tmp18_;
				if (_tmp19_ == 0) {
					_g_free0 (o);
					_g_free0 (opt);
					continue;
				}
				_tmp20_ = o;
				eq = string_index_of_char (_tmp20_, (gunichar) '=', 0);
				if (eq >= 0) {
					const gchar* _tmp22_;
					gchar* _tmp23_;
					_tmp22_ = o;
					_tmp23_ = string_slice (_tmp22_, (glong) 0, (glong) eq);
					_g_free0 (_tmp21_);
					_tmp21_ = _tmp23_;
				} else {
					const gchar* _tmp24_;
					gchar* _tmp25_;
					_tmp24_ = o;
					_tmp25_ = g_strdup (_tmp24_);
					_g_free0 (_tmp21_);
					_tmp21_ = _tmp25_;
				}
				_tmp26_ = _tmp21_;
				_tmp21_ = NULL;
				key = _tmp26_;
				if (eq >= 0) {
					const gchar* _tmp28_;
					gchar* _tmp29_;
					_tmp28_ = o;
					_tmp29_ = string_substring (_tmp28_, (glong) (eq + 1), (glong) -1);
					_g_free0 (_tmp27_);
					_tmp27_ = _tmp29_;
				} else {
					gchar* _tmp30_;
					_tmp30_ = g_strdup ("");
					_g_free0 (_tmp27_);
					_tmp27_ = _tmp30_;
				}
				_tmp31_ = _tmp27_;
				_tmp27_ = NULL;
				val = _tmp31_;
				_tmp32_ = key;
				_tmp33_ = _tmp32_;
				_tmp35_ = (NULL == _tmp33_) ? 0 : g_quark_from_string (_tmp33_);
				if ((_tmp35_ == ((0 != _tmp34_label0) ? _tmp34_label0 : (_tmp34_label0 = g_quark_from_static_string ("removeparam")))) || (_tmp35_ == ((0 != _tmp34_label1) ? _tmp34_label1 : (_tmp34_label1 = g_quark_from_static_string ("queryprune"))))) {
					switch (0) {
						default:
						{
							DcRemoveParamFilterRule* _tmp36_;
							const gchar* _tmp37_;
							gchar* _tmp38_;
							gchar* _tmp39_;
							gboolean _tmp40_;
							has_removeparam = TRUE;
							_tmp36_ = r;
							_tmp37_ = val;
							_tmp38_ = dc_remove_param_filter_unescape (_tmp37_);
							_tmp39_ = _tmp38_;
							_tmp40_ = !dc_remove_param_filter_parse_removeparam_value (_tmp36_, _tmp39_);
							_g_free0 (_tmp39_);
							if (_tmp40_) {
								result = NULL;
								_g_free0 (val);
								_g_free0 (_tmp27_);
								_g_free0 (key);
								_g_free0 (_tmp21_);
								_g_free0 (o);
								_g_free0 (opt);
								opt_collection = (_vala_array_free (opt_collection, opt_collection_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (options);
								_g_free0 (pattern);
								_dc_remove_param_filter_rule_unref0 (r);
								_g_free0 (line);
								return result;
							}
							break;
						}
					}
				} else if ((_tmp35_ == ((0 != _tmp34_label2) ? _tmp34_label2 : (_tmp34_label2 = g_quark_from_static_string ("domain")))) || (_tmp35_ == ((0 != _tmp34_label3) ? _tmp34_label3 : (_tmp34_label3 = g_quark_from_static_string ("from"))))) {
					switch (0) {
						default:
						{
							const gchar* _tmp41_;
							gchar** _tmp42_;
							gchar** _tmp43_;
							_tmp41_ = val;
							_tmp43_ = _tmp42_ = g_strsplit (_tmp41_, "|", 0);
							{
								gchar** d_collection = NULL;
								gint d_collection_length1 = 0;
								gint _d_collection_size_ = 0;
								gint d_it = 0;
								d_collection = _tmp43_;
								d_collection_length1 = _vala_array_length (_tmp42_);
								for (d_it = 0; d_it < d_collection_length1; d_it = d_it + 1) {
									gchar* _tmp44_;
									gchar* d = NULL;
									_tmp44_ = g_strdup (d_collection[d_it]);
									d = _tmp44_;
									{
										const gchar* _tmp45_;
										gint _tmp46_;
										gint _tmp47_;
										const gchar* _tmp48_;
										_tmp45_ = d;
										_tmp46_ = strlen (_tmp45_);
										_tmp47_ = _tmp46_;
										if (_tmp47_ == 0) {
											_g_free0 (d);
											continue;
										}
										_tmp48_ = d;
										if (string_get (_tmp48_, (glong) 0) == '~') {
											DcRemoveParamFilterRule* _tmp49_;
											DcRemoveParamFilterRule* _tmp50_;
											const gchar* _tmp51_;
											gchar* _tmp52_;
											gchar* _tmp53_;
											gchar* _tmp54_;
											_tmp49_ = r;
											_tmp50_ = r;
											_tmp51_ = d;
											_tmp52_ = string_substring (_tmp51_, (glong) 1, (glong) -1);
											_tmp53_ = _tmp52_;
											_tmp54_ = g_utf8_strdown (_tmp53_, (gssize) -1);
											_vala_array_add27 (&_tmp49_->not_domains, &_tmp49_->not_domains_length1, &_tmp49_->_not_domains_size_, _tmp54_);
											_g_free0 (_tmp53_);
										} else {
											DcRemoveParamFilterRule* _tmp55_;
											DcRemoveParamFilterRule* _tmp56_;
											const gchar* _tmp57_;
											gchar* _tmp58_;
											_tmp55_ = r;
											_tmp56_ = r;
											_tmp57_ = d;
											_tmp58_ = g_utf8_strdown (_tmp57_, (gssize) -1);
											_vala_array_add28 (&_tmp55_->domains, &_tmp55_->domains_length1, &_tmp55_->_domains_size_, _tmp58_);
										}
										_g_free0 (d);
									}
								}
								d_collection = (_vala_array_free (d_collection, d_collection_length1, (GDestroyNotify) g_free), NULL);
							}
							break;
						}
					}
				} else if (_tmp35_ == ((0 != _tmp34_label4) ? _tmp34_label4 : (_tmp34_label4 = g_quark_from_static_string ("denyallow")))) {
					switch (0) {
						default:
						{
							const gchar* _tmp59_;
							gchar** _tmp60_;
							gchar** _tmp61_;
							_tmp59_ = val;
							_tmp61_ = _tmp60_ = g_strsplit (_tmp59_, "|", 0);
							{
								gchar** d_collection = NULL;
								gint d_collection_length1 = 0;
								gint _d_collection_size_ = 0;
								gint d_it = 0;
								d_collection = _tmp61_;
								d_collection_length1 = _vala_array_length (_tmp60_);
								for (d_it = 0; d_it < d_collection_length1; d_it = d_it + 1) {
									gchar* _tmp62_;
									gchar* d = NULL;
									_tmp62_ = g_strdup (d_collection[d_it]);
									d = _tmp62_;
									{
										const gchar* _tmp63_;
										gint _tmp64_;
										gint _tmp65_;
										_tmp63_ = d;
										_tmp64_ = strlen (_tmp63_);
										_tmp65_ = _tmp64_;
										if (_tmp65_ > 0) {
											DcRemoveParamFilterRule* _tmp66_;
											DcRemoveParamFilterRule* _tmp67_;
											const gchar* _tmp68_;
											gchar* _tmp69_;
											_tmp66_ = r;
											_tmp67_ = r;
											_tmp68_ = d;
											_tmp69_ = g_utf8_strdown (_tmp68_, (gssize) -1);
											_vala_array_add29 (&_tmp66_->denyallow, &_tmp66_->denyallow_length1, &_tmp66_->_denyallow_size_, _tmp69_);
										}
										_g_free0 (d);
									}
								}
								d_collection = (_vala_array_free (d_collection, d_collection_length1, (GDestroyNotify) g_free), NULL);
							}
							break;
						}
					}
				} else if (_tmp35_ == ((0 != _tmp34_label5) ? _tmp34_label5 : (_tmp34_label5 = g_quark_from_static_string ("match-case")))) {
					switch (0) {
						default:
						{
							match_case = TRUE;
							break;
						}
					}
				} else if (((_tmp35_ == ((0 != _tmp34_label6) ? _tmp34_label6 : (_tmp34_label6 = g_quark_from_static_string ("document")))) || (_tmp35_ == ((0 != _tmp34_label7) ? _tmp34_label7 : (_tmp34_label7 = g_quark_from_static_string ("doc"))))) || (_tmp35_ == ((0 != _tmp34_label8) ? _tmp34_label8 : (_tmp34_label8 = g_quark_from_static_string ("all"))))) {
					switch (0) {
						default:
						{
							type_restricted = TRUE;
							allows_document = TRUE;
							break;
						}
					}
				} else if ((_tmp35_ == ((0 != _tmp34_label9) ? _tmp34_label9 : (_tmp34_label9 = g_quark_from_static_string ("~document")))) || (_tmp35_ == ((0 != _tmp34_label10) ? _tmp34_label10 : (_tmp34_label10 = g_quark_from_static_string ("~doc"))))) {
					switch (0) {
						default:
						{
							result = NULL;
							_g_free0 (val);
							_g_free0 (_tmp27_);
							_g_free0 (key);
							_g_free0 (_tmp21_);
							_g_free0 (o);
							_g_free0 (opt);
							opt_collection = (_vala_array_free (opt_collection, opt_collection_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (options);
							_g_free0 (pattern);
							_dc_remove_param_filter_rule_unref0 (r);
							_g_free0 (line);
							return result;
						}
					}
				} else if (((((((((((((((((_tmp35_ == ((0 != _tmp34_label11) ? _tmp34_label11 : (_tmp34_label11 = g_quark_from_static_string ("xhr")))) || (_tmp35_ == ((0 != _tmp34_label12) ? _tmp34_label12 : (_tmp34_label12 = g_quark_from_static_string ("xmlhttprequest"))))) || (_tmp35_ == ((0 != _tmp34_label13) ? _tmp34_label13 : (_tmp34_label13 = g_quark_from_static_string ("script"))))) || (_tmp35_ == ((0 != _tmp34_label14) ? _tmp34_label14 : (_tmp34_label14 = g_quark_from_static_string ("image"))))) || (_tmp35_ == ((0 != _tmp34_label15) ? _tmp34_label15 : (_tmp34_label15 = g_quark_from_static_string ("font"))))) || (_tmp35_ == ((0 != _tmp34_label16) ? _tmp34_label16 : (_tmp34_label16 = g_quark_from_static_string ("media"))))) || (_tmp35_ == ((0 != _tmp34_label17) ? _tmp34_label17 : (_tmp34_label17 = g_quark_from_static_string ("stylesheet"))))) || (_tmp35_ == ((0 != _tmp34_label18) ? _tmp34_label18 : (_tmp34_label18 = g_quark_from_static_string ("css"))))) || (_tmp35_ == ((0 != _tmp34_label19) ? _tmp34_label19 : (_tmp34_label19 = g_quark_from_static_string ("subdocument"))))) || (_tmp35_ == ((0 != _tmp34_label20) ? _tmp34_label20 : (_tmp34_label20 = g_quark_from_static_string ("frame"))))) || (_tmp35_ == ((0 != _tmp34_label21) ? _tmp34_label21 : (_tmp34_label21 = g_quark_from_static_string ("object"))))) || (_tmp35_ == ((0 != _tmp34_label22) ? _tmp34_label22 : (_tmp34_label22 = g_quark_from_static_string ("ping"))))) || (_tmp35_ == ((0 != _tmp34_label23) ? _tmp34_label23 : (_tmp34_label23 = g_quark_from_static_string ("beacon"))))) || (_tmp35_ == ((0 != _tmp34_label24) ? _tmp34_label24 : (_tmp34_label24 = g_quark_from_static_string ("websocket"))))) || (_tmp35_ == ((0 != _tmp34_label25) ? _tmp34_label25 : (_tmp34_label25 = g_quark_from_static_string ("other"))))) || (_tmp35_ == ((0 != _tmp34_label26) ? _tmp34_label26 : (_tmp34_label26 = g_quark_from_static_string ("webrtc"))))) || (_tmp35_ == ((0 != _tmp34_label27) ? _tmp34_label27 : (_tmp34_label27 = g_quark_from_static_string ("popup"))))) {
					switch (0) {
						default:
						{
							type_restricted = TRUE;
							break;
						}
					}
				} else if (((((((((((((((((((((_tmp35_ == ((0 != _tmp34_label28) ? _tmp34_label28 : (_tmp34_label28 = g_quark_from_static_string ("3p")))) || (_tmp35_ == ((0 != _tmp34_label29) ? _tmp34_label29 : (_tmp34_label29 = g_quark_from_static_string ("~3p"))))) || (_tmp35_ == ((0 != _tmp34_label30) ? _tmp34_label30 : (_tmp34_label30 = g_quark_from_static_string ("third-party"))))) || (_tmp35_ == ((0 != _tmp34_label31) ? _tmp34_label31 : (_tmp34_label31 = g_quark_from_static_string ("~third-party"))))) || (_tmp35_ == ((0 != _tmp34_label32) ? _tmp34_label32 : (_tmp34_label32 = g_quark_from_static_string ("1p"))))) || (_tmp35_ == ((0 != _tmp34_label33) ? _tmp34_label33 : (_tmp34_label33 = g_quark_from_static_string ("~1p"))))) || (_tmp35_ == ((0 != _tmp34_label34) ? _tmp34_label34 : (_tmp34_label34 = g_quark_from_static_string ("first-party"))))) || (_tmp35_ == ((0 != _tmp34_label35) ? _tmp34_label35 : (_tmp34_label35 = g_quark_from_static_string ("~first-party"))))) || (_tmp35_ == ((0 != _tmp34_label36) ? _tmp34_label36 : (_tmp34_label36 = g_quark_from_static_string ("important"))))) || (_tmp35_ == ((0 != _tmp34_label37) ? _tmp34_label37 : (_tmp34_label37 = g_quark_from_static_string ("app"))))) || (_tmp35_ == ((0 != _tmp34_label38) ? _tmp34_label38 : (_tmp34_label38 = g_quark_from_static_string ("~xhr"))))) || (_tmp35_ == ((0 != _tmp34_label39) ? _tmp34_label39 : (_tmp34_label39 = g_quark_from_static_string ("~script"))))) || (_tmp35_ == ((0 != _tmp34_label40) ? _tmp34_label40 : (_tmp34_label40 = g_quark_from_static_string ("~image"))))) || (_tmp35_ == ((0 != _tmp34_label41) ? _tmp34_label41 : (_tmp34_label41 = g_quark_from_static_string ("~font"))))) || (_tmp35_ == ((0 != _tmp34_label42) ? _tmp34_label42 : (_tmp34_label42 = g_quark_from_static_string ("~media"))))) || (_tmp35_ == ((0 != _tmp34_label43) ? _tmp34_label43 : (_tmp34_label43 = g_quark_from_static_string ("~stylesheet"))))) || (_tmp35_ == ((0 != _tmp34_label44) ? _tmp34_label44 : (_tmp34_label44 = g_quark_from_static_string ("~subdocument"))))) || (_tmp35_ == ((0 != _tmp34_label45) ? _tmp34_label45 : (_tmp34_label45 = g_quark_from_static_string ("~object"))))) || (_tmp35_ == ((0 != _tmp34_label46) ? _tmp34_label46 : (_tmp34_label46 = g_quark_from_static_string ("~ping"))))) || (_tmp35_ == ((0 != _tmp34_label47) ? _tmp34_label47 : (_tmp34_label47 = g_quark_from_static_string ("~websocket"))))) || (_tmp35_ == ((0 != _tmp34_label48) ? _tmp34_label48 : (_tmp34_label48 = g_quark_from_static_string ("~other"))))) {
					switch (0) {
						default:
						{
							break;
						}
					}
				} else if (_tmp35_ == ((0 != _tmp34_label49) ? _tmp34_label49 : (_tmp34_label49 = g_quark_from_static_string ("badfilter")))) {
					switch (0) {
						default:
						{
							result = NULL;
							_g_free0 (val);
							_g_free0 (_tmp27_);
							_g_free0 (key);
							_g_free0 (_tmp21_);
							_g_free0 (o);
							_g_free0 (opt);
							opt_collection = (_vala_array_free (opt_collection, opt_collection_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (options);
							_g_free0 (pattern);
							_dc_remove_param_filter_rule_unref0 (r);
							_g_free0 (line);
							return result;
						}
					}
				} else {
					switch (0) {
						default:
						{
							result = NULL;
							_g_free0 (val);
							_g_free0 (_tmp27_);
							_g_free0 (key);
							_g_free0 (_tmp21_);
							_g_free0 (o);
							_g_free0 (opt);
							opt_collection = (_vala_array_free (opt_collection, opt_collection_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (options);
							_g_free0 (pattern);
							_dc_remove_param_filter_rule_unref0 (r);
							_g_free0 (line);
							return result;
						}
					}
				}
				_g_free0 (val);
				_g_free0 (_tmp27_);
				_g_free0 (key);
				_g_free0 (_tmp21_);
				_g_free0 (o);
				_g_free0 (opt);
			}
		}
		opt_collection = (_vala_array_free (opt_collection, opt_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	if (!has_removeparam) {
		result = NULL;
		_g_free0 (options);
		_g_free0 (pattern);
		_dc_remove_param_filter_rule_unref0 (r);
		_g_free0 (line);
		return result;
	}
	if (type_restricted) {
		_tmp70_ = !allows_document;
	} else {
		_tmp70_ = FALSE;
	}
	if (_tmp70_) {
		result = NULL;
		_g_free0 (options);
		_g_free0 (pattern);
		_dc_remove_param_filter_rule_unref0 (r);
		_g_free0 (line);
		return result;
	}
	_tmp71_ = r;
	_tmp72_ = pattern;
	if (!dc_remove_param_filter_compile_pattern (_tmp71_, _tmp72_, match_case)) {
		result = NULL;
		_g_free0 (options);
		_g_free0 (pattern);
		_dc_remove_param_filter_rule_unref0 (r);
		_g_free0 (line);
		return result;
	}
	result = r;
	_g_free0 (options);
	_g_free0 (pattern);
	_g_free0 (line);
	return result;
}

static gboolean
dc_remove_param_filter_parse_removeparam_value (DcRemoveParamFilterRule* r,
                                                const gchar* value)
{
	gchar* v = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	const gchar* _tmp4_;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	const gchar* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (r != NULL, FALSE);
	g_return_val_if_fail (value != NULL, FALSE);
	_tmp0_ = g_strdup (value);
	v = _tmp0_;
	_tmp1_ = v;
	_tmp2_ = strlen (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == 0) {
		r->remove_all = TRUE;
		result = TRUE;
		_g_free0 (v);
		return result;
	}
	_tmp4_ = v;
	if (string_get (_tmp4_, (glong) 0) == '~') {
		const gchar* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		r->inverse = TRUE;
		_tmp5_ = v;
		_tmp6_ = string_substring (_tmp5_, (glong) 1, (glong) -1);
		_g_free0 (v);
		v = _tmp6_;
		_tmp7_ = v;
		_tmp8_ = strlen (_tmp7_);
		_tmp9_ = _tmp8_;
		if (_tmp9_ == 0) {
			result = FALSE;
			_g_free0 (v);
			return result;
		}
	}
	_tmp12_ = v;
	_tmp13_ = strlen (_tmp12_);
	_tmp14_ = _tmp13_;
	if (_tmp14_ >= 2) {
		const gchar* _tmp15_;
		_tmp15_ = v;
		_tmp11_ = string_get (_tmp15_, (glong) 0) == '/';
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		_tmp16_ = v;
		_tmp17_ = v;
		_tmp18_ = strlen (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp10_ = string_get (_tmp16_, (glong) (_tmp19_ - 1)) == '/';
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		{
			GRegex* _tmp20_ = NULL;
			const gchar* _tmp21_;
			const gchar* _tmp22_;
			gint _tmp23_;
			gint _tmp24_;
			gchar* _tmp25_;
			gchar* _tmp26_;
			GRegex* _tmp27_;
			GRegex* _tmp28_;
			GRegex* _tmp29_;
			_tmp21_ = v;
			_tmp22_ = v;
			_tmp23_ = strlen (_tmp22_);
			_tmp24_ = _tmp23_;
			_tmp25_ = string_slice (_tmp21_, (glong) 1, (glong) (_tmp24_ - 1));
			_tmp26_ = _tmp25_;
			_tmp27_ = g_regex_new (_tmp26_, G_REGEX_OPTIMIZE, 0, &_inner_error0_);
			_tmp28_ = _tmp27_;
			_g_free0 (_tmp26_);
			_tmp20_ = _tmp28_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp29_ = _tmp20_;
			_tmp20_ = NULL;
			_g_regex_unref0 (r->param_regex);
			r->param_regex = _tmp29_;
			_g_regex_unref0 (_tmp20_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			const gchar* _tmp30_;
			GError* _tmp31_;
			const gchar* _tmp32_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp30_ = v;
			_tmp31_ = e;
			_tmp32_ = _tmp31_->message;
			g_debug ("removeparam_filter.vala:251: tracking filter: bad param regex %s: %s", _tmp30_, _tmp32_);
			result = FALSE;
			_g_error_free0 (e);
			_g_free0 (v);
			return result;
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp33_ = FALSE;
			_g_free0 (v);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp33_;
		}
	} else {
		const gchar* _tmp34_;
		gchar* _tmp35_;
		_tmp34_ = v;
		_tmp35_ = g_strdup (_tmp34_);
		_g_free0 (r->param_name);
		r->param_name = _tmp35_;
	}
	result = TRUE;
	_g_free0 (v);
	return result;
}

static gint
dc_remove_param_filter_find_options_separator (const gchar* line)
{
	gint idx = 0;
	gint result;
	g_return_val_if_fail (line != NULL, -1);
	idx = string_index_of_char (line, (gunichar) '$', 0);
	while (TRUE) {
		gboolean _tmp0_ = FALSE;
		gint i = 0;
		gboolean _tmp1_ = FALSE;
		gint _tmp2_;
		gint _tmp3_;
		gint name_start = 0;
		gboolean _tmp11_ = FALSE;
		if (!(idx >= 0)) {
			break;
		}
		if (idx > 0) {
			_tmp0_ = string_get (line, (glong) (idx - 1)) == '\\';
		} else {
			_tmp0_ = FALSE;
		}
		if (_tmp0_) {
			idx = string_index_of_char (line, (gunichar) '$', idx + 1);
			continue;
		}
		i = idx + 1;
		_tmp2_ = strlen (line);
		_tmp3_ = _tmp2_;
		if (i < _tmp3_) {
			_tmp1_ = string_get (line, (glong) i) == '~';
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			gint _tmp4_;
			_tmp4_ = i;
			i = _tmp4_ + 1;
		}
		name_start = i;
		while (TRUE) {
			gboolean _tmp5_ = FALSE;
			gint _tmp6_;
			gint _tmp7_;
			gint _tmp10_;
			_tmp6_ = strlen (line);
			_tmp7_ = _tmp6_;
			if (i < _tmp7_) {
				gboolean _tmp8_ = FALSE;
				gboolean _tmp9_ = FALSE;
				if (g_ascii_isalnum (string_get (line, (glong) i))) {
					_tmp9_ = TRUE;
				} else {
					_tmp9_ = string_get (line, (glong) i) == '-';
				}
				if (_tmp9_) {
					_tmp8_ = TRUE;
				} else {
					_tmp8_ = string_get (line, (glong) i) == '_';
				}
				_tmp5_ = _tmp8_;
			} else {
				_tmp5_ = FALSE;
			}
			if (!_tmp5_) {
				break;
			}
			_tmp10_ = i;
			i = _tmp10_ + 1;
		}
		if (i > name_start) {
			gboolean _tmp12_ = FALSE;
			gboolean _tmp13_ = FALSE;
			gint _tmp14_;
			gint _tmp15_;
			_tmp14_ = strlen (line);
			_tmp15_ = _tmp14_;
			if (i == _tmp15_) {
				_tmp13_ = TRUE;
			} else {
				_tmp13_ = string_get (line, (glong) i) == '=';
			}
			if (_tmp13_) {
				_tmp12_ = TRUE;
			} else {
				_tmp12_ = string_get (line, (glong) i) == ',';
			}
			_tmp11_ = _tmp12_;
		} else {
			_tmp11_ = FALSE;
		}
		if (_tmp11_) {
			result = idx;
			return result;
		}
		idx = string_index_of_char (line, (gunichar) '$', idx + 1);
	}
	result = -1;
	return result;
}

static void
_vala_array_add30 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add31 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar**
dc_remove_param_filter_split_unescaped (const gchar* s,
                                        gchar sep,
                                        gint* result_length1)
{
	gchar** parts = NULL;
	gchar** _tmp0_;
	gint parts_length1;
	gint _parts_size_;
	GString* cur = NULL;
	GString* _tmp1_;
	GString* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	gchar** result;
	g_return_val_if_fail (s != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	parts = _tmp0_;
	parts_length1 = 0;
	_parts_size_ = parts_length1;
	_tmp1_ = g_string_new ("");
	cur = _tmp1_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint _tmp4_;
				gint _tmp5_;
				gchar c = '\0';
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = strlen (s);
				_tmp5_ = _tmp4_;
				if (!(i < _tmp5_)) {
					break;
				}
				c = string_get (s, (glong) i);
				if (c == '\\') {
					gint _tmp8_;
					gint _tmp9_;
					_tmp8_ = strlen (s);
					_tmp9_ = _tmp8_;
					_tmp7_ = (i + 1) < _tmp9_;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = string_get (s, (glong) (i + 1)) == sep;
				} else {
					_tmp6_ = FALSE;
				}
				if (_tmp6_) {
					GString* _tmp10_;
					GString* _tmp11_;
					gint _tmp12_;
					_tmp10_ = cur;
					g_string_append_c (_tmp10_, '\\');
					_tmp11_ = cur;
					g_string_append_c (_tmp11_, sep);
					_tmp12_ = i;
					i = _tmp12_ + 1;
				} else {
					if (c == sep) {
						GString* _tmp13_;
						const gchar* _tmp14_;
						gchar* _tmp15_;
						GString* _tmp16_;
						_tmp13_ = cur;
						_tmp14_ = _tmp13_->str;
						_tmp15_ = g_strdup (_tmp14_);
						_vala_array_add30 (&parts, &parts_length1, &_parts_size_, _tmp15_);
						_tmp16_ = cur;
						g_string_truncate (_tmp16_, (gsize) 0);
					} else {
						GString* _tmp17_;
						_tmp17_ = cur;
						g_string_append_c (_tmp17_, c);
					}
				}
			}
		}
	}
	_tmp18_ = cur;
	_tmp19_ = _tmp18_->str;
	_tmp20_ = g_strdup (_tmp19_);
	_vala_array_add31 (&parts, &parts_length1, &_parts_size_, _tmp20_);
	_tmp21_ = parts;
	_tmp21__length1 = parts_length1;
	if (result_length1) {
		*result_length1 = _tmp21__length1;
	}
	result = _tmp21_;
	_g_string_free0 (cur);
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static gchar*
dc_remove_param_filter_unescape (const gchar* s)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (s != NULL, NULL);
	_tmp0_ = string_replace (s, "\\,", ",");
	_tmp1_ = _tmp0_;
	_tmp2_ = string_replace (_tmp1_, "\\\\$", "\\$");
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}

static gboolean
dc_remove_param_filter_compile_pattern (DcRemoveParamFilterRule* r,
                                        const gchar* pattern,
                                        gboolean match_case)
{
	gchar* p = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GRegexCompileFlags _tmp6_ = 0U;
	GRegexCompileFlags flags = 0U;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	GString* re = NULL;
	GString* _tmp31_;
	gint i = 0;
	const gchar* _tmp32_;
	gint end = 0;
	const gchar* _tmp66_;
	gint _tmp67_;
	gint _tmp68_;
	gboolean anchor_end = FALSE;
	gboolean _tmp69_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (r != NULL, FALSE);
	g_return_val_if_fail (pattern != NULL, FALSE);
	_tmp0_ = g_strdup (pattern);
	p = _tmp0_;
	_tmp2_ = p;
	_tmp3_ = strlen (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_ == 0) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp5_;
		_tmp5_ = p;
		_tmp1_ = g_strcmp0 (_tmp5_, "*") == 0;
	}
	if (_tmp1_) {
		result = TRUE;
		_g_free0 (p);
		return result;
	}
	if (match_case) {
		_tmp6_ = G_REGEX_OPTIMIZE;
	} else {
		_tmp6_ = G_REGEX_OPTIMIZE | G_REGEX_CASELESS;
	}
	flags = _tmp6_;
	_tmp9_ = p;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ > 2) {
		const gchar* _tmp12_;
		_tmp12_ = p;
		_tmp8_ = string_get (_tmp12_, (glong) 0) == '/';
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		_tmp13_ = p;
		_tmp14_ = p;
		_tmp15_ = strlen (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp7_ = string_get (_tmp13_, (glong) (_tmp16_ - 1)) == '/';
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		gboolean _tmp30_ = FALSE;
		{
			GRegex* _tmp17_ = NULL;
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			gint _tmp20_;
			gint _tmp21_;
			gchar* _tmp22_;
			gchar* _tmp23_;
			GRegex* _tmp24_;
			GRegex* _tmp25_;
			GRegex* _tmp26_;
			_tmp18_ = p;
			_tmp19_ = p;
			_tmp20_ = strlen (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = string_slice (_tmp18_, (glong) 1, (glong) (_tmp21_ - 1));
			_tmp23_ = _tmp22_;
			_tmp24_ = g_regex_new (_tmp23_, flags, 0, &_inner_error0_);
			_tmp25_ = _tmp24_;
			_g_free0 (_tmp23_);
			_tmp17_ = _tmp25_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp26_ = _tmp17_;
			_tmp17_ = NULL;
			_g_regex_unref0 (r->pattern);
			r->pattern = _tmp26_;
			result = TRUE;
			_g_regex_unref0 (_tmp17_);
			_g_free0 (p);
			return result;
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			const gchar* _tmp27_;
			GError* _tmp28_;
			const gchar* _tmp29_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp27_ = p;
			_tmp28_ = e;
			_tmp29_ = _tmp28_->message;
			g_debug ("removeparam_filter.vala:323: tracking filter: bad pattern %s: %s", _tmp27_, _tmp29_);
			result = FALSE;
			_g_error_free0 (e);
			_g_free0 (p);
			return result;
		}
		__finally0:
		_g_free0 (p);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp30_;
	}
	_tmp31_ = g_string_new ("");
	re = _tmp31_;
	i = 0;
	_tmp32_ = p;
	if (g_str_has_prefix (_tmp32_, "||")) {
		GString* _tmp33_;
		gint j = 0;
		gboolean _tmp46_ = FALSE;
		gboolean _tmp47_ = FALSE;
		gboolean _tmp48_ = FALSE;
		gboolean _tmp49_ = FALSE;
		const gchar* _tmp50_;
		gint _tmp51_;
		gint _tmp52_;
		gboolean boundary = FALSE;
		gboolean _tmp57_ = FALSE;
		gboolean _tmp58_ = FALSE;
		_tmp33_ = re;
		g_string_append (_tmp33_, "^[a-z][a-z0-9+.-]*://(?:[^/?#]*@)?(?:[^/?#]*\\.)?");
		i = 2;
		j = i;
		while (TRUE) {
			gboolean _tmp34_ = FALSE;
			const gchar* _tmp35_;
			gint _tmp36_;
			gint _tmp37_;
			gint _tmp45_;
			_tmp35_ = p;
			_tmp36_ = strlen (_tmp35_);
			_tmp37_ = _tmp36_;
			if (j < _tmp37_) {
				gboolean _tmp38_ = FALSE;
				gboolean _tmp39_ = FALSE;
				gboolean _tmp40_ = FALSE;
				const gchar* _tmp41_;
				_tmp41_ = p;
				if (g_ascii_isalnum (string_get (_tmp41_, (glong) j))) {
					_tmp40_ = TRUE;
				} else {
					const gchar* _tmp42_;
					_tmp42_ = p;
					_tmp40_ = string_get (_tmp42_, (glong) j) == '.';
				}
				if (_tmp40_) {
					_tmp39_ = TRUE;
				} else {
					const gchar* _tmp43_;
					_tmp43_ = p;
					_tmp39_ = string_get (_tmp43_, (glong) j) == '-';
				}
				if (_tmp39_) {
					_tmp38_ = TRUE;
				} else {
					const gchar* _tmp44_;
					_tmp44_ = p;
					_tmp38_ = string_get (_tmp44_, (glong) j) == '_';
				}
				_tmp34_ = _tmp38_;
			} else {
				_tmp34_ = FALSE;
			}
			if (!_tmp34_) {
				break;
			}
			_tmp45_ = j;
			j = _tmp45_ + 1;
		}
		_tmp50_ = p;
		_tmp51_ = strlen (_tmp50_);
		_tmp52_ = _tmp51_;
		if (j == _tmp52_) {
			_tmp49_ = TRUE;
		} else {
			const gchar* _tmp53_;
			_tmp53_ = p;
			_tmp49_ = string_get (_tmp53_, (glong) j) == '^';
		}
		if (_tmp49_) {
			_tmp48_ = TRUE;
		} else {
			const gchar* _tmp54_;
			_tmp54_ = p;
			_tmp48_ = string_get (_tmp54_, (glong) j) == '/';
		}
		if (_tmp48_) {
			_tmp47_ = TRUE;
		} else {
			const gchar* _tmp55_;
			_tmp55_ = p;
			_tmp47_ = string_get (_tmp55_, (glong) j) == '?';
		}
		if (_tmp47_) {
			_tmp46_ = TRUE;
		} else {
			const gchar* _tmp56_;
			_tmp56_ = p;
			_tmp46_ = string_get (_tmp56_, (glong) j) == '|';
		}
		boundary = _tmp46_;
		if (j > i) {
			_tmp58_ = boundary;
		} else {
			_tmp58_ = FALSE;
		}
		if (_tmp58_) {
			const gchar* _tmp59_;
			_tmp59_ = p;
			_tmp57_ = string_get (_tmp59_, (glong) (j - 1)) != '.';
		} else {
			_tmp57_ = FALSE;
		}
		if (_tmp57_) {
			const gchar* _tmp60_;
			gchar* _tmp61_;
			gchar* _tmp62_;
			gchar* _tmp63_;
			_tmp60_ = p;
			_tmp61_ = string_slice (_tmp60_, (glong) i, (glong) j);
			_tmp62_ = _tmp61_;
			_tmp63_ = g_utf8_strdown (_tmp62_, (gssize) -1);
			_g_free0 (r->host_hint);
			r->host_hint = _tmp63_;
			_g_free0 (_tmp62_);
		}
	} else {
		const gchar* _tmp64_;
		_tmp64_ = p;
		if (g_str_has_prefix (_tmp64_, "|")) {
			GString* _tmp65_;
			_tmp65_ = re;
			g_string_append_c (_tmp65_, '^');
			i = 1;
		}
	}
	_tmp66_ = p;
	_tmp67_ = strlen (_tmp66_);
	_tmp68_ = _tmp67_;
	end = _tmp68_;
	anchor_end = FALSE;
	if (end > i) {
		const gchar* _tmp70_;
		_tmp70_ = p;
		_tmp69_ = string_get (_tmp70_, (glong) (end - 1)) == '|';
	} else {
		_tmp69_ = FALSE;
	}
	if (_tmp69_) {
		gint _tmp71_;
		anchor_end = TRUE;
		_tmp71_ = end;
		end = _tmp71_ - 1;
	}
	{
		gboolean _tmp72_ = FALSE;
		_tmp72_ = TRUE;
		while (TRUE) {
			gchar c = '\0';
			const gchar* _tmp74_;
			if (!_tmp72_) {
				gint _tmp73_;
				_tmp73_ = i;
				i = _tmp73_ + 1;
			}
			_tmp72_ = FALSE;
			if (!(i < end)) {
				break;
			}
			_tmp74_ = p;
			c = string_get (_tmp74_, (glong) i);
			if (c == '*') {
				GString* _tmp75_;
				_tmp75_ = re;
				g_string_append (_tmp75_, ".*");
			} else {
				if (c == '^') {
					GString* _tmp76_;
					_tmp76_ = re;
					g_string_append (_tmp76_, "(?:[^0-9a-zA-Z_.%-]|$)");
				} else {
					if (g_ascii_isalnum (c)) {
						GString* _tmp77_;
						_tmp77_ = re;
						g_string_append_c (_tmp77_, c);
					} else {
						GString* _tmp78_;
						GString* _tmp79_;
						_tmp78_ = re;
						g_string_append_c (_tmp78_, '\\');
						_tmp79_ = re;
						g_string_append_c (_tmp79_, c);
					}
				}
			}
		}
	}
	if (anchor_end) {
		GString* _tmp80_;
		_tmp80_ = re;
		g_string_append_c (_tmp80_, '$');
	}
	{
		GRegex* _tmp81_ = NULL;
		GString* _tmp82_;
		const gchar* _tmp83_;
		GRegex* _tmp84_;
		GRegex* _tmp85_;
		_tmp82_ = re;
		_tmp83_ = _tmp82_->str;
		_tmp84_ = g_regex_new (_tmp83_, flags, 0, &_inner_error0_);
		_tmp81_ = _tmp84_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp85_ = _tmp81_;
		_tmp81_ = NULL;
		_g_regex_unref0 (r->pattern);
		r->pattern = _tmp85_;
		_g_regex_unref0 (_tmp81_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp86_;
		GError* _tmp87_;
		const gchar* _tmp88_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp86_ = p;
		_tmp87_ = e;
		_tmp88_ = _tmp87_->message;
		g_debug ("removeparam_filter.vala:369: tracking filter: bad pattern %s: %s", _tmp86_, _tmp88_);
		result = FALSE;
		_g_error_free0 (e);
		_g_string_free0 (re);
		_g_free0 (p);
		return result;
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp89_ = FALSE;
		_g_string_free0 (re);
		_g_free0 (p);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp89_;
	}
	result = TRUE;
	_g_string_free0 (re);
	_g_free0 (p);
	return result;
}

/** Applies the list to one http(s) URL. */
gchar*
dc_remove_param_filter_clean_url (DcRemoveParamFilter* self,
                                  const gchar* url)
{
	gboolean _tmp0_ = FALSE;
	gint frag_start = 0;
	gint query_start = 0;
	gboolean _tmp2_ = FALSE;
	gchar* host = NULL;
	gchar* _tmp4_;
	gint _tmp5_ = 0;
	gint query_end = 0;
	gchar* query = NULL;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gchar** pairs = NULL;
	const gchar* _tmp13_;
	gchar** _tmp14_;
	gchar** _tmp15_;
	gint pairs_length1;
	gint _pairs_size_;
	gboolean* removed = NULL;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gboolean* _tmp17_;
	gint removed_length1;
	gint _removed_size_;
	gboolean* shielded = NULL;
	gchar** _tmp18_;
	gint _tmp18__length1;
	gboolean* _tmp19_;
	gint shielded_length1;
	gint _shielded_size_;
	DcRemoveParamFilterRule** _tmp20_;
	gint _tmp20__length1;
	gboolean any = FALSE;
	DcRemoveParamFilterRule** _tmp35_;
	gint _tmp35__length1;
	GString* kept = NULL;
	GString* _tmp56_;
	gchar* _result_ = NULL;
	gchar* _tmp67_;
	GString* _tmp68_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (url != NULL, NULL);
	if (!g_str_has_prefix (url, "http://")) {
		_tmp0_ = !g_str_has_prefix (url, "https://");
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup (url);
		result = _tmp1_;
		return result;
	}
	frag_start = string_index_of_char (url, (gunichar) '#', 0);
	query_start = string_index_of_char (url, (gunichar) '?', 0);
	if (frag_start >= 0) {
		_tmp2_ = query_start > frag_start;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		query_start = -1;
	}
	if (query_start < 0) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup (url);
		result = _tmp3_;
		return result;
	}
	_tmp4_ = dc_remove_param_filter_host_of (url);
	host = _tmp4_;
	if (frag_start >= 0) {
		_tmp5_ = frag_start;
	} else {
		gint _tmp6_;
		gint _tmp7_;
		_tmp6_ = strlen (url);
		_tmp7_ = _tmp6_;
		_tmp5_ = _tmp7_;
	}
	query_end = _tmp5_;
	_tmp8_ = string_slice (url, (glong) (query_start + 1), (glong) query_end);
	query = _tmp8_;
	_tmp9_ = query;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ == 0) {
		gchar* _tmp12_;
		_tmp12_ = g_strdup (url);
		result = _tmp12_;
		_g_free0 (query);
		_g_free0 (host);
		return result;
	}
	_tmp13_ = query;
	_tmp15_ = _tmp14_ = g_strsplit (_tmp13_, "&", 0);
	pairs = _tmp15_;
	pairs_length1 = _vala_array_length (_tmp14_);
	_pairs_size_ = pairs_length1;
	_tmp16_ = pairs;
	_tmp16__length1 = pairs_length1;
	_tmp17_ = g_new0 (gboolean, _tmp16__length1);
	removed = _tmp17_;
	removed_length1 = _tmp16__length1;
	_removed_size_ = removed_length1;
	_tmp18_ = pairs;
	_tmp18__length1 = pairs_length1;
	_tmp19_ = g_new0 (gboolean, _tmp18__length1);
	shielded = _tmp19_;
	shielded_length1 = _tmp18__length1;
	_shielded_size_ = shielded_length1;
	_tmp20_ = self->priv->rules;
	_tmp20__length1 = self->priv->rules_length1;
	{
		DcRemoveParamFilterRule** r_collection = NULL;
		gint r_collection_length1 = 0;
		gint _r_collection_size_ = 0;
		gint r_it = 0;
		r_collection = _tmp20_;
		r_collection_length1 = _tmp20__length1;
		for (r_it = 0; r_it < r_collection_length1; r_it = r_it + 1) {
			DcRemoveParamFilterRule* _tmp21_;
			DcRemoveParamFilterRule* r = NULL;
			_tmp21_ = _dc_remove_param_filter_rule_ref0 (r_collection[r_it]);
			r = _tmp21_;
			{
				gboolean _tmp22_ = FALSE;
				DcRemoveParamFilterRule* _tmp23_;
				DcRemoveParamFilterRule* _tmp26_;
				_tmp23_ = r;
				if (!_tmp23_->exception) {
					_tmp22_ = TRUE;
				} else {
					DcRemoveParamFilterRule* _tmp24_;
					const gchar* _tmp25_;
					_tmp24_ = r;
					_tmp25_ = host;
					_tmp22_ = !dc_remove_param_filter_rule_matches (_tmp24_, url, _tmp25_);
				}
				if (_tmp22_) {
					_dc_remove_param_filter_rule_unref0 (r);
					continue;
				}
				_tmp26_ = r;
				if (_tmp26_->remove_all) {
					gchar* _tmp27_;
					_tmp27_ = g_strdup (url);
					result = _tmp27_;
					_dc_remove_param_filter_rule_unref0 (r);
					shielded = (g_free (shielded), NULL);
					removed = (g_free (removed), NULL);
					pairs = (_vala_array_free (pairs, pairs_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (query);
					_g_free0 (host);
					return result;
				}
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp28_ = FALSE;
						_tmp28_ = TRUE;
						while (TRUE) {
							gchar** _tmp30_;
							gint _tmp30__length1;
							DcRemoveParamFilterRule* _tmp31_;
							gchar** _tmp32_;
							gint _tmp32__length1;
							const gchar* _tmp33_;
							if (!_tmp28_) {
								gint _tmp29_;
								_tmp29_ = i;
								i = _tmp29_ + 1;
							}
							_tmp28_ = FALSE;
							_tmp30_ = pairs;
							_tmp30__length1 = pairs_length1;
							if (!(i < _tmp30__length1)) {
								break;
							}
							_tmp31_ = r;
							_tmp32_ = pairs;
							_tmp32__length1 = pairs_length1;
							_tmp33_ = _tmp32_[i];
							if (dc_remove_param_filter_param_selected (_tmp31_, _tmp33_)) {
								gboolean* _tmp34_;
								gint _tmp34__length1;
								_tmp34_ = shielded;
								_tmp34__length1 = shielded_length1;
								_tmp34_[i] = TRUE;
							}
						}
					}
				}
				_dc_remove_param_filter_rule_unref0 (r);
			}
		}
	}
	any = FALSE;
	_tmp35_ = self->priv->rules;
	_tmp35__length1 = self->priv->rules_length1;
	{
		DcRemoveParamFilterRule** r_collection = NULL;
		gint r_collection_length1 = 0;
		gint _r_collection_size_ = 0;
		gint r_it = 0;
		r_collection = _tmp35_;
		r_collection_length1 = _tmp35__length1;
		for (r_it = 0; r_it < r_collection_length1; r_it = r_it + 1) {
			DcRemoveParamFilterRule* _tmp36_;
			DcRemoveParamFilterRule* r = NULL;
			_tmp36_ = _dc_remove_param_filter_rule_ref0 (r_collection[r_it]);
			r = _tmp36_;
			{
				gboolean _tmp37_ = FALSE;
				DcRemoveParamFilterRule* _tmp38_;
				_tmp38_ = r;
				if (_tmp38_->exception) {
					_tmp37_ = TRUE;
				} else {
					DcRemoveParamFilterRule* _tmp39_;
					const gchar* _tmp40_;
					_tmp39_ = r;
					_tmp40_ = host;
					_tmp37_ = !dc_remove_param_filter_rule_matches (_tmp39_, url, _tmp40_);
				}
				if (_tmp37_) {
					_dc_remove_param_filter_rule_unref0 (r);
					continue;
				}
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp41_ = FALSE;
						_tmp41_ = TRUE;
						while (TRUE) {
							gchar** _tmp43_;
							gint _tmp43__length1;
							gboolean _tmp44_ = FALSE;
							gboolean* _tmp45_;
							gint _tmp45__length1;
							gboolean _tmp46_;
							gboolean _tmp49_ = FALSE;
							DcRemoveParamFilterRule* _tmp50_;
							if (!_tmp41_) {
								gint _tmp42_;
								_tmp42_ = i;
								i = _tmp42_ + 1;
							}
							_tmp41_ = FALSE;
							_tmp43_ = pairs;
							_tmp43__length1 = pairs_length1;
							if (!(i < _tmp43__length1)) {
								break;
							}
							_tmp45_ = removed;
							_tmp45__length1 = removed_length1;
							_tmp46_ = _tmp45_[i];
							if (_tmp46_) {
								_tmp44_ = TRUE;
							} else {
								gboolean* _tmp47_;
								gint _tmp47__length1;
								gboolean _tmp48_;
								_tmp47_ = shielded;
								_tmp47__length1 = shielded_length1;
								_tmp48_ = _tmp47_[i];
								_tmp44_ = _tmp48_;
							}
							if (_tmp44_) {
								continue;
							}
							_tmp50_ = r;
							if (_tmp50_->remove_all) {
								_tmp49_ = TRUE;
							} else {
								DcRemoveParamFilterRule* _tmp51_;
								gchar** _tmp52_;
								gint _tmp52__length1;
								const gchar* _tmp53_;
								_tmp51_ = r;
								_tmp52_ = pairs;
								_tmp52__length1 = pairs_length1;
								_tmp53_ = _tmp52_[i];
								_tmp49_ = dc_remove_param_filter_param_selected (_tmp51_, _tmp53_);
							}
							if (_tmp49_) {
								gboolean* _tmp54_;
								gint _tmp54__length1;
								_tmp54_ = removed;
								_tmp54__length1 = removed_length1;
								_tmp54_[i] = TRUE;
								any = TRUE;
							}
						}
					}
				}
				_dc_remove_param_filter_rule_unref0 (r);
			}
		}
	}
	if (!any) {
		gchar* _tmp55_;
		_tmp55_ = g_strdup (url);
		result = _tmp55_;
		shielded = (g_free (shielded), NULL);
		removed = (g_free (removed), NULL);
		pairs = (_vala_array_free (pairs, pairs_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (query);
		_g_free0 (host);
		return result;
	}
	_tmp56_ = g_string_new ("");
	kept = _tmp56_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp57_ = FALSE;
			_tmp57_ = TRUE;
			while (TRUE) {
				gchar** _tmp59_;
				gint _tmp59__length1;
				gboolean* _tmp60_;
				gint _tmp60__length1;
				gboolean _tmp61_;
				GString* _tmp62_;
				GString* _tmp64_;
				gchar** _tmp65_;
				gint _tmp65__length1;
				const gchar* _tmp66_;
				if (!_tmp57_) {
					gint _tmp58_;
					_tmp58_ = i;
					i = _tmp58_ + 1;
				}
				_tmp57_ = FALSE;
				_tmp59_ = pairs;
				_tmp59__length1 = pairs_length1;
				if (!(i < _tmp59__length1)) {
					break;
				}
				_tmp60_ = removed;
				_tmp60__length1 = removed_length1;
				_tmp61_ = _tmp60_[i];
				if (_tmp61_) {
					continue;
				}
				_tmp62_ = kept;
				if (_tmp62_->len > ((gssize) 0)) {
					GString* _tmp63_;
					_tmp63_ = kept;
					g_string_append_c (_tmp63_, '&');
				}
				_tmp64_ = kept;
				_tmp65_ = pairs;
				_tmp65__length1 = pairs_length1;
				_tmp66_ = _tmp65_[i];
				g_string_append (_tmp64_, _tmp66_);
			}
		}
	}
	_tmp67_ = string_slice (url, (glong) 0, (glong) query_start);
	_result_ = _tmp67_;
	_tmp68_ = kept;
	if (_tmp68_->len > ((gssize) 0)) {
		const gchar* _tmp69_;
		GString* _tmp70_;
		const gchar* _tmp71_;
		gchar* _tmp72_;
		gchar* _tmp73_;
		gchar* _tmp74_;
		_tmp69_ = _result_;
		_tmp70_ = kept;
		_tmp71_ = _tmp70_->str;
		_tmp72_ = g_strconcat ("?", _tmp71_, NULL);
		_tmp73_ = _tmp72_;
		_tmp74_ = g_strconcat (_tmp69_, _tmp73_, NULL);
		_g_free0 (_result_);
		_result_ = _tmp74_;
		_g_free0 (_tmp73_);
	}
	if (frag_start >= 0) {
		const gchar* _tmp75_;
		gchar* _tmp76_;
		gchar* _tmp77_;
		gchar* _tmp78_;
		_tmp75_ = _result_;
		_tmp76_ = string_substring (url, (glong) frag_start, (glong) -1);
		_tmp77_ = _tmp76_;
		_tmp78_ = g_strconcat (_tmp75_, _tmp77_, NULL);
		_g_free0 (_result_);
		_result_ = _tmp78_;
		_g_free0 (_tmp77_);
	}
	result = _result_;
	_g_string_free0 (kept);
	shielded = (g_free (shielded), NULL);
	removed = (g_free (removed), NULL);
	pairs = (_vala_array_free (pairs, pairs_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (query);
	_g_free0 (host);
	return result;
}

static gboolean
dc_remove_param_filter_param_selected (DcRemoveParamFilterRule* r,
                                       const gchar* pair)
{
	gboolean hit = FALSE;
	const gchar* _tmp0_;
	gboolean _tmp16_ = FALSE;
	gboolean result;
	g_return_val_if_fail (r != NULL, FALSE);
	g_return_val_if_fail (pair != NULL, FALSE);
	_tmp0_ = r->param_name;
	if (_tmp0_ != NULL) {
		gint eq = 0;
		gchar* _tmp1_ = NULL;
		gchar* name = NULL;
		gchar* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		eq = string_index_of_char (pair, (gunichar) '=', 0);
		if (eq >= 0) {
			gchar* _tmp2_;
			_tmp2_ = string_slice (pair, (glong) 0, (glong) eq);
			_g_free0 (_tmp1_);
			_tmp1_ = _tmp2_;
		} else {
			gchar* _tmp3_;
			_tmp3_ = g_strdup (pair);
			_g_free0 (_tmp1_);
			_tmp1_ = _tmp3_;
		}
		_tmp4_ = _tmp1_;
		_tmp1_ = NULL;
		name = _tmp4_;
		_tmp5_ = name;
		_tmp6_ = r->param_name;
		hit = g_strcmp0 (_tmp5_, _tmp6_) == 0;
		_g_free0 (name);
		_g_free0 (_tmp1_);
	} else {
		GRegex* _tmp7_;
		_tmp7_ = r->param_regex;
		if (_tmp7_ != NULL) {
			GRegex* _tmp8_;
			_tmp8_ = r->param_regex;
			hit = g_regex_match (_tmp8_, pair, 0, NULL);
			if (!hit) {
				gchar* _tmp9_ = NULL;
				gchar* _tmp10_;
				gchar* decoded = NULL;
				gchar* _tmp12_;
				const gchar* _tmp13_;
				_tmp10_ = g_uri_unescape_string (pair, NULL);
				_tmp9_ = _tmp10_;
				if (_tmp9_ == NULL) {
					gchar* _tmp11_;
					_tmp11_ = g_strdup (pair);
					_g_free0 (_tmp9_);
					_tmp9_ = _tmp11_;
				}
				_tmp12_ = _tmp9_;
				_tmp9_ = NULL;
				decoded = _tmp12_;
				_tmp13_ = decoded;
				if (g_strcmp0 (_tmp13_, pair) != 0) {
					GRegex* _tmp14_;
					const gchar* _tmp15_;
					_tmp14_ = r->param_regex;
					_tmp15_ = decoded;
					hit = g_regex_match (_tmp14_, _tmp15_, 0, NULL);
				}
				_g_free0 (decoded);
				_g_free0 (_tmp9_);
			}
		} else {
			result = FALSE;
			return result;
		}
	}
	if (r->inverse) {
		_tmp16_ = !hit;
	} else {
		_tmp16_ = hit;
	}
	result = _tmp16_;
	return result;
}

static gboolean
dc_remove_param_filter_rule_matches (DcRemoveParamFilterRule* r,
                                     const gchar* url,
                                     const gchar* host)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gboolean _tmp3_ = FALSE;
	GRegex* _tmp4_;
	gboolean _tmp6_ = FALSE;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gboolean _tmp9_ = FALSE;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gboolean _tmp12_ = FALSE;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gboolean result;
	g_return_val_if_fail (r != NULL, FALSE);
	g_return_val_if_fail (url != NULL, FALSE);
	g_return_val_if_fail (host != NULL, FALSE);
	_tmp1_ = r->host_hint;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		_tmp2_ = r->host_hint;
		_tmp0_ = !dc_remove_param_filter_host_matches (host, _tmp2_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp4_ = r->pattern;
	if (_tmp4_ != NULL) {
		GRegex* _tmp5_;
		_tmp5_ = r->pattern;
		_tmp3_ = !g_regex_match (_tmp5_, url, 0, NULL);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		result = FALSE;
		return result;
	}
	_tmp7_ = r->domains;
	_tmp7__length1 = r->domains_length1;
	if (_tmp7__length1 > 0) {
		gchar** _tmp8_;
		gint _tmp8__length1;
		_tmp8_ = r->domains;
		_tmp8__length1 = r->domains_length1;
		_tmp6_ = !dc_remove_param_filter_in_domain_list (host, _tmp8_, (gint) _tmp8__length1);
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		result = FALSE;
		return result;
	}
	_tmp10_ = r->not_domains;
	_tmp10__length1 = r->not_domains_length1;
	if (_tmp10__length1 > 0) {
		gchar** _tmp11_;
		gint _tmp11__length1;
		_tmp11_ = r->not_domains;
		_tmp11__length1 = r->not_domains_length1;
		_tmp9_ = dc_remove_param_filter_in_domain_list (host, _tmp11_, (gint) _tmp11__length1);
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		result = FALSE;
		return result;
	}
	_tmp13_ = r->denyallow;
	_tmp13__length1 = r->denyallow_length1;
	if (_tmp13__length1 > 0) {
		gchar** _tmp14_;
		gint _tmp14__length1;
		_tmp14_ = r->denyallow;
		_tmp14__length1 = r->denyallow_length1;
		_tmp12_ = dc_remove_param_filter_in_domain_list (host, _tmp14_, (gint) _tmp14__length1);
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		result = FALSE;
		return result;
	}
	result = TRUE;
	return result;
}

static gboolean
dc_remove_param_filter_in_domain_list (const gchar* host,
                                       gchar** list,
                                       gint list_length1)
{
	gboolean result;
	g_return_val_if_fail (host != NULL, FALSE);
	{
		gchar** d_collection = NULL;
		gint d_collection_length1 = 0;
		gint _d_collection_size_ = 0;
		gint d_it = 0;
		d_collection = list;
		d_collection_length1 = list_length1;
		for (d_it = 0; d_it < d_collection_length1; d_it = d_it + 1) {
			gchar* _tmp0_;
			gchar* d = NULL;
			_tmp0_ = g_strdup (d_collection[d_it]);
			d = _tmp0_;
			{
				const gchar* _tmp1_;
				_tmp1_ = d;
				if (dc_remove_param_filter_host_matches (host, _tmp1_)) {
					result = TRUE;
					_g_free0 (d);
					return result;
				}
				_g_free0 (d);
			}
		}
	}
	result = FALSE;
	return result;
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gboolean
dc_remove_param_filter_host_matches (const gchar* host,
                                     const gchar* domain)
{
	gboolean _tmp14_ = FALSE;
	gboolean result;
	g_return_val_if_fail (host != NULL, FALSE);
	g_return_val_if_fail (domain != NULL, FALSE);
	if (g_str_has_suffix (domain, ".*")) {
		gchar* prefix = NULL;
		gint _tmp0_;
		gint _tmp1_;
		gchar* _tmp2_;
		const gchar* _tmp3_;
		gint idx = 0;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gint _tmp7_;
		gboolean _tmp8_ = FALSE;
		_tmp0_ = strlen (domain);
		_tmp1_ = _tmp0_;
		_tmp2_ = string_slice (domain, (glong) 0, (glong) (_tmp1_ - 1));
		prefix = _tmp2_;
		_tmp3_ = prefix;
		if (g_str_has_prefix (host, _tmp3_)) {
			result = TRUE;
			_g_free0 (prefix);
			return result;
		}
		_tmp4_ = prefix;
		_tmp5_ = g_strconcat (".", _tmp4_, NULL);
		_tmp6_ = _tmp5_;
		_tmp7_ = string_index_of (host, _tmp6_, 0);
		_g_free0 (_tmp6_);
		idx = _tmp7_;
		if (idx > 0) {
			const gchar* _tmp9_;
			gint _tmp10_;
			gint _tmp11_;
			gint _tmp12_;
			gint _tmp13_;
			_tmp9_ = prefix;
			_tmp10_ = strlen (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = strlen (host);
			_tmp13_ = _tmp12_;
			_tmp8_ = ((idx + _tmp11_) + 1) < _tmp13_;
		} else {
			_tmp8_ = FALSE;
		}
		result = _tmp8_;
		_g_free0 (prefix);
		return result;
	}
	if (g_strcmp0 (host, domain) == 0) {
		_tmp14_ = TRUE;
	} else {
		gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp15_ = g_strconcat (".", domain, NULL);
		_tmp16_ = _tmp15_;
		_tmp14_ = g_str_has_suffix (host, _tmp16_);
		_g_free0 (_tmp16_);
	}
	result = _tmp14_;
	return result;
}

/** Lowercased host without userinfo or port. */
static gint
string_last_index_of_char (const gchar* self,
                           gunichar c,
                           gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_strrchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gchar*
dc_remove_param_filter_host_of (const gchar* url)
{
	gint scheme_end = 0;
	gint start = 0;
	gint end = 0;
	gchar* host = NULL;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gint at = 0;
	const gchar* _tmp10_;
	gint colon = 0;
	const gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (url != NULL, NULL);
	scheme_end = string_index_of (url, "://", 0);
	if (scheme_end < 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		result = _tmp0_;
		return result;
	}
	start = scheme_end + 3;
	end = start;
	while (TRUE) {
		gint _tmp1_;
		gint _tmp2_;
		gchar c = '\0';
		gboolean _tmp3_ = FALSE;
		gboolean _tmp4_ = FALSE;
		gint _tmp5_;
		_tmp1_ = strlen (url);
		_tmp2_ = _tmp1_;
		if (!(end < _tmp2_)) {
			break;
		}
		c = string_get (url, (glong) end);
		if (c == '/') {
			_tmp4_ = TRUE;
		} else {
			_tmp4_ = c == '?';
		}
		if (_tmp4_) {
			_tmp3_ = TRUE;
		} else {
			_tmp3_ = c == '#';
		}
		if (_tmp3_) {
			break;
		}
		_tmp5_ = end;
		end = _tmp5_ + 1;
	}
	_tmp6_ = string_slice (url, (glong) start, (glong) end);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_utf8_strdown (_tmp7_, (gssize) -1);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	host = _tmp9_;
	_tmp10_ = host;
	at = string_last_index_of_char (_tmp10_, (gunichar) '@', 0);
	if (at >= 0) {
		const gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp11_ = host;
		_tmp12_ = string_substring (_tmp11_, (glong) (at + 1), (glong) -1);
		_g_free0 (host);
		host = _tmp12_;
	}
	_tmp13_ = host;
	colon = string_index_of_char (_tmp13_, (gunichar) ':', 0);
	if (colon >= 0) {
		const gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp14_ = host;
		_tmp15_ = string_slice (_tmp14_, (glong) 0, (glong) colon);
		_g_free0 (host);
		host = _tmp15_;
	}
	result = host;
	return result;
}

DcRemoveParamFilter*
dc_remove_param_filter_construct (GType object_type)
{
	DcRemoveParamFilter * self = NULL;
	self = (DcRemoveParamFilter*) g_object_new (object_type, NULL);
	return self;
}

DcRemoveParamFilter*
dc_remove_param_filter_new (void)
{
	return dc_remove_param_filter_construct (DC_TYPE_REMOVE_PARAM_FILTER);
}

const gchar*
dc_remove_param_filter_get_title (DcRemoveParamFilter* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_title;
	result = _tmp0_;
	return result;
}

static void
dc_remove_param_filter_set_title (DcRemoveParamFilter* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_remove_param_filter_get_title (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_title);
		self->priv->_title = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_TITLE_PROPERTY]);
	}
}

const gchar*
dc_remove_param_filter_get_version (DcRemoveParamFilter* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_version;
	result = _tmp0_;
	return result;
}

static void
dc_remove_param_filter_set_version (DcRemoveParamFilter* self,
                                    const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_remove_param_filter_get_version (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_version);
		self->priv->_version = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_VERSION_PROPERTY]);
	}
}

gint64
dc_remove_param_filter_get_expires_seconds (DcRemoveParamFilter* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->_expires_seconds;
	return result;
}

static void
dc_remove_param_filter_set_expires_seconds (DcRemoveParamFilter* self,
                                            gint64 value)
{
	gint64 old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_remove_param_filter_get_expires_seconds (self);
	if (old_value != value) {
		self->priv->_expires_seconds = value;
		g_object_notify_by_pspec ((GObject *) self, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_EXPIRES_SECONDS_PROPERTY]);
	}
}

gint
dc_remove_param_filter_get_rule_count (DcRemoveParamFilter* self)
{
	gint result;
	DcRemoveParamFilterRule** _tmp0_;
	gint _tmp0__length1;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->rules;
	_tmp0__length1 = self->priv->rules_length1;
	result = _tmp0__length1;
	return result;
}

static DcRemoveParamFilterRule*
dc_remove_param_filter_rule_construct (GType object_type)
{
	DcRemoveParamFilterRule* self = NULL;
	self = (DcRemoveParamFilterRule*) g_type_create_instance (object_type);
	return self;
}

static DcRemoveParamFilterRule*
dc_remove_param_filter_rule_new (void)
{
	return dc_remove_param_filter_rule_construct (DC_REMOVE_PARAM_FILTER_TYPE_RULE);
}

static void
dc_remove_param_filter_value_rule_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_remove_param_filter_value_rule_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_remove_param_filter_rule_unref (value->data[0].v_pointer);
	}
}

static void
dc_remove_param_filter_value_rule_copy_value (const GValue* src_value,
                                              GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_remove_param_filter_rule_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_remove_param_filter_value_rule_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_remove_param_filter_value_rule_collect_value (GValue* value,
                                                 guint n_collect_values,
                                                 GTypeCValue* collect_values,
                                                 guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcRemoveParamFilterRule * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_remove_param_filter_rule_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_remove_param_filter_value_rule_lcopy_value (const GValue* value,
                                               guint n_collect_values,
                                               GTypeCValue* collect_values,
                                               guint collect_flags)
{
	DcRemoveParamFilterRule ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_remove_param_filter_rule_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
dc_remove_param_filter_param_spec_rule (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags)
{
	DcRemoveParamFilterParamSpecRule* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_REMOVE_PARAM_FILTER_TYPE_RULE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
dc_remove_param_filter_value_get_rule (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_REMOVE_PARAM_FILTER_TYPE_RULE), NULL);
	return value->data[0].v_pointer;
}

static void
dc_remove_param_filter_value_set_rule (GValue* value,
                                       gpointer v_object)
{
	DcRemoveParamFilterRule * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_REMOVE_PARAM_FILTER_TYPE_RULE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_REMOVE_PARAM_FILTER_TYPE_RULE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_remove_param_filter_rule_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_remove_param_filter_rule_unref (old);
	}
}

static void
dc_remove_param_filter_value_take_rule (GValue* value,
                                        gpointer v_object)
{
	DcRemoveParamFilterRule * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_REMOVE_PARAM_FILTER_TYPE_RULE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_REMOVE_PARAM_FILTER_TYPE_RULE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_remove_param_filter_rule_unref (old);
	}
}

static void
dc_remove_param_filter_rule_class_init (DcRemoveParamFilterRuleClass * klass,
                                        gpointer klass_data)
{
	dc_remove_param_filter_rule_parent_class = g_type_class_peek_parent (klass);
	((DcRemoveParamFilterRuleClass *) klass)->finalize = dc_remove_param_filter_rule_finalize;
}

static void
dc_remove_param_filter_rule_instance_init (DcRemoveParamFilterRule * self,
                                           gpointer klass)
{
	gchar** _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	self->exception = FALSE;
	self->remove_all = FALSE;
	self->inverse = FALSE;
	self->param_name = NULL;
	self->param_regex = NULL;
	self->pattern = NULL;
	self->host_hint = NULL;
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	self->domains = _tmp0_;
	self->domains_length1 = 0;
	self->_domains_size_ = self->domains_length1;
	_tmp1_ = g_new0 (gchar*, 0 + 1);
	self->not_domains = _tmp1_;
	self->not_domains_length1 = 0;
	self->_not_domains_size_ = self->not_domains_length1;
	_tmp2_ = g_new0 (gchar*, 0 + 1);
	self->denyallow = _tmp2_;
	self->denyallow_length1 = 0;
	self->_denyallow_size_ = self->denyallow_length1;
	self->ref_count = 1;
}

static void
dc_remove_param_filter_rule_finalize (DcRemoveParamFilterRule * obj)
{
	DcRemoveParamFilterRule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_REMOVE_PARAM_FILTER_TYPE_RULE, DcRemoveParamFilterRule);
	g_signal_handlers_destroy (self);
	_g_free0 (self->param_name);
	_g_regex_unref0 (self->param_regex);
	_g_regex_unref0 (self->pattern);
	_g_free0 (self->host_hint);
	self->domains = (_vala_array_free (self->domains, self->domains_length1, (GDestroyNotify) g_free), NULL);
	self->not_domains = (_vala_array_free (self->not_domains, self->not_domains_length1, (GDestroyNotify) g_free), NULL);
	self->denyallow = (_vala_array_free (self->denyallow, self->denyallow_length1, (GDestroyNotify) g_free), NULL);
}

static GType
dc_remove_param_filter_rule_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_remove_param_filter_value_rule_init, dc_remove_param_filter_value_rule_free_value, dc_remove_param_filter_value_rule_copy_value, dc_remove_param_filter_value_rule_peek_pointer, "p", dc_remove_param_filter_value_rule_collect_value, "p", dc_remove_param_filter_value_rule_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcRemoveParamFilterRuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_remove_param_filter_rule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcRemoveParamFilterRule), 0, (GInstanceInitFunc) dc_remove_param_filter_rule_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_remove_param_filter_rule_type_id;
	dc_remove_param_filter_rule_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcRemoveParamFilterRule", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_remove_param_filter_rule_type_id;
}

static GType
dc_remove_param_filter_rule_get_type (void)
{
	static volatile gsize dc_remove_param_filter_rule_type_id__once = 0;
	if (g_once_init_enter (&dc_remove_param_filter_rule_type_id__once)) {
		GType dc_remove_param_filter_rule_type_id;
		dc_remove_param_filter_rule_type_id = dc_remove_param_filter_rule_get_type_once ();
		g_once_init_leave (&dc_remove_param_filter_rule_type_id__once, dc_remove_param_filter_rule_type_id);
	}
	return dc_remove_param_filter_rule_type_id__once;
}

static gpointer
dc_remove_param_filter_rule_ref (gpointer instance)
{
	DcRemoveParamFilterRule * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dc_remove_param_filter_rule_unref (gpointer instance)
{
	DcRemoveParamFilterRule * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_REMOVE_PARAM_FILTER_RULE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
dc_remove_param_filter_class_init (DcRemoveParamFilterClass * klass,
                                   gpointer klass_data)
{
	dc_remove_param_filter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcRemoveParamFilter_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_remove_param_filter_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_remove_param_filter_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_remove_param_filter_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_REMOVE_PARAM_FILTER_TITLE_PROPERTY, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_TITLE_PROPERTY] = g_param_spec_string ("title", "title", "title", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_REMOVE_PARAM_FILTER_VERSION_PROPERTY, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_VERSION_PROPERTY] = g_param_spec_string ("version", "version", "version", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** From the `! Expires:` header; DEFAULT_EXPIRES when absent. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_REMOVE_PARAM_FILTER_EXPIRES_SECONDS_PROPERTY, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_EXPIRES_SECONDS_PROPERTY] = g_param_spec_int64 ("expires-seconds", "expires-seconds", "expires-seconds", G_MININT64, G_MAXINT64, DC_REMOVE_PARAM_FILTER_DEFAULT_EXPIRES, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_REMOVE_PARAM_FILTER_RULE_COUNT_PROPERTY, dc_remove_param_filter_properties[DC_REMOVE_PARAM_FILTER_RULE_COUNT_PROPERTY] = g_param_spec_int ("rule-count", "rule-count", "rule-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dc_remove_param_filter_instance_init (DcRemoveParamFilter * self,
                                      gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	DcRemoveParamFilterRule** _tmp2_;
	self->priv = dc_remove_param_filter_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_title = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_version = _tmp1_;
	self->priv->_expires_seconds = DC_REMOVE_PARAM_FILTER_DEFAULT_EXPIRES;
	_tmp2_ = g_new0 (DcRemoveParamFilterRule*, 0 + 1);
	self->priv->rules = _tmp2_;
	self->priv->rules_length1 = 0;
	self->priv->_rules_size_ = self->priv->rules_length1;
}

static void
dc_remove_param_filter_finalize (GObject * obj)
{
	DcRemoveParamFilter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_REMOVE_PARAM_FILTER, DcRemoveParamFilter);
	_g_free0 (self->priv->_title);
	_g_free0 (self->priv->_version);
	self->priv->rules = (_vala_array_free (self->priv->rules, self->priv->rules_length1, (GDestroyNotify) dc_remove_param_filter_rule_unref), NULL);
	G_OBJECT_CLASS (dc_remove_param_filter_parent_class)->finalize (obj);
}

/**
     * Interpreter for the `$removeparam` subset of uBlock Origin / AdGuard
     * filter lists (for example the AdGuard URL Tracking filter,
     * https://filters.adtidy.org/extension/ublock/filters/17.txt).
     *
     * A parsed list replaces LinkCleaner's built-in rules for pasted
     * links: every rule whose URL pattern matches the link decides which
     * query parameters are dropped. Supported syntax:
     *
     *   pattern$removeparam=name          drop parameter `name`
     *   pattern$removeparam=/regex/       drop `name=value` pairs matching
     *   pattern$removeparam=~name         drop everything except `name`
     *   pattern$removeparam               drop the whole query
     *   @@pattern$removeparam[=x]         exception (keep x / keep all)
     *   options: domain=, denyallow=, request types, ~3p, match-case
     *
     * Patterns follow ABP conventions: `||host^`, `|` anchors, `*` and
     * `^` wildcards, `/regex/`. Since a pasted link is a top-level
     * navigation, rules restricted to other request types (xhr, script,
     * image, ...) are ignored and `domain=` is checked against the link's
     * own host.
     */
static GType
dc_remove_param_filter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcRemoveParamFilterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_remove_param_filter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcRemoveParamFilter), 0, (GInstanceInitFunc) dc_remove_param_filter_instance_init, NULL };
	GType dc_remove_param_filter_type_id;
	dc_remove_param_filter_type_id = g_type_register_static (G_TYPE_OBJECT, "DcRemoveParamFilter", &g_define_type_info, 0);
	DcRemoveParamFilter_private_offset = g_type_add_instance_private (dc_remove_param_filter_type_id, sizeof (DcRemoveParamFilterPrivate));
	return dc_remove_param_filter_type_id;
}

GType
dc_remove_param_filter_get_type (void)
{
	static volatile gsize dc_remove_param_filter_type_id__once = 0;
	if (g_once_init_enter (&dc_remove_param_filter_type_id__once)) {
		GType dc_remove_param_filter_type_id;
		dc_remove_param_filter_type_id = dc_remove_param_filter_get_type_once ();
		g_once_init_leave (&dc_remove_param_filter_type_id__once, dc_remove_param_filter_type_id);
	}
	return dc_remove_param_filter_type_id__once;
}

static void
_vala_dc_remove_param_filter_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	DcRemoveParamFilter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_REMOVE_PARAM_FILTER, DcRemoveParamFilter);
	switch (property_id) {
		case DC_REMOVE_PARAM_FILTER_TITLE_PROPERTY:
		g_value_set_string (value, dc_remove_param_filter_get_title (self));
		break;
		case DC_REMOVE_PARAM_FILTER_VERSION_PROPERTY:
		g_value_set_string (value, dc_remove_param_filter_get_version (self));
		break;
		case DC_REMOVE_PARAM_FILTER_EXPIRES_SECONDS_PROPERTY:
		g_value_set_int64 (value, dc_remove_param_filter_get_expires_seconds (self));
		break;
		case DC_REMOVE_PARAM_FILTER_RULE_COUNT_PROPERTY:
		g_value_set_int (value, dc_remove_param_filter_get_rule_count (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_remove_param_filter_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	DcRemoveParamFilter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_REMOVE_PARAM_FILTER, DcRemoveParamFilter);
	switch (property_id) {
		case DC_REMOVE_PARAM_FILTER_TITLE_PROPERTY:
		dc_remove_param_filter_set_title (self, g_value_get_string (value));
		break;
		case DC_REMOVE_PARAM_FILTER_VERSION_PROPERTY:
		dc_remove_param_filter_set_version (self, g_value_get_string (value));
		break;
		case DC_REMOVE_PARAM_FILTER_EXPIRES_SECONDS_PROPERTY:
		dc_remove_param_filter_set_expires_seconds (self, g_value_get_int64 (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

