简体   繁体   中英

Undo html escape with ruby on rails data migration

I have a database, and currently many of the items within it have been html escaped. I need to undo this (don't ask why!), for which I'll carry out a data migration.

But is the a way to un-escape these strings? I've not been able to find anything..

Ruby's CGI::unescapeHTML can do HTML unescaping.

Unescape a string that has been HTML-escaped

  CGI::unescapeHTML("Usage: foo "bar" <baz>")
     # => "Usage: foo \"bar\" <baz>"

您应该看看htmlentities gem

If i understand it correct you need to replace strings like &gt; to > . If so - check xml documentation and replace required strings with their real values. I dont code in ruby, so this one you got to figure out :] XML special characters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM