upmark 1.1.0 → 2.0.0

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: 6b50ae60e763766a5a5b4276591f488e17668ef3d85d2f78079d2a259e81fcdc
4
- data.tar.gz: 3d5722b9cee80ab15a9d9f975b0b6f5d662a53d325a54849ec47bbe6c17ee4d6
3
+ metadata.gz: 30ee9a20ac459c48e9a74d6b2ce2df2328366421c2193b0b81b7d60504dbb171
4
+ data.tar.gz: 5cd1167cf96a88018f9a34cd1ea7b330b21c7732ffaf1525f110694f83f90edc
5
5
  SHA512:
6
- metadata.gz: bed12a83c45c01bc2033d4c41bd3a5af61aa2777925f51b19322a0655756f8d4aab7f76b1db1a633b08bd9d43a1f30001b0489ca4bb8ad7105666d3e5f3f7d50
7
- data.tar.gz: b2ffc99286769acc223f9065bbdacf82c3c3ca2c6132120b7af036ec8a71721950bd03125f61767c6411fb93c5f19ab10ea78f780ad534449ab670c4410e312c
6
+ metadata.gz: d3e08e299cc8405a1c2833637b85ffd04aa078f7af031f8a52745fd742d316aae118efbfa0c32db8a6411ea94be684c488902a9864b9bc664eab0f2c39a84247
7
+ data.tar.gz: 858361e80fa96cd4001c317b3af32dfc36bf30d6ca70375c1fac81f24b3d96cd9c02f0ad1ee17f9059c4141a6e9b2916a587f456bb91004cc6e8c44c15e9d0c3
@@ -71,7 +71,7 @@ module Upmark
71
71
 
72
72
  element(:img) do |element|
73
73
  attributes = map_attributes_subtree(element[:attributes])
74
- href = attributes[:src]
74
+ href = attributes[:src].to_s
75
75
  title = attributes[:title]
76
76
  alt_text = attributes[:alt]
77
77
 
data/lib/upmark.rb CHANGED
@@ -14,7 +14,11 @@ module Upmark
14
14
  preprocess = Transform::Preprocess.new
15
15
  markdown = Transform::Markdown.new
16
16
 
17
- ast = xml.parse(html.strip)
17
+ # Remove base64 data URLs that cause parser issues
18
+ html = html.gsub(/(data:image\/[^;]*;base64,)[A-Za-z0-9+\/=]+/, '').strip
19
+
20
+ ast = xml.parse(html)
21
+
18
22
  ast = normalise.apply(ast)
19
23
  ast = preprocess.apply(ast)
20
24
  ast = markdown.apply(ast)
@@ -86,6 +86,17 @@ Labor MP calls to end dogs
86
86
  ![messenger bag skateboard](http://helvetica.com/image.gif "art party organic")
87
87
  MD
88
88
  end
89
+
90
+ specify "removes base64 data URLs" do
91
+ expect(<<~HTML).to convert_to("")
92
+ <img src="data:image/png;base64,abc" />
93
+ HTML
94
+
95
+ src = "abc" * 10000
96
+ expect(<<~HTML).to convert_to("")
97
+ <img src="data:image/png;base64,#{src}" />
98
+ HTML
99
+ end
89
100
  end
90
101
 
91
102
  context "<p>" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bassett
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-22 00:00:00.000000000 Z
13
+ date: 2025-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec