From c7918da8a6b28fc515d273c16a9ffca2a4b9e119 Mon Sep 17 00:00:00 2001 From: Eldon Stegall Date: Tue, 17 Oct 2017 14:55:52 +0000 Subject: Improve http object export for URLs with long extensions This allows the export of objects with extensions that may be longer than the allowed file name of an export (due to underlying filesystem, etc). The extension detection mechanism previously preserved everything in the file name after the final ".", but in some cases (especially with long query strings) this would exceed the allowed maximum file length, and simply refuse to export the object. Now, if the length of the extension and duplicate number is longer than the allowable file length, the extension is ignored, and the entire string is truncated to allow an acceptable export filename. Bug: 14130 Change-Id: I6fa0281519d031c07a9ac621002ac328f34f54cc Reviewed-on: https://code.wireshark.org/review/23960 Reviewed-by: Michael Mann Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/gtk/export_object_dlg.c | 2 +- ui/qt/export_object_dialog.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/gtk/export_object_dlg.c b/ui/gtk/export_object_dlg.c index ba7ce9c136..ee0783827e 100644 --- a/ui/gtk/export_object_dlg.c +++ b/ui/gtk/export_object_dlg.c @@ -160,7 +160,7 @@ eo_save_clicked_cb(GtkWidget *widget _U_, gpointer arg) return; } - safe_filename = eo_massage_str(entry->filename, 256, 0); + safe_filename = eo_massage_str(entry->filename, EXPORT_OBJECT_MAXFILELEN, 0); /* * Loop until the user either selects a file or gives up. diff --git a/ui/qt/export_object_dialog.cpp b/ui/qt/export_object_dialog.cpp index d5b60afbb2..4d3d3dca25 100644 --- a/ui/qt/export_object_dialog.cpp +++ b/ui/qt/export_object_dialog.cpp @@ -312,8 +312,10 @@ void ExportObjectDialog::saveCurrentEntry() return; } + GString *safe_filename = eo_massage_str(entry->filename, EXPORT_OBJECT_MAXFILELEN-path.canonicalPath().length(), 0); file_name = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save Object As" UTF8_HORIZONTAL_ELLIPSIS)), - path.filePath(entry->filename)); + safe_filename->str); + g_string_free(safe_filename, TRUE); if (file_name.length() > 0) { eo_save_entry(file_name.toUtf8().constData(), entry, TRUE); -- cgit v1.2.3