creative-commoners / create-ss-demo

BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Prevent non-alphanumeric characters in site name during "instantiate" #5

Open robbieaverill opened 5 years ago

robbieaverill commented 5 years ago

The SSP API returns an error response if you use anything other than [a-zA-Z0-9] in the site name. We can validate this pattern early in the instantiate command to prevent API errors coming back.

https://platform.playpen.pl/static/internal.html#demos-demos-collection-post - see "project_id" param. The input requirements are not documented at this stage.

robbieaverill commented 5 years ago

Validation rules from SSP:

        if (preg_match('/[^a-zA-Z0-9]/', $this->Name)) {
            $result->error('"name" contains invalid characters, only a-z, A-Z, 0-9 permitted');
        }
        if (preg_match('/[^a-zA-Z0-9\/\-_:\.]/', $this->Image)) {
            $result->error('"image" contains invalid characters, only a-z, A-Z, 0-9, slash, dash, underscore, colon and full stop permitted');
        }
brynwhyman commented 5 years ago

This same SSP API restriction is seen with the CWP demos: https://github.com/silverstripeltd/cwp-demo/issues/18