diff --git a/Library.Encyclopedia.DataAccess/DataAccess/MainDataAccess.cs b/Library.Encyclopedia.DataAccess/DataAccess/MainDataAccess.cs index 0145e33..bdc7d83 100644 --- a/Library.Encyclopedia.DataAccess/DataAccess/MainDataAccess.cs +++ b/Library.Encyclopedia.DataAccess/DataAccess/MainDataAccess.cs @@ -165,6 +165,9 @@ async Task
IMainDataAccess.GetAsync(Guid id) #region CREATE public async Task CreateAsync(Main model) { + if (model.RichDescription.Contains("$$$")) + throw new CreateFailedException(CreateFailErrorCode.INVALID_INPUT_SEQUENCE); + // assign a random id model.Id = Guid.NewGuid(); @@ -183,7 +186,7 @@ public async Task CreateAsync(Main model) private Main ReplaceLineBreaks(Main model) { - string searchStartString = "

"; + string searchStartString = "') + 1); + if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value)) { newDesc = newDesc.Replace(tag, "
"); @@ -303,6 +309,9 @@ public async Task

UpdateAsync(Guid id, MainUpdateModel model) if (model.RichDescription != null) { + if (model.RichDescription!=null && model.RichDescription.Contains("$$$")) + throw new UpdateFailedException(UpdateFailErrorCode.INVALID_INPUT_SEQUENCE); + entry.RichDescription = model.RichDescription; entry = ReplaceInternalLinks(entry); diff --git a/Library.Encyclopedia.Entity/Exceptions/CreateFailedException.cs b/Library.Encyclopedia.Entity/Exceptions/CreateFailedException.cs new file mode 100644 index 0000000..1fd9049 --- /dev/null +++ b/Library.Encyclopedia.Entity/Exceptions/CreateFailedException.cs @@ -0,0 +1,19 @@ +using EnumsNET; +using System; +using System.ComponentModel; + +namespace Library.Encyclopedia.Entity.Exceptions +{ + public class CreateFailedException : Exception + { + public CreateFailedException(CreateFailErrorCode code) : base(((CreateFailErrorCode)code).AsString(EnumFormat.Description)) + { + } + } + + public enum CreateFailErrorCode + { + [Description("$$$ is not an accepted input")] + INVALID_INPUT_SEQUENCE + } +} \ No newline at end of file diff --git a/Library.Encyclopedia.Entity/Exceptions/UpdateFailedException.cs b/Library.Encyclopedia.Entity/Exceptions/UpdateFailedException.cs index 7bd1aa6..eb04a1e 100644 --- a/Library.Encyclopedia.Entity/Exceptions/UpdateFailedException.cs +++ b/Library.Encyclopedia.Entity/Exceptions/UpdateFailedException.cs @@ -14,6 +14,8 @@ public UpdateFailedException(UpdateFailErrorCode code) : base(((UpdateFailErrorC public enum UpdateFailErrorCode { [Description("Entry not found!")] - EntryNotFound + EntryNotFound, + [Description("$$$ is not an accepted input")] + INVALID_INPUT_SEQUENCE } }