From 507e9908b2d9e16edb503c48a1ceaa06508766ad Mon Sep 17 00:00:00 2001 From: ruri Date: Fri, 17 May 2019 00:15:38 +0200 Subject: [PATCH] Fixed (very dirty) encode content in Request Block. --- OpenBullet/LSDoc.xml | 2 +- OpenBullet/SyntaxHelper.xml | 2 +- RuriLib/Blocks/BlockRequest.cs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenBullet/LSDoc.xml b/OpenBullet/LSDoc.xml index 6130edf..6875069 100644 --- a/OpenBullet/LSDoc.xml +++ b/OpenBullet/LSDoc.xml @@ -271,7 +271,7 @@ KEYCHECK BanOnToCheck=False This will spawn and execute a Request Block. Syntax (expanded for readability): -REQUEST METHOD "URL" [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeOutput?] +REQUEST METHOD "URL" [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeContent?] [STANDARD / MULTIPART / BASICAUTH] [CONTENT "postdata"] [CONTENTTYPE "ctype"] diff --git a/OpenBullet/SyntaxHelper.xml b/OpenBullet/SyntaxHelper.xml index 47937c1..33d0aee 100644 --- a/OpenBullet/SyntaxHelper.xml +++ b/OpenBullet/SyntaxHelper.xml @@ -10,7 +10,7 @@ KEYCHECK [BanOn4XX?] [BanOnToCheck?] ]* -REQUEST METHOD "URL" [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeOutput?] +REQUEST METHOD "URL" [AutoRedirect?] [ReadResponseSource?] [ParseQuery?] [EncodeContent?] [STANDARD / MULTIPART / BASICAUTH] [CONTENT "postdata"] [CONTENTTYPE "ctype"] diff --git a/RuriLib/Blocks/BlockRequest.cs b/RuriLib/Blocks/BlockRequest.cs index a188590..4fea172 100644 --- a/RuriLib/Blocks/BlockRequest.cs +++ b/RuriLib/Blocks/BlockRequest.cs @@ -393,7 +393,14 @@ namespace RuriLib .Select(p => ReplaceValues(p, data))); if (pData != "") { - if (encodeContent) pData = System.Uri.EscapeDataString(pData); + if (encodeContent) + { + // Very dirty but it works + var nonce = data.rand.Next(1000000, 9999999); + pData = pData.Replace("&", $"{nonce}&{nonce}").Replace("=", $"{nonce}={nonce}"); + pData = System.Uri.EscapeDataString(pData).Replace($"{nonce}%26{nonce}", "&").Replace($"{nonce}%3D{nonce}", "="); + } + content = new StringContent(pData); content.ContentType = cType; data.Log(new LogEntry(string.Format("Post Data: {0}", pData), Colors.MediumTurquoise));