canvas_link_migrator 1.0.16 → 1.0.18
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/canvas_link_migrator/link_parser.rb +1 -1
- data/lib/canvas_link_migrator/resource_map_service.rb +3 -3
- data/lib/canvas_link_migrator/version.rb +1 -1
- data/spec/canvas_link_migrator/link_parser_spec.rb +14 -0
- data/spec/fixtures/canvas_resource_map.json +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 949c23c7d951df591af05de644bc829ceada5889aed295bb8e8dee5b897054ee
|
4
|
+
data.tar.gz: 8418a95af9eca811bf3e3848987bbd83bef233ca7aadaf33455f277cecb759b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e886dbeaefd433185a7036739dba643c4c26add118b0dd737ee79db6e1dd7e384ba1a5389491023a857b72727055f494e2894746e5f55849ea13f11855c5b4b
|
7
|
+
data.tar.gz: 97f130e22876d639a79faf0b062442252df9392b8e2338a6bf6b46793a83d815b954b43e34f4e1ff1fce97f7e4856b4ca34e5085e1b212c58f653dc05ff89c9d
|
@@ -81,7 +81,7 @@ module CanvasLinkMigrator
|
|
81
81
|
|
82
82
|
def convert(html, item_type, mig_id, field, remove_outer_nodes_if_one_child: nil)
|
83
83
|
mig_id = mig_id.to_s
|
84
|
-
doc = Nokogiri::HTML5.fragment(html || "")
|
84
|
+
doc = Nokogiri::HTML5.fragment(html || "", max_tree_depth: 10_000)
|
85
85
|
|
86
86
|
# Replace source tags with iframes
|
87
87
|
doc.search("source[data-media-type],source[data-media-id]").each do |source|
|
@@ -93,15 +93,15 @@ module CanvasLinkMigrator
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def media_map
|
96
|
-
@media_map ||= resources["files"]
|
97
|
-
media_id = file.dig("destination", "media_entry_id")
|
96
|
+
@media_map ||= resources["files"]&.each_with_object({}) do |(_mig_id, file), map|
|
97
|
+
media_id = file.dig("destination", "media_entry_id") if file.respond_to?(:dig)
|
98
98
|
next unless media_id
|
99
99
|
map[media_id] = file
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
def convert_attachment_media_id(media_id)
|
104
|
-
media_map
|
104
|
+
media_map&.dig(media_id, "destination")&.slice("id", "uuid")&.values
|
105
105
|
end
|
106
106
|
|
107
107
|
def convert_migration_id(type, migration_id)
|
@@ -69,5 +69,19 @@ describe CanvasLinkMigrator::LinkParser do
|
|
69
69
|
doc = Nokogiri::HTML5.fragment(%Q(<a id="media_comment_m-4uoGqVdEqXhpqu2ZMytHSy9XMV73aQ7E" class="instructure_inline_media_comment" data-media_comment_type="video" data-alt=""></a>))
|
70
70
|
expect{ parser.convert(doc.to_html, "type", "lookup_id", "field") }.not_to raise_error
|
71
71
|
end
|
72
|
+
|
73
|
+
it "handles deeply nested html up to 10.000 levels" do
|
74
|
+
deeply_nested_html = "<div>" * 9999
|
75
|
+
deeply_nested_html += "<a target=\"_blank\"></a>"
|
76
|
+
deeply_nested_html += "</div>" * 9999
|
77
|
+
expect{ parser.convert(deeply_nested_html, "type", "lookup_id", "field") }.not_to raise_error
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises error when html is beyond 10.000 depth" do
|
81
|
+
deeply_nested_html = "<div>" * 10_000
|
82
|
+
deeply_nested_html += "<a target=\"_blank\"></a>"
|
83
|
+
deeply_nested_html += "</div>" * 10_000
|
84
|
+
expect{ parser.convert(deeply_nested_html, "type", "lookup_id", "field") }.to raise_error("Document tree depth limit exceeded")
|
85
|
+
end
|
72
86
|
end
|
73
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_link_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mysti Lilla
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2025-
|
14
|
+
date: 2025-07-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|