mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 08:32:50 -05:00
Fix queue message encoding for Azure (UTF-16 in XML) (#1439)
* Revert "Encode into b64 to avoid illegal xml encoding when sending to Azure (#1425)"
This reverts commit 2c9a5bb4ab
.
* Azure queue to use base64 encoding universally
* Ensure byte size calc is using encoded byte count
* Remove message text extension from blockIP svc
* Remove unused using on blockIp hosted service
This commit is contained in:
@ -24,6 +24,9 @@ using Bit.Core.Models.Table;
|
||||
using IdentityModel;
|
||||
using System.Text.Json;
|
||||
using Bit.Core.Enums.Provider;
|
||||
using Azure.Storage.Queues;
|
||||
using Azure.Storage.Queues.Models;
|
||||
using System.Threading;
|
||||
|
||||
namespace Bit.Core.Utilities
|
||||
{
|
||||
@ -901,5 +904,22 @@ namespace Bit.Core.Utilities
|
||||
list.Add(item);
|
||||
return list;
|
||||
}
|
||||
|
||||
public static string DecodeMessageText(this QueueMessage message)
|
||||
{
|
||||
var text = message?.MessageText;
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Base64DecodeString(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Utilities
|
||||
{
|
||||
public class EncodedStringConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(string);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
{
|
||||
return existingValue;
|
||||
}
|
||||
|
||||
var value = reader.Value as string;
|
||||
return System.Net.WebUtility.HtmlDecode(value);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
if (serializer.NullValueHandling == NullValueHandling.Include)
|
||||
{
|
||||
writer.WriteNull();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
writer.WriteValue(System.Net.WebUtility.HtmlEncode((string)value));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user