AudioscrobblerEntry* rb_audioscrobbler_entry_load_from_string (const char *string) { AudioscrobblerEntry *entry; int i = 0; char **breaks; entry = g_new0 (AudioscrobblerEntry, 1); rb_audioscrobbler_entry_init (entry); breaks = g_strsplit (string, "&", 6); for (i = 0; breaks[i] != NULL; i++) { char **breaks2 = g_strsplit (breaks[i], "=", 2); if (breaks2[0] != NULL && breaks2[1] != NULL) { if (g_str_has_prefix (breaks2[0], "a")) { g_free (entry->artist); entry->artist = soup_uri_decode (breaks2[1]); } if (g_str_has_prefix (breaks2[0], "t")) { g_free (entry->title); entry->title = soup_uri_decode (breaks2[1]); } if (g_str_has_prefix (breaks2[0], "b")) { g_free (entry->album); entry->album = soup_uri_decode (breaks2[1]); } if (g_str_has_prefix (breaks2[0], "m")) { g_free (entry->mbid); entry->mbid = soup_uri_decode (breaks2[1]); } if (g_str_has_prefix (breaks2[0], "l")) { entry->length = atoi (breaks2[1]); } /* 'I' here is for backwards compatibility with queue files * saved while we were using the 1.1 protocol. see bug 508895. */ if (g_str_has_prefix (breaks2[0], "i") || g_str_has_prefix (breaks2[0], "I")) { entry->play_time = strtol (breaks2[1], NULL, 10); } } g_strfreev (breaks2); } g_strfreev (breaks); if (strcmp (entry->artist, "") == 0 || strcmp (entry->title, "") == 0) { rb_audioscrobbler_entry_free (entry); entry = NULL; } return entry; }
static gboolean soup_request_file_ensure_file (SoupRequestFile *file, GCancellable *cancellable, GError **error) { SoupURI *uri; char *decoded_path; if (file->priv->gfile) return TRUE; uri = soup_request_get_uri (SOUP_REQUEST (file)); decoded_path = soup_uri_decode (uri->path); #ifdef G_OS_WIN32 windowsify_file_uri_path (decoded_path); #endif if (uri->scheme == SOUP_URI_SCHEME_RESOURCE) { char *uri_str; uri_str = g_strdup_printf ("resource://%s", decoded_path); file->priv->gfile = g_file_new_for_uri (uri_str); g_free (uri_str); } else file->priv->gfile = g_file_new_for_path (decoded_path); g_free (decoded_path); return TRUE; }
/* open urls in external window. You don't want to navigate without a back * button nor url bar. * No clean way to handle this, so use global cur_url */ static WebKitNavigationResponse wp_navigation_requested(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gpointer user_data) { const gchar *uri; gchar *decoded_uri; GError *error = NULL; GdkScreen *screen; uri = webkit_network_request_get_uri(request); decoded_uri = soup_uri_decode(uri); if (g_str_has_prefix(decoded_uri, current_url)) { g_log(wikipedia_logdomain, G_LOG_LEVEL_DEBUG, "Accepting %s\n", uri); g_free(decoded_uri); return WEBKIT_NAVIGATION_RESPONSE_ACCEPT; } g_free(decoded_uri); g_log(wikipedia_logdomain, G_LOG_LEVEL_DEBUG, "%s != %s\n", uri, current_url); screen = gtk_widget_get_screen(GTK_WIDGET(web_view)); if (!screen) screen = gdk_screen_get_default (); gtk_show_uri(screen, uri, gtk_get_current_event_time(), &error); if (error) { g_log(wikipedia_logdomain, G_LOG_LEVEL_DEBUG, "gtk_show_uri %s\n", error->message); g_error_free(error); } return WEBKIT_NAVIGATION_RESPONSE_IGNORE; }
static gboolean soup_request_file_ensure_file (SoupRequestFile *file, GCancellable *cancellable, GError **error) { SoupURI *uri; if (file->priv->gfile) return TRUE; uri = soup_request_get_uri (SOUP_REQUEST (file)); if (uri->scheme == SOUP_URI_SCHEME_FILE) { gchar *decoded_uri = soup_uri_decode (g_strdup (uri->path)); if (decoded_uri) { file->priv->gfile = g_file_new_for_path (decoded_uri); g_free (decoded_uri); } return TRUE; } g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_UNSUPPORTED_URI_SCHEME, _("Unsupported URI scheme '%s'"), uri->scheme); return FALSE; }
char * http_uri_get_basename (const char *uri_str) { char *decoded; char *basename; basename = http_path_get_basename (uri_str); decoded = soup_uri_decode (basename); g_free (basename); return decoded; }
static GInputStream * soup_request_data_send (SoupRequest *request, GCancellable *cancellable, GError **error) { SoupRequestData *data = SOUP_REQUEST_DATA (request); SoupURI *uri = soup_request_get_uri (request); GInputStream *memstream; const char *comma, *start, *end; gboolean base64 = FALSE; char *uristr; uristr = soup_uri_to_string (uri, FALSE); start = uristr + 5; comma = strchr (start, ','); if (comma && comma != start) { /* Deal with MIME type / params */ if (comma > start + BASE64_INDICATOR_LEN && !g_ascii_strncasecmp (comma - BASE64_INDICATOR_LEN, BASE64_INDICATOR, BASE64_INDICATOR_LEN)) { end = comma - BASE64_INDICATOR_LEN; base64 = TRUE; } else end = comma; if (end != start) data->priv->content_type = uri_decoded_copy (start, end - start); } memstream = g_memory_input_stream_new (); if (comma) start = comma + 1; if (*start) { guchar *buf = (guchar *) soup_uri_decode (start); if (base64) buf = g_base64_decode_inplace ((gchar*) buf, &data->priv->content_length); else data->priv->content_length = strlen ((const char *) buf); g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (memstream), buf, data->priv->content_length, g_free); } g_free (uristr); return memstream; }
static void wp_set_url(char *wp) { gchar *new_url; new_url = malloc(strlen(wp) + strlen(WP_SKINSTR) + 1); strcpy(new_url, wp); strcat(new_url, WP_SKINSTR); if (current_url) g_free(current_url); current_url = soup_uri_decode(new_url); webkit_web_view_open(WEBKIT_WEB_VIEW(moz), new_url); gtk_widget_show_all(moz); g_free(new_url); }
static gboolean decode_rfc5987 (char *encoded_string) { char *q, *decoded; gboolean iso_8859_1 = FALSE; q = strchr (encoded_string, '\''); if (!q) return FALSE; if (g_ascii_strncasecmp (encoded_string, "UTF-8", q - encoded_string) == 0) ; else if (g_ascii_strncasecmp (encoded_string, "iso-8859-1", q - encoded_string) == 0) iso_8859_1 = TRUE; else return FALSE; q = strchr (q + 1, '\''); if (!q) return FALSE; decoded = soup_uri_decode (q + 1); if (iso_8859_1) { char *utf8 = g_convert_with_fallback (decoded, -1, "UTF-8", "iso-8859-1", "_", NULL, NULL, NULL); g_free (decoded); if (!utf8) return FALSE; decoded = utf8; } /* If encoded_string was UTF-8, then each 3-character %-escape * will be converted to a single byte, and so decoded is * shorter than encoded_string. If encoded_string was * iso-8859-1, then each 3-character %-escape will be * converted into at most 2 bytes in UTF-8, and so it's still * shorter. */ strcpy (encoded_string, decoded); g_free (decoded); return TRUE; }
static void got_headers (SoupMessage *req, SoupClientContext *client) { SoupServer *server = client->server; SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server); SoupURI *uri; SoupDate *date; char *date_string; SoupAuthDomain *domain; GSList *iter; gboolean rejected = FALSE; char *auth_user; if (!priv->raw_paths) { char *decoded_path; uri = soup_message_get_uri (req); decoded_path = soup_uri_decode (uri->path); soup_uri_set_path (uri, decoded_path); g_free (decoded_path); } /* Add required response headers */ date = soup_date_new_from_now (0); date_string = soup_date_to_string (date, SOUP_DATE_HTTP); soup_message_headers_replace (req->response_headers, "Date", date_string); g_free (date_string); soup_date_free (date); /* Now handle authentication. (We do this here so that if * the request uses "Expect: 100-continue", we can reject it * immediately rather than waiting for the request body to * be sent. */ for (iter = priv->auth_domains; iter; iter = iter->next) { domain = iter->data; if (soup_auth_domain_covers (domain, req)) { auth_user = soup_auth_domain_accepts (domain, req); if (auth_user) { client->auth_domain = g_object_ref (domain); client->auth_user = auth_user; return; } rejected = TRUE; } } /* If no auth domain rejected it, then it's ok. */ if (!rejected) return; for (iter = priv->auth_domains; iter; iter = iter->next) { domain = iter->data; if (soup_auth_domain_covers (domain, req)) soup_auth_domain_challenge (domain, req); } }
static GInputStream * soup_request_data_send (SoupRequest *request, GCancellable *cancellable, GError **error) { SoupRequestData *data = SOUP_REQUEST_DATA (request); SoupURI *uri = soup_request_get_uri (request); GInputStream *memstream; const char *comma, *start, *end; gboolean base64 = FALSE; char *uristr; uristr = soup_uri_to_string (uri, FALSE); start = uristr + 5; comma = strchr (start, ','); if (comma && comma != start) { /* Deal with MIME type / params */ if (comma > start + BASE64_INDICATOR_LEN && !g_ascii_strncasecmp (comma - BASE64_INDICATOR_LEN, BASE64_INDICATOR, BASE64_INDICATOR_LEN)) { end = comma - BASE64_INDICATOR_LEN; base64 = TRUE; } else end = comma; if (end != start) { char *encoded_content_type = g_strndup (start, end - start); if (base64) data->priv->content_type = encoded_content_type; else { data->priv->content_type = soup_uri_decode (encoded_content_type); g_free (encoded_content_type); } } } memstream = g_memory_input_stream_new (); if (comma) start = comma + 1; if (*start) { guchar *buf; if (base64) { int inlen, state = 0; guint save = 0; inlen = strlen (start); buf = g_malloc0 (inlen * 3 / 4 + 3); data->priv->content_length = g_base64_decode_step (start, inlen, buf, &state, &save); if (state != 0) { g_free (buf); goto fail; } } else { buf = (guchar *) soup_uri_decode (start); data->priv->content_length = strlen ((const char *) buf); } g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (memstream), buf, data->priv->content_length, g_free); } g_free (uristr); return memstream; fail: g_free (uristr); g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_BAD_URI, _("Unable to decode URI: %s"), start); g_object_unref (memstream); return NULL; }
RygelHTTPItemURI* rygel_http_item_uri_construct_from_string (GType object_type, const char* uri, RygelHTTPServer* http_server, GError** error) { #line 233 "rygel-http-item-uri.c" GError * _inner_error_; RygelHTTPItemURI * self; char* _tmp0_; RygelHTTPServer* _tmp1_; char* request_uri; char** _tmp3_; gint _parts_size_; gint parts_length1; char** _tmp2_; char** parts; gboolean _tmp4_ = FALSE; #line 45 "rygel-http-item-uri.vala" g_return_val_if_fail (uri != NULL, NULL); #line 45 "rygel-http-item-uri.vala" g_return_val_if_fail (http_server != NULL, NULL); #line 249 "rygel-http-item-uri.c" _inner_error_ = NULL; #line 45 "rygel-http-item-uri.vala" self = (RygelHTTPItemURI*) g_object_new (object_type, NULL); #line 49 "rygel-http-item-uri.vala" self->thumbnail_index = -1; #line 50 "rygel-http-item-uri.vala" self->subtitle_index = -1; #line 51 "rygel-http-item-uri.vala" self->transcode_target = (_tmp0_ = NULL, _g_free0 (self->transcode_target), _tmp0_); #line 52 "rygel-http-item-uri.vala" self->http_server = (_tmp1_ = _g_object_ref0 (http_server), _g_object_unref0 (self->http_server), _tmp1_); #line 54 "rygel-http-item-uri.vala" request_uri = string_replace (uri, rygel_http_server_get_path_root (http_server), ""); #line 263 "rygel-http-item-uri.c" parts = (_tmp3_ = _tmp2_ = g_strsplit (request_uri, "/", 0), parts_length1 = _vala_array_length (_tmp2_), _parts_size_ = parts_length1, _tmp3_); #line 57 "rygel-http-item-uri.vala" if (parts_length1 < 2) { #line 57 "rygel-http-item-uri.vala" _tmp4_ = TRUE; #line 269 "rygel-http-item-uri.c" } else { #line 57 "rygel-http-item-uri.vala" _tmp4_ = (parts_length1 % 2) == 0; #line 273 "rygel-http-item-uri.c" } #line 57 "rygel-http-item-uri.vala" if (_tmp4_) { #line 277 "rygel-http-item-uri.c" _inner_error_ = g_error_new (RYGEL_HTTP_REQUEST_ERROR, RYGEL_HTTP_REQUEST_ERROR_BAD_REQUEST, _ ("Invalid URI '%s'"), request_uri); { if (_inner_error_->domain == RYGEL_HTTP_REQUEST_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_object_unref (self); return NULL; } else { _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } } { gint i; #line 62 "rygel-http-item-uri.vala" i = 1; #line 299 "rygel-http-item-uri.c" { gboolean _tmp5_; #line 62 "rygel-http-item-uri.vala" _tmp5_ = TRUE; #line 62 "rygel-http-item-uri.vala" while (TRUE) { #line 306 "rygel-http-item-uri.c" GQuark _tmp13_; const char* _tmp12_; static GQuark _tmp13__label0 = 0; static GQuark _tmp13__label1 = 0; static GQuark _tmp13__label2 = 0; static GQuark _tmp13__label3 = 0; #line 62 "rygel-http-item-uri.vala" if (!_tmp5_) { #line 62 "rygel-http-item-uri.vala" i = i + 2; #line 317 "rygel-http-item-uri.c" } #line 62 "rygel-http-item-uri.vala" _tmp5_ = FALSE; #line 62 "rygel-http-item-uri.vala" if (!(i < (parts_length1 - 1))) { #line 62 "rygel-http-item-uri.vala" break; #line 325 "rygel-http-item-uri.c" } _tmp12_ = parts[i]; _tmp13_ = (NULL == _tmp12_) ? 0 : g_quark_from_string (_tmp12_); if (_tmp13_ == ((0 != _tmp13__label0) ? _tmp13__label0 : (_tmp13__label0 = g_quark_from_static_string ("item")))) switch (0) { default: { guchar* _tmp9_; gint _data_size_; gint data_length1; size_t _tmp7_; char* _tmp6_; guchar* _tmp8_; guchar* data; GString* builder; char* _tmp10_; data = (_tmp9_ = (_tmp8_ = g_base64_decode (_tmp6_ = soup_uri_decode (parts[i + 1]), &_tmp7_), _g_free0 (_tmp6_), _tmp8_), data_length1 = _tmp7_, _data_size_ = data_length1, _tmp9_); #line 66 "rygel-http-item-uri.vala" builder = g_string_new (""); #line 67 "rygel-http-item-uri.vala" g_string_append (builder, (const char*) data); #line 68 "rygel-http-item-uri.vala" self->item_id = (_tmp10_ = g_strdup (builder->str), _g_free0 (self->item_id), _tmp10_); #line 349 "rygel-http-item-uri.c" data = (g_free (data), NULL); _g_string_free0 (builder); #line 70 "rygel-http-item-uri.vala" break; #line 354 "rygel-http-item-uri.c" } } else if (_tmp13_ == ((0 != _tmp13__label1) ? _tmp13__label1 : (_tmp13__label1 = g_quark_from_static_string ("transcoded")))) switch (0) { default: { char* _tmp11_; #line 72 "rygel-http-item-uri.vala" self->transcode_target = (_tmp11_ = soup_uri_decode (parts[i + 1]), _g_free0 (self->transcode_target), _tmp11_); #line 74 "rygel-http-item-uri.vala" break; #line 365 "rygel-http-item-uri.c" } } else if (_tmp13_ == ((0 != _tmp13__label2) ? _tmp13__label2 : (_tmp13__label2 = g_quark_from_static_string ("thumbnail")))) switch (0) { default: { #line 76 "rygel-http-item-uri.vala" self->thumbnail_index = atoi (parts[i + 1]); #line 78 "rygel-http-item-uri.vala" break; #line 375 "rygel-http-item-uri.c" } } else if (_tmp13_ == ((0 != _tmp13__label3) ? _tmp13__label3 : (_tmp13__label3 = g_quark_from_static_string ("subtitle")))) switch (0) { default: { #line 80 "rygel-http-item-uri.vala" self->subtitle_index = atoi (parts[i + 1]); #line 82 "rygel-http-item-uri.vala" break; #line 385 "rygel-http-item-uri.c" } } else switch (0) { default: { #line 84 "rygel-http-item-uri.vala" break; #line 393 "rygel-http-item-uri.c" } } } } } #line 88 "rygel-http-item-uri.vala" if (self->item_id == NULL) { #line 401 "rygel-http-item-uri.c" _inner_error_ = g_error_new_literal (RYGEL_HTTP_REQUEST_ERROR, RYGEL_HTTP_REQUEST_ERROR_NOT_FOUND, _ ("Not Found")); { if (_inner_error_->domain == RYGEL_HTTP_REQUEST_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_object_unref (self); return NULL; } else { _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } } _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); return self; }