diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/ShardedSnapshotStore.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/ShardedSnapshotStore.cs index 398ac08b0f..fbbe1c2d9f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/ShardedSnapshotStore.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/ShardedSnapshotStore.cs @@ -91,7 +91,7 @@ private static DomainId GetAppId(DomainId key) // This is a leaky abstraction, but the only option to implement that in a fast way. var parts = key.ToString().Split(DomainId.IdSeparator); - if (parts.Length != 2) + if (parts.Length < 2) { throw new InvalidOperationException("The key does not contain an app id."); } diff --git a/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs b/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs index 46afeaa4a2..3c7f059850 100644 --- a/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs +++ b/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs @@ -330,6 +330,28 @@ public async Task Should_create_content_with_custom_id_and_upsert() Assert.Equal(3, content.Data.Number); } + [Theory] + [InlineData("e5f7c399-6024-4367-9538-b7de4bced0f9' UNION ALL SELECT NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL-- vIGQ")] + [InlineData("e5f7c399-6024-4367-9538-b7de4bced0f9') UNION ALL SELECT 59,59,59,'qkjvq'||'FWUHnOHbQqCmewsQoKRPxqUXmHZMTtqHmyYoRhwu'||'qvpkq',59-- dLuxn")] + public async Task Should_create_and_delete_content_with_strange_id(string id) + { + // STEP 1: Upsert a new item with a custom id. + var content_0 = await _.Contents.UpsertAsync(id, new TestEntityData(), ContentUpsertOptions.AsPublish); + + Assert.Equal(id, content_0.Id); + + // STEP 2: Find content + var content_1 = await _.Contents.GetAsync(id); + + Assert.Equal(id, content_1.Id); + + + // STEP 3: Delete content. + await _.Contents.DeleteAsync(id); + + await Assert.ThrowsAnyAsync(() => _.Contents.GetAsync(id)); + } + [Theory] [InlineData(ContentStrategies.Update.Normal)] [InlineData(ContentStrategies.Update.Upsert)]