midori_browser_download_prepare_destination_uri (WebKitDownload* download,
const gchar* folder)
{
- const gchar* suggested_filename;
+ gchar* suggested_filename;
GFile* file_source;
gchar* file_basename;
gchar* download_dir = NULL;
gchar* destination_filename;
gchar* midori_tmp_dir;
- suggested_filename = webkit_download_get_suggested_filename (download);
+ suggested_filename = sokoke_get_download_filename (download);
file_source = g_file_new_for_uri (suggested_filename);
+ g_free (suggested_filename);
file_basename = g_file_get_basename (file_source);
if (folder == NULL)
{
if (g_object_get_data (G_OBJECT (download), "save-as-download"))
{
static GtkWidget* dialog = NULL;
+ gchar* filename;
if (!dialog)
{
G_CALLBACK (midori_view_download_save_as_response_cb), browser);
}
g_object_set_data (G_OBJECT (dialog), "download", download);
- gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
- webkit_download_get_suggested_filename (download));
+ filename = sokoke_get_download_filename (download);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
+ g_free (filename);
gtk_widget_show (dialog);
}
else
gchar* content_type;
gchar* description;
gchar* file_type;
+ gchar* name;
gchar* file_name;
WebKitDownload *download;
WebKitWebDataSource* datasource;
g_free (description);
download = webkit_download_new (request);
- file_name = g_strdup_printf (_("File Name: %s"),
- webkit_download_get_suggested_filename (download));
+ name = sokoke_get_download_filename (download);
+ file_name = g_strdup_printf (_("File Name: %s"), name);
+ g_free (name);
g_object_unref (download);
/* Link Fingerprint */
#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <glib/gstdio.h>
+#include <webkit/webkit.h>
#ifdef HAVE_HILDON_FM
#include <hildon/hildon-file-chooser-dialog.h>
}
}
+gchar*
+sokoke_get_download_filename (WebKitDownload* download)
+{
+ /* https://bugs.webkit.org/show_bug.cgi?id=83161 */
+ /* https://d19vezwu8eufl6.cloudfront.net/nlp/slides%2F03-01-FormalizingNB.pdf */
+ gchar* filename = g_strdup (webkit_download_get_suggested_filename (download));
+ #ifdef G_OS_WIN32
+ g_strdelimit (filename, "/\\<>:\"|?*", '_');
+ #else
+ g_strdelimit (filename, "/", '_');
+ #endif
+ return filename;
+}
+
#define __SOKOKE_H__ 1
#include <JavaScriptCore/JavaScript.h>
+#include <webkit/webkit.h>
#include <midori/midori-websettings.h>
#include <katze/gtk3-compat.h>
gboolean
sokoke_recursive_fork_protection (const gchar* uri,
gboolean set_uri);
+gchar*
+sokoke_get_download_filename (WebKitDownload* download);
typedef struct
{
gchar* total;
gchar* size_text;
gchar* text;
+ gchar* filename;
gdouble progress;
gtk_tree_model_get (model, iter, 1, &download, -1);
size_text = g_strdup_printf (_("%s of %s"), current, total);
g_free (current);
g_free (total);
- text = g_strdup_printf ("%s\n%s",
- webkit_download_get_suggested_filename (download), size_text);
+ filename = sokoke_get_download_filename (download);
+ text = g_strdup_printf ("%s\n%s", filename, size_text);
+ g_free (filename);
g_free (size_text);
/* Avoid a bug in WebKit */
if (webkit_download_get_status (download) != WEBKIT_DOWNLOAD_STATUS_CREATED)
g_free (path);
}
else
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress),
- webkit_download_get_suggested_filename (download));
+ {
+ gchar* filename = sokoke_get_download_filename (download);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), filename);
+ g_free (filename);
+ }
sokoke_widget_get_text_size (progress, "M", &width, NULL);
gtk_widget_set_size_request (progress, width * 10, 1);
/* Avoid a bug in WebKit */