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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efaf75cf3064504593f43e89db514210910841aed31d54f2d221d14966604f34
4
- data.tar.gz: bca0a633d4aa3fcf774ef6f953c007f0b8e71fc57bf89477e0567a66c9c8ba2c
3
+ metadata.gz: 949c23c7d951df591af05de644bc829ceada5889aed295bb8e8dee5b897054ee
4
+ data.tar.gz: 8418a95af9eca811bf3e3848987bbd83bef233ca7aadaf33455f277cecb759b0
5
5
  SHA512:
6
- metadata.gz: beebade2ac325c6edce39afefe1a2d7016435cb94c18d911a7a1b5bbd6d53273d6d275eacc80f63d1c3be3f9d4dad8782934be1e10e0300ea6d0b8089fc6eaef
7
- data.tar.gz: 757708e37211c4d7a4359f813aa3e68f927112a3999d24e449adb3c3de35178a7504d9b4ded842c790fb4f22b906ee483e060b67ffaada4951a155711af87376
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"].each_with_object({}) do |(_mig_id, file), map|
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.dig(media_id, "destination")&.slice("id", "uuid")&.values
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)
@@ -1,3 +1,3 @@
1
1
  module CanvasLinkMigrator
2
- VERSION = "1.0.16"
2
+ VERSION = "1.0.18"
3
3
  end
@@ -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
@@ -47,6 +47,7 @@
47
47
  }
48
48
  },
49
49
  "files": {
50
+ "3": "5",
50
51
  "E": {
51
52
  "destination": {
52
53
  "id": "5",
@@ -59,6 +60,7 @@
59
60
  "uuid": "u3"
60
61
  }
61
62
  },
63
+ "4":"6",
62
64
  "F": {
63
65
  "destination": {
64
66
  "id": "6",
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.16
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-01-30 00:00:00.000000000 Z
14
+ date: 2025-07-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport