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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37b3d1b2d32cd45ef6a97096e97bd5c6a39009ace98ead88dac0fdc89e786528
4
- data.tar.gz: c02fc34b91be2c3dbad1f577b590be80d1eae9043803cd0fa2819ec465f47dce
3
+ metadata.gz: 22585d14a68f2f43593a60d1cd6f6173cd0c6103ef715f381195f8a4f006588e
4
+ data.tar.gz: a89a7168c5175e862ef902b7501ffb85a1fa195298dd4d5b981f69695fa49cfb
5
5
  SHA512:
6
- metadata.gz: 6efda648bfaf41d5fba86200f2a3d063e186982cf1325721dcbc49660933592492526802e4c052850e710887dbefd10275001738a2fb149d3abb1bae620e9445
7
- data.tar.gz: af138286dcc50de2e72defd69f535b9854ccbe5236b54c320a33b2a9e08487ff3ad557a90b6ae8486dd882c34c02d99d707b5abb8c344feb6a1e34b00a9d03d0
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 (expr.start_with?('"') && expr.end_with?('"')) ||
1046
- (expr.start_with?("'") && expr.end_with?("'"))
1047
- return expr[1..-2]
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) { CGI.escape(v.to_s) },
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>\n") },
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.13.26"
4
+ VERSION = "3.13.27"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.26
4
+ version: 3.13.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team