statamic / workshop

Create and edit entries, pages, and globals on the front-end of your site without the control panel.
https://statamic.com/marketplace/addons/workshop
3 stars 2 forks source link

ParseException when text input starts with special character #32

Open danielfowler opened 5 years ago

danielfowler commented 5 years ago

Describe the bug I have a Twitter handle field input for users and some are including the @ symbol at the start of their input. Workshop isn't wrapping the resultant string in quotes, which is throwing a ParseException upon trying to load the value in template.

To Reproduce Steps to reproduce the behavior:

  1. Fresh install of Statamic
  2. Add Workshop
  3. Create a text input like <input name="twitter"/>
  4. Load in browser and save text input value like @statamic
  5. Load any page in browser

Expected behavior String value would save as twitter: "@statamic" and page would load

Screenshots If applicable, add screenshots to help explain your problem.

Environment details (please complete the following information):

Additional context Technically this is happening through the Profiler add-on, but it's using the Workshop engine to save values to user files.

Error stack trace:

ParseException in Inline.php line 334: The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 18 (near "instagram: @justclawsonthings").

    in Inline.php line 334
    at Inline::parseScalar('@justclawsonthings', '0', null, '18', true, array()) in Inline.php line 109
    at Inline::parse('@justclawsonthings', '0', array()) in Parser.php line 757
    at Parser->parseValue('@justclawsonthings', '0', 'mapping') in Parser.php line 354
    at Parser->doParse('6167381437', '0') in Parser.php line 105
danielfowler commented 5 years ago

I'm troubleshooting a bunch of errors right now, so please excuse my sudden run on issue reporting.

Update: it seems all leading special characters in text inputs aren't being escaped on save. I'm seeing issues with strings that contain apostrophes and/or quotation marks start with special characters.

A couple examples: