dawoe / OEmbed-Picker-Property-Editor

Property editor for Umbraco CMS to allow embedding 3rd party media like Youtube, Vimeo, ... outside of the rich text editor.
https://our.umbraco.org/projects/backoffice-extensions/oembed-picker-property-editor/
MIT License
10 stars 10 forks source link

PVC may fail if switching from an existing property editor #22

Closed bjarnef closed 1 year ago

bjarnef commented 2 years ago

I am working on a project which has a block with an Embed property (textstring), which contains an URL to a YouTube video. When switching the the OEmbed property editor (single) the PVC breaks.

image

It could use the DetectIsJson() method to ensure this is valid JSON before trying deserialize and inside that also use JsonConvert.DeserializeObject in try of a try/catch block: https://github.com/dawoe/OEmbed-Picker-Property-Editor/blob/develop/src/Dawoe.OEmbedPickerPropertyEditor.Core/ValueConverters/OEmbedPickerValueConverter.cs#L63

E.g. like on some JSON based core PVC: https://github.com/umbraco/Umbraco-CMS/blob/5bfab13dc5a268714aad2426a2b68ab5561a6407/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/GridValueConverter.cs#L43-L47