How to handle the "\b" (the backspace character) in your Rails application?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to handle the "\b" (the backspace character) in your Rails application?

Paul McMahon
Somehow, users sometimes enter "\b" (the backspace character) into our web forms.For the sake of example, say they enter in "Foo\bbar" into a form.

This then gets saved to the database as is "Foo\bbar". When I later include this in my html, it gets added as is (so my html contains "Foo\bbar"). However, the browser renders it as "Foobar". This seems to match the users intention (they want to display "Foobar"), and so they leave it as is. The only way a user might notice this is if they try and copy and paste the displayed text, they'll get "Fobar" (the backspace character is applied).

I bring this up as an issue as PayPal crashes if you try to create a charge with "\b" in their memo field.

I'm wondering how our application should handle this. My first instinct was to just strip them from the model attribute that's being to create a charge with PayPal, resolving my immediate issue. However, that got me wondering, should I just strip this character from all my models, and in that case, would this make sense as a Rails feature?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7e1af55e-4ff6-4ef0-bc5c-ec0c353675f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle the "\b" (the backspace character) in your Rails application?

fugee ohu


On Monday, June 4, 2018 at 5:56:59 AM UTC-4, Paul McMahon wrote:
Somehow, users sometimes enter "\b" (the backspace character) into our web forms.For the sake of example, say they enter in "Foo\bbar" into a form.

This then gets saved to the database as is "Foo\bbar". When I later include this in my html, it gets added as is (so my html contains "Foo\bbar"). However, the browser renders it as "Foobar". This seems to match the users intention (they want to display "Foobar"), and so they leave it as is. The only way a user might notice this is if they try and copy and paste the displayed text, they'll get "Fobar" (the backspace character is applied).

I bring this up as an issue as PayPal crashes if you try to create a charge with "\b" in their memo field.

I'm wondering how our application should handle this. My first instinct was to just strip them from the model attribute that's being to create a charge with PayPal, resolving my immediate issue. However, that got me wondering, should I just strip this character from all my models, and in that case, would this make sense as a Rails feature?

sanitize helper in views so it'll be stripped out before being rendered and they're not gonna be allowed to use it as input, i guess you could use it on your params in any controller too no?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/795d465b-8b60-45f2-86db-fbee3ea8d8e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle the "\b" (the backspace character) in your Rails application?

fugee ohu
In reply to this post by Paul McMahon


On Monday, June 4, 2018 at 5:56:59 AM UTC-4, Paul McMahon wrote:
Somehow, users sometimes enter "\b" (the backspace character) into our web forms.For the sake of example, say they enter in "Foo\bbar" into a form.

This then gets saved to the database as is "Foo\bbar". When I later include this in my html, it gets added as is (so my html contains "Foo\bbar"). However, the browser renders it as "Foobar". This seems to match the users intention (they want to display "Foobar"), and so they leave it as is. The only way a user might notice this is if they try and copy and paste the displayed text, they'll get "Fobar" (the backspace character is applied).

I bring this up as an issue as PayPal crashes if you try to create a charge with "\b" in their memo field.

I'm wondering how our application should handle this. My first instinct was to just strip them from the model attribute that's being to create a charge with PayPal, resolving my immediate issue. However, that got me wondering, should I just strip this character from all my models, and in that case, would this make sense as a Rails feature?

You don't want to accomodate them in allowing them to input the special character do you? 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/98e579db-1669-40f0-8185-6f075a856ede%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle the "\b" (the backspace character) in your Rails application?

Paul McMahon
On Monday, June 4, 2018 at 7:30:31 PM UTC+9, fugee ohu wrote:
You don't want to accomodate them in allowing them to input the special character do you? 

There's no reason I can see of in our app (or almost any Rails app) you'd want to allow the "\b" character as user input.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b29d08b3-b104-47e2-92d5-df913c8571dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.