OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

MenuText throws an exception when user sets a very long text when creating menu items #8756

Closed AndreaPiovanelli closed 9 months ago

AndreaPiovanelli commented 9 months ago

https://github.com/OrchardCMS/Orchard/blob/90b104ed74234bdaaedf2b730166eddc66ad4d4c/src/Orchard.Web/Core/Navigation/ViewModels/MenuPartViewModel.cs#L11

When a user sets a MenuText longer than 255 characters, an exception is thrown because data would be truncated inside the database. The MenuText column of Navigation_MenuPartRecord table has a datatype of nvarchar(255) but there is no validation. I noticed that there is a proper data annotation for Orchard.Core.Navigation.Models.MenuPart but data annotation is missing for Orchard.Core.Navigation.ViewModels.MenuPartViewModel, which is the model used inside the EditorTemplates/Parts.Navigation.Menu.Edit.cshtml shape.