plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
502 stars 670 forks source link

Cannot create a page with short name "contributors" #3441

Open iFlameing opened 2 years ago

iFlameing commented 2 years ago

If I name the page contributors then I am unable to save.

harshit-dugar commented 2 years ago

I am new to Volto @iFlameing can you please specify the issue

iFlameing commented 2 years ago

@harshit-dugar Try to give a page Title contributors you will be not able to solve the page.

tisto commented 1 year ago

We need to create a static list in Volto with reserved words (e.g. "contributors", "search") and make sure the Volto UI tells editors when they want to add or edit an ID that matches our reserved words list.

@robgietema @sneridagh if I am not mistaken we worked on something like this in one of our client projects.

erral commented 1 year ago

We need to create a static list in Volto with reserved words (e.g. "contributors", "search") and make sure the Volto UI tells editors when they want to add or edit an ID that matches our reserved words list.

I think this should be done on the backend level and emit a proper error through the REST API when creating a content with such URLs

sneridagh commented 1 year ago

@tisto we already do it in the widget ID in core (see below), but in the use case of "add" form, the main check happens on the backend, on POST. As @erral hinted the RESTAPI response should be more explicit in the case of clash. Could be that the error provided in Dexterity won't be enough descriptive even... so it might require more changes than fixing only RESTAPI.

/cc @davisagli @jaroel

Using a static list of reserved words, in the config:

https://github.com/plone/volto/blob/main/src/components/manage/Widgets/IdWidget.jsx#L101

Checking the current list of indexes:

https://github.com/plone/volto/blob/main/src/components/manage/Widgets/IdWidget.jsx#L147-L149

And checking for special characters:

https://github.com/plone/volto/blob/main/src/components/manage/Widgets/IdWidget.jsx#L142-L145C6

erral commented 1 year ago

As @erral hinted the RESTAPI response should be more explicit in the case of clash. Could be that the error provided in Dexterity won't be enough descriptive even... so it might require more changes than fixing only RESTAPI.

/cc @davisagli @jaroel

I think we don't even have such a list in the backend... I tried once to track down how was this controlled on Plone or Zope level (because a client added a page named layout in Plone 3 and when we migrated it to Plone 5 it crashed) and I wasn¡t able to track it down.

davisagli commented 1 year ago

This is related to https://github.com/plone/plone.restapi/issues/1613

davisagli commented 1 year ago

Also related to https://github.com/plone/volto/issues/3716 and https://github.com/plone/volto/pull/4686#discussion_r1322684331