tina4ruby 3.13.26 → 3.13.27
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 +4 -4
- data/lib/tina4/frond.rb +26 -8
- data/lib/tina4/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22585d14a68f2f43593a60d1cd6f6173cd0c6103ef715f381195f8a4f006588e
|
|
4
|
+
data.tar.gz: a89a7168c5175e862ef902b7501ffb85a1fa195298dd4d5b981f69695fa49cfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3cb82ae2d3b78cc1fecc97427200181298c6a4da3fbb1ce5820cce8f066621bacd04f8345ee33636ea2fc1ed0b2b8f905d48358c09d0294448edc87aab54af7
|
|
7
|
+
data.tar.gz: e551aea110d6e9e86e44d003522145a734221da3942120c2c563df98e05b4092c66919afebeecaae01ed78ca2c533fc6b8ef6eb2a78bf4ebbf0f604c0656ba46
|
data/lib/tina4/frond.rb
CHANGED
|
@@ -10,6 +10,7 @@ require "json"
|
|
|
10
10
|
require "digest"
|
|
11
11
|
require "base64"
|
|
12
12
|
require "cgi"
|
|
13
|
+
require "erb"
|
|
13
14
|
require "uri"
|
|
14
15
|
require "date"
|
|
15
16
|
require "time"
|
|
@@ -738,7 +739,7 @@ module Tina4
|
|
|
738
739
|
when "title" then value.to_s.split.map(&:capitalize).join(" ")
|
|
739
740
|
when "string" then value.to_s
|
|
740
741
|
when "int" then value.to_i
|
|
741
|
-
when "escape", "e" then Frond.escape_html(value.to_s)
|
|
742
|
+
when "escape", "e" then Tina4::SafeString.new(Frond.escape_html(value.to_s))
|
|
742
743
|
else value
|
|
743
744
|
end
|
|
744
745
|
next
|
|
@@ -1042,9 +1043,26 @@ module Tina4
|
|
|
1042
1043
|
# ── Literal values: strings, numbers, booleans, null ──
|
|
1043
1044
|
|
|
1044
1045
|
def eval_literal(expr)
|
|
1045
|
-
if
|
|
1046
|
-
|
|
1047
|
-
|
|
1046
|
+
if expr.length >= 2 && (expr[0] == '"' || expr[0] == "'") && expr[-1] == expr[0]
|
|
1047
|
+
# Only a SINGLE complete string literal — i.e. the opening quote's
|
|
1048
|
+
# match is the final char. Without this check, `'a' ~ 'b'` and
|
|
1049
|
+
# `'Y' if x else 'N'` (which merely start and end with a quote) get
|
|
1050
|
+
# their outer quotes stripped here before concat / inline-if run.
|
|
1051
|
+
q = expr[0]
|
|
1052
|
+
i = 1
|
|
1053
|
+
single = false
|
|
1054
|
+
while i < expr.length
|
|
1055
|
+
if expr[i] == "\\"
|
|
1056
|
+
i += 2
|
|
1057
|
+
next
|
|
1058
|
+
end
|
|
1059
|
+
if expr[i] == q
|
|
1060
|
+
single = (i == expr.length - 1)
|
|
1061
|
+
break
|
|
1062
|
+
end
|
|
1063
|
+
i += 1
|
|
1064
|
+
end
|
|
1065
|
+
return expr[1..-2] if single
|
|
1048
1066
|
end
|
|
1049
1067
|
return expr.to_i if expr =~ INTEGER_RE
|
|
1050
1068
|
return expr.to_f if expr =~ FLOAT_RE
|
|
@@ -1894,8 +1912,8 @@ module Tina4
|
|
|
1894
1912
|
"striptags" => ->(v, *_a) { v.to_s.gsub(STRIPTAGS_RE, "") },
|
|
1895
1913
|
|
|
1896
1914
|
# -- Encoding --
|
|
1897
|
-
"escape" => ->(v, *_a) { Frond.escape_html(v.to_s) },
|
|
1898
|
-
"e" => ->(v, *_a) { Frond.escape_html(v.to_s) },
|
|
1915
|
+
"escape" => ->(v, *_a) { Tina4::SafeString.new(Frond.escape_html(v.to_s)) },
|
|
1916
|
+
"e" => ->(v, *_a) { Tina4::SafeString.new(Frond.escape_html(v.to_s)) },
|
|
1899
1917
|
"raw" => ->(v, *_a) { v },
|
|
1900
1918
|
"safe" => ->(v, *_a) { v },
|
|
1901
1919
|
"json_encode" => ->(v, *_a) { JSON.generate(v) rescue v.to_s },
|
|
@@ -1914,7 +1932,7 @@ module Tina4
|
|
|
1914
1932
|
v.to_s
|
|
1915
1933
|
end
|
|
1916
1934
|
},
|
|
1917
|
-
"url_encode" => ->(v, *_a) {
|
|
1935
|
+
"url_encode" => ->(v, *_a) { ERB::Util.url_encode(v.to_s) },
|
|
1918
1936
|
|
|
1919
1937
|
# -- JSON / JS --
|
|
1920
1938
|
"to_json" => ->(v, *a) {
|
|
@@ -2058,7 +2076,7 @@ module Tina4
|
|
|
2058
2076
|
lines.join("\n")
|
|
2059
2077
|
},
|
|
2060
2078
|
"slug" => ->(v, *_a) { v.to_s.downcase.gsub(SLUG_CLEAN_RE, "-").gsub(SLUG_TRIM_RE, "") },
|
|
2061
|
-
"nl2br" => ->(v, *_a) { v.to_s.gsub("\n", "<br
|
|
2079
|
+
"nl2br" => ->(v, *_a) { Tina4::SafeString.new(Frond.escape_html(v.to_s).gsub("\n", "<br />\n")) },
|
|
2062
2080
|
"format" => ->(v, *a) {
|
|
2063
2081
|
if a.any?
|
|
2064
2082
|
v.to_s % a
|
data/lib/tina4/version.rb
CHANGED