Also make further uses of Midori.URI.parse.
ADBLOCK_FILTER_SET (filter, TRUE);
if (gtk_cell_renderer_toggle_get_active (renderer))
{
- if (!strncmp (filter, "http", 4))
+ if (midori_uri_is_http (filter))
{
gchar* filename = adblock_get_filename_for_uri (filter);
g_unlink (filename);
page_uri = webkit_web_view_get_uri (web_view);
/* Skip checks on about: pages */
- if (!(page_uri && *page_uri) || !strncmp (page_uri, "about:", 6))
+ if (midori_uri_is_blank (page_uri))
return;
/* Never filter the main page itself */
page_uri = webkit_web_view_get_uri (web_view);
/* Don't add adblock css into speeddial and about: pages */
- if (!(page_uri && *page_uri) || !strncmp (page_uri, "about:", 6))
+ if (midori_uri_is_blank (page_uri))
return;
g_free (sokoke_js_script_eval (js_context, blockscript, NULL));
MidoriExtension* extension)
{
GtkWidget* label;
- SoupURI* uri;
+ gchar* hostname;
gchar* colorstr;
GdkColor color;
GdkColor fgcolor;
label = midori_view_get_proxy_tab_label (view);
- if ((uri = soup_uri_new (midori_view_get_display_uri (view)))
- && uri->host && (katze_object_get_enum (view, "load-status") == MIDORI_LOAD_FINISHED))
+ if ((hostname = midori_uri_parse (midori_view_get_display_uri (view), NULL))
+ && katze_object_get_enum (view, "load-status") == MIDORI_LOAD_FINISHED)
{
icon = midori_view_get_icon (view);
}
else
{
- gchar* hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, uri->host, 1);
+ gchar* hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, hostname, 1);
colorstr = g_strndup (hash, 6 + 1);
g_free (hash);
colorstr[0] = '#';
gdk_color_parse (colorstr, &color);
}
- soup_uri_free (uri);
+ g_free (hostname);
if ((color.red < 35000)
&& (color.green < 35000)
SoupURI* soup_uri = soup_message_get_uri (msg);
gchar* uri = soup_uri_to_string (soup_uri, FALSE);
- if (uri && g_str_has_prefix (uri, "http") && !g_strcmp0 (msg->method, "GET"))
+ if (midori_uri_is_http (uri) && !g_strcmp0 (msg->method, "GET"))
{
gchar* filename = web_cache_get_cached_path (extension, uri);
GHashTable* cache_headers;
#endif
#include "katze-net.h"
+#include "midori-core.h"
#include <glib/gstdio.h>
#include <libsoup/soup.h>
priv->user_data = user_data;
priv->request = request;
- if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri, "https://"))
+ if (midori_uri_is_http (uri))
{
msg = soup_message_new ("GET", uri);
if (status_cb)
g_return_val_if_fail (uri != NULL, NULL);
- if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri,"https://"))
+ if (midori_uri_is_http (uri))
{
guint i;
gchar* icon_uri;
public static bool is_blank (string? uri) {
return !(uri != null && uri != "" && !uri.has_prefix ("about:"));
}
+ public static bool is_http (string? uri) {
+ return uri != null
+ && (uri.has_prefix ("http://") || uri.has_prefix ("https://"));
+ }
public static bool is_resource (string? uri) {
return uri != null
- && (uri.has_prefix ("http://")
- || (uri.has_prefix ("data:") && uri.chr (-1, ';') != null)
- || uri.has_prefix ("https://"));
+ && (is_http (uri)
+ || (uri.has_prefix ("data:") && uri.chr (-1, ';') != null));
}
public static bool is_location (string? uri) {
/* file:// is not considered a location for security reasons */
SoupURI* proxy_uri;
/* soup_uri_new expects a non-NULL string with a protocol */
- if (uri && g_str_has_prefix (uri, "http://"))
+ if (midori_uri_is_http (uri))
proxy_uri = soup_uri_new (uri);
else if (uri && *uri)
{
pixbuf = NULL;
icon_uri = g_strdup (view->icon_uri);
- if ((icon_uri && g_str_has_prefix (icon_uri, "http"))
- || (view->uri && g_str_has_prefix (view->uri, "http")))
+ if (midori_uri_is_http (icon_uri) || midori_uri_is_http (view->uri))
{
if (!icon_uri)
{