Module: PHPRB::Util
- Defined in:
- lib/web/phprb.rb
Instance Method Summary collapse
- #html_escape(s) ⇒ Object (also: #h)
- #url_encode(s) ⇒ Object (also: #u)
Instance Method Details
#html_escape(s) ⇒ Object Also known as: h
454 455 456 |
# File 'lib/web/phprb.rb', line 454 def html_escape(s) s.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |
#url_encode(s) ⇒ Object Also known as: u
459 460 461 |
# File 'lib/web/phprb.rb', line 459 def url_encode(s) s.to_s.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) } end |