mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-22 09:57:20 +00:00
Fixed the "System.UriFormatException: Invalid URI: The Uri string is too long." exception when submitting a longer hardware report.
This commit is contained in:
parent
49367c2e45
commit
357a7a114e
@ -4,11 +4,11 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using OpenHardwareMonitor.Utilities;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -59,10 +59,10 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
string report =
|
string report =
|
||||||
"type=crash&" +
|
"type=crash&" +
|
||||||
"version=" + Uri.EscapeDataString(version.ToString()) + "&" +
|
"version=" + HttpUtility.UrlEncode(version.ToString()) + "&" +
|
||||||
"report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
|
"report=" + HttpUtility.UrlEncode(reportTextBox.Text) + "&" +
|
||||||
"comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
|
"comment=" + HttpUtility.UrlEncode(commentTextBox.Text) + "&" +
|
||||||
"email=" + Uri.EscapeDataString(emailTextBox.Text);
|
"email=" + HttpUtility.UrlEncode(emailTextBox.Text);
|
||||||
byte[] byteArray = Encoding.UTF8.GetBytes(report);
|
byte[] byteArray = Encoding.UTF8.GetBytes(report);
|
||||||
request.ContentLength = byteArray.Length;
|
request.ContentLength = byteArray.Length;
|
||||||
|
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
|
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using OpenHardwareMonitor.Utilities;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -47,10 +48,10 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
string report =
|
string report =
|
||||||
"type=hardware&" +
|
"type=hardware&" +
|
||||||
"version=" + Uri.EscapeDataString(version.ToString()) + "&" +
|
"version=" + HttpUtility.UrlEncode(version.ToString()) + "&" +
|
||||||
"report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
|
"report=" + HttpUtility.UrlEncode(reportTextBox.Text) + "&" +
|
||||||
"comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
|
"comment=" + HttpUtility.UrlEncode(commentTextBox.Text) + "&" +
|
||||||
"email=" + Uri.EscapeDataString(emailTextBox.Text);
|
"email=" + HttpUtility.UrlEncode(emailTextBox.Text);
|
||||||
byte[] byteArray = Encoding.UTF8.GetBytes(report);
|
byte[] byteArray = Encoding.UTF8.GetBytes(report);
|
||||||
request.ContentLength = byteArray.Length;
|
request.ContentLength = byteArray.Length;
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
<Compile Include="GUI\UserRadioGroup.cs" />
|
<Compile Include="GUI\UserRadioGroup.cs" />
|
||||||
<Compile Include="Properties\AssemblyVersion.cs" />
|
<Compile Include="Properties\AssemblyVersion.cs" />
|
||||||
<Compile Include="Utilities\HttpServer.cs" />
|
<Compile Include="Utilities\HttpServer.cs" />
|
||||||
|
<Compile Include="Utilities\HttpUtility.cs" />
|
||||||
<Compile Include="Utilities\Logger.cs" />
|
<Compile Include="Utilities\Logger.cs" />
|
||||||
<Compile Include="Utilities\PersistentSettings.cs" />
|
<Compile Include="Utilities\PersistentSettings.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
34
Utilities/HttpUtility.cs
Normal file
34
Utilities/HttpUtility.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
Copyright (C) 2020 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenHardwareMonitor.Utilities {
|
||||||
|
|
||||||
|
public class HttpUtility {
|
||||||
|
public static string UrlEncode(string s) {
|
||||||
|
|
||||||
|
int maxLength = 32765;
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
int imax = s.Length / maxLength;
|
||||||
|
|
||||||
|
for (int i = 0; i <= imax; i++) {
|
||||||
|
sb.Append(
|
||||||
|
Uri.EscapeDataString(i < imax
|
||||||
|
? s.Substring(maxLength * i, maxLength)
|
||||||
|
: s.Substring(maxLength * i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user