Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginUtil.cpp

Issue 4899473029332992: Noissue - Remove dead code (Closed)
Patch Set: Created March 17, 2015, 2:35 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginUtil.cpp
===================================================================
--- a/src/plugin/PluginUtil.cpp
+++ b/src/plugin/PluginUtil.cpp
@@ -16,11 +16,13 @@
*/
#include "PluginStdAfx.h"
+#include "../shared/Utils.h"
+#include <memory>
#include <algorithm>
Oleksandr 2015/03/19 04:39:32 algorithm, stdexcept, vector, shlwapi.h, PluginSet
#include <stdexcept>
#include <vector>
-
-#include "../shared/Utils.h"
+#include <WinInet.h>
+#include <shlwapi.h>
#include "PluginUtil.h"
#include "PluginSettings.h"
@@ -54,4 +56,32 @@
return std::wstring();
}
return std::wstring(locationUrl, locationUrl.Length());
-}
+}
+
+void UnescapeUrl(std::wstring& url)
+{
+ try
+ {
+ DWORD result_length = INTERNET_MAX_URL_LENGTH;
+ std::unique_ptr<wchar_t[]> result(new wchar_t[result_length]);
+ HRESULT hr = UrlUnescapeW(const_cast<wchar_t*>(url.c_str()), result.get(), &result_length, 0);
+ if (hr == S_OK)
+ {
+ url = std::wstring(result.get(), result_length);
+ }
+ /*
+ * Do nothing. This masks error return values from UrlUnescape without logging the error.
+ */
+ }
+ catch(std::bad_alloc e)
+ {
+ /*
+ * When the code has a systematic way of handling bad_alloc, we'll rethrow (probably).
+ * Until then, we mask the exception and make no modification.
+ */
+ }
+ catch(...)
+ {
+ // no modification if any other exception
+ }
+}

Powered by Google App Engine
This is Rietveld