1

I have a strange issue with URLs double encoding. So for instance if I have a URL with spaces, instead of the site navigating to "url%20name" it instead navigates to "url%2520name."

I'm looking at how to rewrite .htaccess to fix this but I feel like the best practice would be to strip the spaces out of the data coming from the safecracker form field.

My code is

   <label for="story_author">Author*</label><br>
    {field:story_author}<br>

What could I add to that to strip out the spaces in the output?

2
  • The best tip would be to never have spaces in URLs in line with RFC 1738. I'd look to remove the spaces and then use .htaccess to catch any requests for old URIs. That will fix the problem with the safecracker form.
    – Ian Young
    Commented Mar 26, 2013 at 14:54
  • I agree, but I don't know how to strip spaces from a safecracker form field. The users are entering their names as "First Last" so I'd need to remove that space. Commented Mar 26, 2013 at 15:48

1 Answer 1

1

You could either turn on PHP in your templates and use regular PHP:

trim({field:story_author})

Or you could use a small plugin and keep PHP out of your templates. TextTrimmer will strip out whitespace and is just $3. Either solution should work depending on which you feel more comfortable with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.