ed-precompiled_erb 5.0.3-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.document +6 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/dependabot_automerge.yml +30 -0
- data/.github/workflows/sync-ruby.yml +33 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +12 -0
- data/.rdoc_options +1 -0
- data/BDSL +22 -0
- data/COPYING +56 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +2 -0
- data/NEWS.md +69 -0
- data/README.md +98 -0
- data/Rakefile +19 -0
- data/_doc/cgi.rb +3 -0
- data/_doc/erb_executable.md +240 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/erb.gemspec +36 -0
- data/ext/erb/escape/escape.c +102 -0
- data/ext/erb/escape/extconf.rb +9 -0
- data/lib/erb/3.2/escape.so +0 -0
- data/lib/erb/3.3/escape.so +0 -0
- data/lib/erb/3.4/escape.so +0 -0
- data/lib/erb/compiler.rb +488 -0
- data/lib/erb/def_method.rb +47 -0
- data/lib/erb/escape.so +0 -0
- data/lib/erb/util.rb +77 -0
- data/lib/erb/version.rb +5 -0
- data/lib/erb.rb +1220 -0
- data/libexec/erb +184 -0
- metadata +80 -0
data/lib/erb/util.rb
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Load CGI.escapeHTML and CGI.escapeURIComponent.
|
|
4
|
+
# CRuby:
|
|
5
|
+
# cgi.gem v0.1.0+ (Ruby 2.7-3.4) and Ruby 3.5+ stdlib have 'cgi/escape' and CGI.escapeHTML.
|
|
6
|
+
# cgi.gem v0.3.3+ (Ruby 3.2-3.4) and Ruby 3.5+ stdlib have CGI.escapeURIComponent.
|
|
7
|
+
# JRuby: cgi.gem has a Java extension 'cgi/escape'.
|
|
8
|
+
# TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'.
|
|
9
|
+
require 'cgi/escape'
|
|
10
|
+
|
|
11
|
+
# Load or define ERB::Escape#html_escape.
|
|
12
|
+
# We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM.
|
|
13
|
+
# miniruby (used by CRuby build scripts) also fails to load erb/escape.so.
|
|
14
|
+
begin
|
|
15
|
+
ruby_version = /(\d+\.\d+)/.match(::RUBY_VERSION)
|
|
16
|
+
require "erb/#{ruby_version}/escape"
|
|
17
|
+
rescue LoadError
|
|
18
|
+
# ERB::Escape
|
|
19
|
+
#
|
|
20
|
+
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
|
|
21
|
+
# Rails will not monkey-patch ERB::Escape#html_escape.
|
|
22
|
+
module ERB::Escape
|
|
23
|
+
def html_escape(s)
|
|
24
|
+
CGI.escapeHTML(s.to_s)
|
|
25
|
+
end
|
|
26
|
+
module_function :html_escape
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# ERB::Util
|
|
31
|
+
#
|
|
32
|
+
# A utility module for conversion routines, often handy in HTML generation.
|
|
33
|
+
module ERB::Util
|
|
34
|
+
#
|
|
35
|
+
# A utility method for escaping HTML tag characters in _s_.
|
|
36
|
+
#
|
|
37
|
+
# require "erb"
|
|
38
|
+
# include ERB::Util
|
|
39
|
+
#
|
|
40
|
+
# puts html_escape("is a > 0 & a < 10?")
|
|
41
|
+
#
|
|
42
|
+
# _Generates_
|
|
43
|
+
#
|
|
44
|
+
# is a > 0 & a < 10?
|
|
45
|
+
#
|
|
46
|
+
include ERB::Escape # html_escape
|
|
47
|
+
module_function :html_escape
|
|
48
|
+
alias h html_escape
|
|
49
|
+
module_function :h
|
|
50
|
+
|
|
51
|
+
if CGI.respond_to?(:escapeURIComponent)
|
|
52
|
+
#
|
|
53
|
+
# A utility method for encoding the String _s_ as a URL.
|
|
54
|
+
#
|
|
55
|
+
# require "erb"
|
|
56
|
+
# include ERB::Util
|
|
57
|
+
#
|
|
58
|
+
# puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
|
|
59
|
+
#
|
|
60
|
+
# _Generates_
|
|
61
|
+
#
|
|
62
|
+
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
|
63
|
+
#
|
|
64
|
+
def url_encode(s)
|
|
65
|
+
CGI.escapeURIComponent(s.to_s)
|
|
66
|
+
end
|
|
67
|
+
else # cgi.gem <= v0.3.2
|
|
68
|
+
def url_encode(s)
|
|
69
|
+
s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) do |m|
|
|
70
|
+
sprintf("%%%02X", m.unpack1("C"))
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
alias u url_encode
|
|
75
|
+
module_function :u
|
|
76
|
+
module_function :url_encode
|
|
77
|
+
end
|