relaton-render 1.2.0 → 1.2.1

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: bfa59dd1186cb178a96316ffff00066b9c048a326f47dda9381424f4d805e79c
4
- data.tar.gz: b6f23cf5a7190c5cbac9b57350cf3a3812da2fbf94cf45218d02c7f4a8bc026c
3
+ metadata.gz: 4bcf0448a633329d256fee9e297e7c50182a5e214014a7cb78a9d3ab7ec3147f
4
+ data.tar.gz: 766c8ddbb23a88334eaf2d3be35894ffe62ce300126c7cdded5af90e8341a7a6
5
5
  SHA512:
6
- metadata.gz: 8a857436fbd6e62d3d0471efe0a8c0b4b2a77684a9346558d1912d51fdd84d353a8c40aa7a141f5bfd03da162dd97e0a6c5817e86dffaa3c139e2df0b7d638c8
7
- data.tar.gz: 8701d33d12f8cad24ccb245c0804c4e3e886aa833a6a8da8d86866acd2b7db540c12221a47ec9ae234617744c8cc26bec40c1c2192900ec89ce1af002135d697
6
+ metadata.gz: 9ff2d1381a4075e7c0c5b46a5fb174b1190621b25760600928f2b49da2379eea21006f17468d74c89e9c1f30cd8abb49f591bd5361e5ab57e029a6de04d09c57
7
+ data.tar.gz: 18b0f1710c29a3e8ce67f055d3dcdefeaf62191ff7711beaa296bf95f669f49699186868172a617a429765c9544de52eb30669b98c2b63f41a46c76b36b91b65
@@ -82,6 +82,8 @@ module Relaton
82
82
  end
83
83
  end
84
84
 
85
+ ALLOWED_INLINE_TAGS = %w[em strong sub sup a smallcap].freeze
86
+
85
87
  private
86
88
 
87
89
  def blank?(text)
@@ -93,6 +95,19 @@ module Relaton
93
95
  "<esc>#{text}</esc>"
94
96
  end
95
97
 
98
+ # Strip any tag not in ALLOWED_INLINE_TAGS, in both literal (<tag>) and
99
+ # entity-encoded (&lt;tag&gt;) forms. Used to defend Liquid template
100
+ # output against embedded structural markup (most commonly <title>) in
101
+ # bibliographic text fields, where relaton-bib may surface either form
102
+ # depending on lutaml-model serialisation behaviour.
103
+ def sanitise_inline_markup(str)
104
+ blank?(str) and return str
105
+ allowed = ALLOWED_INLINE_TAGS.join("|")
106
+ literal = %r{</?(?!(?:#{allowed})\b)[A-Za-z][\w:-]*(?:\s[^>]*)?/?>}
107
+ encoded = %r{&lt;/?(?!(?:#{allowed})\b)[A-Za-z][\w:-]*(?:\s[^&]*?)?/?&gt;}
108
+ str.gsub(literal, "").gsub(encoded, "")
109
+ end
110
+
96
111
  def wrap_in_esc(obj)
97
112
  case obj
98
113
  when String then esc(obj)
@@ -4,15 +4,12 @@ module Relaton
4
4
  def content(node)
5
5
  node.nil? and return node
6
6
  node.is_a?(String) and
7
- return node.strip.gsub("</title>", "").gsub("<title>", "")
7
+ return sanitise_inline_markup(node.strip)
8
8
  .gsub(/>\n\s*</, "><").gsub(/\n\s*/, " ")
9
9
  node.content.is_a?(Array) and return node.content.map { |x| content(x) }
10
- ret = node.content.strip
11
- .gsub("</title>", "").gsub("<title>", "")
10
+ ret = sanitise_inline_markup(node.content.strip)
12
11
  # safeguard against indented XML
13
12
  ret.gsub(/>\n\s*</, "><").gsub(/\n\s*/, " ")
14
- # node.children.map { |n| n.text? ? n.content : n.to_xml }.join
15
- # node.text? ? node.content.strip : node.to_xml.strip
16
13
  end
17
14
 
18
15
  def extract_orgname(org)
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Render
3
- VERSION = "1.2.0".freeze
3
+ VERSION = "1.2.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-render
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-11 00:00:00.000000000 Z
11
+ date: 2026-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler