Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Base64 to pass text through compiled erb templates #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/better_html/better_erb/runtime_checks.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "base64"
require "action_view"

module BetterHtml
Expand Down Expand Up @@ -32,7 +33,7 @@ def wrap_method
def add_expr_auto_escaped(src, code, auto_escape)
flush_newline_if_pending(src)

escaped_code = escape_text(code)
escaped_code = Base64.urlsafe_encode64(code)

src << "#{wrap_method}(@output_buffer, (#{parser_context.inspect}), '#{escaped_code}'.freeze, #{auto_escape})"
method_name = "safe_#{@parser.context}_append"
Expand Down
4 changes: 3 additions & 1 deletion lib/better_html/better_erb/validated_output_buffer.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# frozen_string_literal: true

require "base64"

module BetterHtml
class BetterErb
class ValidatedOutputBuffer
class Context
def initialize(output, context, code, auto_escape)
@output = output
@context = context
@code = code
@code = Base64.urlsafe_decode64(code)
@auto_escape = auto_escape
end

Expand Down
Loading