From 791810928496f733a6bbe7a53bf0c82f235be434 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 1 Jun 2012 06:26:17 +0000 Subject: [PATCH] Fixed bug #3529455 (uri string is too long) and a minor Imgur history form nuisance. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1908 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- .../releases/additional_files/readme.txt | 2 +- GreenshotImgurPlugin/Forms/ImgurHistory.cs | 4 ++-- GreenshotImgurPlugin/ImgurUtils.cs | 22 +++++++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Greenshot/releases/additional_files/readme.txt b/Greenshot/releases/additional_files/readme.txt index bc9d2b140..f1dfd3027 100644 --- a/Greenshot/releases/additional_files/readme.txt +++ b/Greenshot/releases/additional_files/readme.txt @@ -3,7 +3,7 @@ Greenshot: A screenshot tool optimized for productivity. Save a screenshot or a CHANGE LOG: -1.0.0 build 1905 (Unstable, meaning we are in testing fase and haven't released yet) +1.0.0 build 1908 (Unstable, meaning we are in testing fase and haven't released yet) We changed the version to 1.0.0, after 5 year the version should no longer have a "beta" feeling! diff --git a/GreenshotImgurPlugin/Forms/ImgurHistory.cs b/GreenshotImgurPlugin/Forms/ImgurHistory.cs index dbca3eea6..ebf85d3c0 100644 --- a/GreenshotImgurPlugin/Forms/ImgurHistory.cs +++ b/GreenshotImgurPlugin/Forms/ImgurHistory.cs @@ -114,12 +114,12 @@ namespace GreenshotImgurPlugin { private void DeleteButtonClick(object sender, EventArgs e) { if (listview_imgur_uploads.SelectedItems != null && listview_imgur_uploads.SelectedItems.Count > 0) { - // Should fix Bug #3378699 - pictureBox1.Image = pictureBox1.ErrorImage; for (int i = 0; i < listview_imgur_uploads.SelectedItems.Count; i++) { ImgurInfo imgurInfo = (ImgurInfo)listview_imgur_uploads.SelectedItems[i].Tag; DialogResult result = MessageBox.Show(Language.GetFormattedString("imgur", LangKey.delete_question, imgurInfo.Title), Language.GetFormattedString("imgur", LangKey.delete_title, imgurInfo.Hash), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { + // Should fix Bug #3378699 + pictureBox1.Image = pictureBox1.ErrorImage; BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(ImgurPlugin.Attributes.Name, Language.GetString("imgur", LangKey.communication_wait)); try { ImgurUtils.DeleteImgurImage(imgurInfo); diff --git a/GreenshotImgurPlugin/ImgurUtils.cs b/GreenshotImgurPlugin/ImgurUtils.cs index bd6a1a59d..83d1fb407 100644 --- a/GreenshotImgurPlugin/ImgurUtils.cs +++ b/GreenshotImgurPlugin/ImgurUtils.cs @@ -79,9 +79,27 @@ namespace GreenshotImgurPlugin { } } - private static string EscapeText(string Text) { + /// + /// A wrapper around the EscapeDataString, as the limit is 32766 characters + /// See: http://msdn.microsoft.com/en-us/library/system.uri.escapedatastring%28v=vs.110%29.aspx + /// + /// + /// escaped data string + private static StringBuilder EscapeDataStringToStringBuilder(string dataString) { + StringBuilder result = new StringBuilder(); + int currentLocation = 0; + while (currentLocation < dataString.Length) { + string process = dataString.Substring(currentLocation,Math.Min(16384, dataString.Length-currentLocation)); + result.Append(Uri.EscapeDataString(process)); + currentLocation = currentLocation + 16384; + } + return result; + } + + private static string EscapeText(string text) { string[] UriRfc3986CharsToEscape = new[] { "!", "*", "'", "(", ")" }; - StringBuilder escaped = new StringBuilder(Uri.EscapeDataString(Text.ToString())); + LOG.DebugFormat("Text size {0}", text.Length); + StringBuilder escaped = EscapeDataStringToStringBuilder(text); for (int i = 0; i < UriRfc3986CharsToEscape.Length; i++) { escaped.Replace(UriRfc3986CharsToEscape[i], Uri.HexEscape(UriRfc3986CharsToEscape[i][0]));