ruby on rails - Coping with "string contains null byte" sent from users -
i have api controller receives information media file's path , id3 tags, , saves them active record instance, using postgresql/rails.
sometimes user sends strings such as:
"genre"=>"hip-hop\u0000hip-hop/rap"
and rails/postgres aren't happy when trying persist on save
:
an argumenterror occurred in internals#receive: string contains null byte activerecord (3.2.21) lib/active_record/connection_adapters/postgresql_adapter.rb:1172:in `send_query_prepared'
how can clean string in ruby remove null bytes?
the gsub
method on string
suitable. can string.gsub("\u0000", '')
rid of them.
Comments
Post a Comment