FEATURE-896: Added HTTPS to the Imgur links

This commit is contained in:
RKrom 2015-11-07 23:10:08 +01:00
commit 0fe3083122
2 changed files with 50 additions and 44 deletions

View file

@ -16,6 +16,8 @@ Bugs Resolved:
BUG-1850: Greenshot stops responding BUG-1850: Greenshot stops responding
BUG-1864: Imgur link wasn't copied to the clipboard BUG-1864: Imgur link wasn't copied to the clipboard
Features:
FEATURE-896: Use Imgur with HTTPS (with changing the Imgur API from V2 to V3 this was already required for the upload anyway.)
Known bugs: Known bugs:
* BUG-1852: When using the Imgur & clipboard destinations together, the imgur export Uri overwrites the clipboard image * BUG-1852: When using the Imgur & clipboard destinations together, the imgur export Uri overwrites the clipboard image

View file

@ -29,10 +29,11 @@ namespace GreenshotImgurPlugin
/// </summary> /// </summary>
public class ImgurInfo : IDisposable { public class ImgurInfo : IDisposable {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurInfo)); private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurInfo));
private string hash;
public string Hash { public string Hash
get {return hash;} {
set {hash = value;} get;
set;
} }
private string deleteHash; private string deleteHash;
@ -40,57 +41,58 @@ namespace GreenshotImgurPlugin
get {return deleteHash;} get {return deleteHash;}
set { set {
deleteHash = value; deleteHash = value;
deletePage = "http://imgur.com/delete/" + value; DeletePage = "https://imgur.com/delete/" + value;
} }
} }
private string title; public string Title
public string Title { {
get {return title;} get;
set {title = value;} set;
} }
private string imageType; public string ImageType
public string ImageType { {
get {return imageType;} get;
set {imageType = value;} set;
} }
private DateTime timestamp; public DateTime Timestamp
public DateTime Timestamp { {
get {return timestamp;} get;
set {timestamp = value;} set;
} }
private string original; public string Original
public string Original { {
get {return original;} get;
set {original = value;} set;
} }
private string page; public string Page
public string Page { {
get {return page;} get;
set {page = value;} set;
} }
private string smallSquare; public string SmallSquare
public string SmallSquare { {
get {return smallSquare;} get;
set {smallSquare = value;} set;
} }
private string largeThumbnail; public string LargeThumbnail
public string LargeThumbnail { {
get {return largeThumbnail;} get;
set {largeThumbnail = value;} set;
} }
private string deletePage; public string DeletePage
public string DeletePage { {
get {return deletePage;} get;
set {deletePage = value;} set;
} }
private Image image; private Image image;
public Image Image { public Image Image {
get {return image;} get {return image;}
@ -175,32 +177,34 @@ namespace GreenshotImgurPlugin
} }
} }
nodes = doc.GetElementsByTagName("original"); nodes = doc.GetElementsByTagName("original");
if(nodes.Count > 0) { if (nodes.Count > 0)
imgurInfo.Original = nodes.Item(0).InnerText; {
imgurInfo.Original = nodes.Item(0).InnerText.Replace("http:", "https:");
} }
// Version 3 API only has Link // Version 3 API only has Link
nodes = doc.GetElementsByTagName("link"); nodes = doc.GetElementsByTagName("link");
if (nodes.Count > 0) if (nodes.Count > 0)
{ {
imgurInfo.Original = nodes.Item(0).InnerText; imgurInfo.Original = nodes.Item(0).InnerText.Replace("http:", "https:");
} }
nodes = doc.GetElementsByTagName("imgur_page"); nodes = doc.GetElementsByTagName("imgur_page");
if (nodes.Count > 0) if (nodes.Count > 0)
{ {
imgurInfo.Page = nodes.Item(0).InnerText; imgurInfo.Page = nodes.Item(0).InnerText.Replace("http:", "https:");
} }
else else
{ {
// Version 3 doesn't have a page link in the response // Version 3 doesn't have a page link in the response
imgurInfo.Page = string.Format("http://imgur.com/{0}", imgurInfo.Hash); imgurInfo.Page = string.Format("https://imgur.com/{0}", imgurInfo.Hash);
} }
nodes = doc.GetElementsByTagName("small_square"); nodes = doc.GetElementsByTagName("small_square");
if(nodes.Count > 0) { if(nodes.Count > 0) {
imgurInfo.SmallSquare = nodes.Item(0).InnerText; imgurInfo.SmallSquare = nodes.Item(0).InnerText;
} }
nodes = doc.GetElementsByTagName("large_thumbnail"); nodes = doc.GetElementsByTagName("large_thumbnail");
if(nodes.Count > 0) { if(nodes.Count > 0)
imgurInfo.LargeThumbnail = nodes.Item(0).InnerText; {
imgurInfo.LargeThumbnail = nodes.Item(0).InnerText.Replace("http:", "https:");
} }
} catch(Exception e) { } catch(Exception e) {
LOG.ErrorFormat("Could not parse Imgur response due to error {0}, response was: {1}", e.Message, response); LOG.ErrorFormat("Could not parse Imgur response due to error {0}, response was: {1}", e.Message, response);