blackstack_commons 1.1.41 → 1.1.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/extend_string.rb +26 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f72ddf1432211dec45c5288eb7ccd1a3c51824f
|
4
|
+
data.tar.gz: 23eb0b0027a1b9e3bd07a5798c92760ce2bccb75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ed23e9086cd0dd9e9d0d746b4308142d2443c7fdaefff25297ca0a8d3a3088fbc458233b703a9c50d7d88f71893433c1c405945856c59135880188bd0f3f02c
|
7
|
+
data.tar.gz: 6f6c9203a3c3fdd0e04c7c14fd7325eae02db3d848e52e99407be302040cfeffd6f7db1f5db1c2b9401c3156fdfd9044c20fa0d1f08cd7f20c4e30464ba972cd
|
data/lib/extend_string.rb
CHANGED
@@ -110,11 +110,34 @@ class String
|
|
110
110
|
|
111
111
|
# Escapes carriage returns and single and double quotes for JavaScript segments.
|
112
112
|
# reference: https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html
|
113
|
+
#
|
114
|
+
# Example:
|
115
|
+
# <%
|
116
|
+
# s = 'Hello World!'
|
117
|
+
# %>
|
118
|
+
# text = "<%=s.escape_javascript%>"
|
119
|
+
#
|
120
|
+
# Never use single-quotation marks, because this method is not supporting it.
|
121
|
+
# <%
|
122
|
+
# s = 'Hello World!'
|
123
|
+
# %>
|
124
|
+
# text = '<%=s.escape_javascript%>'
|
125
|
+
#
|
113
126
|
def escape_javascript
|
114
127
|
s = self.dup
|
115
|
-
|
116
|
-
|
117
|
-
|
128
|
+
js_escape_map = {
|
129
|
+
'\\' => '\\\\',
|
130
|
+
"</" => '<\/',
|
131
|
+
"\r\n" => '\n',
|
132
|
+
"\n" => '\n',
|
133
|
+
"\r" => '\n',
|
134
|
+
'"' => '\\"',
|
135
|
+
"'" => "\'",
|
136
|
+
"`" => "\`",
|
137
|
+
"$" => "\\$",
|
138
|
+
}
|
139
|
+
js_escape_map.each { | x, y | s.gsub!(x,y) }
|
140
|
+
s
|
118
141
|
end
|
119
142
|
|
120
143
|
end # class String
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content_spinning
|