1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-08 03:15:07 -05:00

Encode into b64 to avoid illegal xml encoding when sending to Azure (#1425)

* Encode into b64 to avoid illegal xml encoding when sending to Azure

* Revert "Encode into b64 to avoid illegal xml encoding when sending to Azure"

This reverts commit d50de941da.

* HtmlEncode strings if they use multi-byte characters

* Add serializer to event processor

* Rename to used class

* Formatting

* PR feedback
This commit is contained in:
Matt Gibson
2021-07-02 17:11:33 -04:00
committed by GitHub
parent 7cfa54ba14
commit 2c9a5bb4ab
4 changed files with 63 additions and 19 deletions

View File

@ -12,11 +12,13 @@ using Microsoft.Extensions.Logging;
using Azure.Storage.Queues;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Bit.Core.Utilities;
namespace Bit.EventsProcessor
{
public class AzureQueueHostedService : IHostedService, IDisposable
{
private readonly JsonSerializer _jsonSerializer;
private readonly ILogger<AzureQueueHostedService> _logger;
private readonly IConfiguration _configuration;
@ -31,6 +33,11 @@ namespace Bit.EventsProcessor
{
_logger = logger;
_configuration = configuration;
_jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings
{
Converters = new[] { new EncodedStringConverter() },
});
}
public Task StartAsync(CancellationToken cancellationToken)
@ -111,7 +118,7 @@ namespace Bit.EventsProcessor
var token = JToken.Parse(message);
if (token is JArray)
{
var indexedEntities = token.ToObject<List<EventMessage>>()
var indexedEntities = token.ToObject<List<EventMessage>>(_jsonSerializer)
.SelectMany(e => EventTableEntity.IndexEvent(e));
events.AddRange(indexedEntities);
}