Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Escape HTML on output
Browse files Browse the repository at this point in the history
  • Loading branch information
ptere committed Aug 30, 2022
1 parent 6303d3e commit ca43995
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions views/cart.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="container">
<h1><%= @cart[:cart_name] %></h1>
<h1><%= h @cart[:cart_name] %></h1>
</div>

<div class="container">
<% if @gateway %>

<p class="lead">Great! You have configurated a Gateway.</p>
<p>Your Gateway token is <em>'<%= @gateway[:gateway_token] %>'</em>. You can see how it was retained using the secure API by looking at <a href="https://github.com/spreedly/sample-foodcarts/blob/master/web.rb">the application code</a>.</p>
<p>Your Gateway token is <em>'<%= h @gateway[:gateway_token] %>'</em>. You can see how it was retained using the secure API by looking at <a href="https://github.com/spreedly/sample-foodcarts/blob/master/web.rb">the application code</a>.</p>
<p>Now imagine having thousands of customers, each one using a different Gateway. You are able to store credit cards and other payment methods in Spreedly's vault for all of them. If they decide to move to another Gateway, you can tell them, "No problemo! We're using Spreedly!"<p>
<p>spreedly.js has been designed to simplify your integration with Spreedly. Thanks for exploring, and <a href="mailto:[email protected]?subject=Food%20Carts%20Sample%20-%20spreedly.js">please let us know</a> if you have any trouble.</p>

Expand All @@ -19,7 +19,7 @@
data-theme="default"
data-types="test">
<input type="hidden" name="authenticity_token" value="<%= env['rack.session'][:csrf] %>" />
<input type="hidden" name="cart_name" value="<%= @cart[:cart_name] %>"></input>
<input type="hidden" name="cart_name" value="<%= hattr @cart[:cart_name] %>"></input>
</form>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def view(template)
@active = template
erb template
end

def h(text)
Rack::Utils.escape_html(text)
end

def hattr(text)
Rack::Utils.escape_path(text)
end
end

before do
Expand Down

0 comments on commit ca43995

Please sign in to comment.