cms icon indicating copy to clipboard operation
cms copied to clipboard

Field handles have no `snake_case` validation

Open jesseleite opened this issue 3 years ago • 2 comments

Bug description

Field handles have no validation ensuring snake_case, which causes edge case JS errors when using field conditions (due to our omitter trying to access a JS key when a space characters exists in a field handle).

We probably should have some basic snake_case validation on field handles... https://github.com/statamic/cms/blob/7948e9934e7f39326451a230ba089d9120502828/src/Http/Controllers/CP/Fields/FieldsController.php#L92-L98

Maybe this is a breaking change for people and should be introduced in 3.4 or 4.0? Field handles with spaces would've only worked in places by fluke in the first place though (ie. {{ my field }}).

Environment

Statamic: 3.3.25

jesseleite avatar Aug 05 '22 20:08 jesseleite

Just a note that {{ my field }} will not work in Antlers Runtime, and will generate [ANTLR_006]: Unexpected stack condition, but will in Regex mode.

JohnathonKoster avatar Aug 05 '22 23:08 JohnathonKoster

Yeah we're just saying if it worked anywhere, it was by accident. Definitely shouldn't be allowed. 👍

jasonvarga avatar Aug 06 '22 16:08 jasonvarga