bypass 0.0.2 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDBiMzE5MzA3NjVlMDg2MjE4NDdiMzM1MmIwNjg4N2RhNjcwODRiNQ==
4
+ MGE5YjdiM2QyNTc1MTM4MzQ3NGVhODRmM2ZiM2ZhMDAzYmZjZTVhZg==
5
5
  data.tar.gz: !binary |-
6
- OWJlMGQyMjliODRmOGM3YTExZjk5NmIwZThiMmI3ZTgyNDhiYTU2OQ==
6
+ MGU0ODk2YmVmN2Q3ZjNiNjZiZGI3YmNlYjNlYmVlYzYzZjY0NTA2Yw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGY3NTZmMzc1ZGRhYzhlZWU2NWJlZDY2OWFmZWQ4YTJmZTkyNjZiZjY1ZWY3
10
- OWE3NmFlOWJmYzJhMTg5ZWU4MjVhNTE4ZmE5YWM1OWMzMjU3M2FiNThmMzE2
11
- Nzc1OGUzNDc4MWUxODI3YzA4NjVhOTE1NjFhYzM5ZjEwYjJhMWU=
9
+ NzY2NjUzNDJjYjE3MzBjYzY1ZjQ5NTQ0NGY3ZjFhM2I2YWMyYjYxNWI5MTU3
10
+ OWNmMzMxMTFhZWI3NzRjNjFiZWUwNjZiNGUyMzc3ZDNiMDA1MzQ5ZmRiMGEy
11
+ MGE2OWUwY2E5NWJkMjdmYzFjYWI1MTM1OTY4NzQ2YjYwMjA3MDU=
12
12
  data.tar.gz: !binary |-
13
- M2Y0MTVkZTA1ZmI1YjFkNTNiOGI1NTg5YjM3YWQ2MmZmNDBkNDI1YTIyNjA2
14
- MDlmNTFmNGJhOGM3ZjU4YzUyOWIwYTcxOGM1YzM2MWI1ZmI2NWY3MDUyOTky
15
- M2M1ZWY4ZmI3OGMyOGY4OWMzN2Q4NzcxY2M1MDUwMjM2ZTA4MWU=
13
+ YTNmZTcyMzFmMmMxYmNlOTgwZjRiZWI3YjQwM2IwY2ZjMDlmMzU1NjVjMjcz
14
+ YWU0MGE4OWVhZTY5ODY3Njg3OWIyMDkzMGNmZTg4YmViNWEyYzhhNThiMWQ3
15
+ NDkyZGE2NDllNzc3OGU2NmMyMjE2ZTI1MTIyZWYzNGU5OTU5Yzg=
data/.travis.yml CHANGED
@@ -1,11 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
3
+ - 2.0.0
4
4
  - 1.9.2
5
- - jruby-18mode
6
5
  - jruby-19mode
7
- - rbx-2.1.1
8
6
  - ruby-head
9
7
  - jruby-head
10
- - 1.8.7
11
- - ree
data/lib/bypass/filter.rb CHANGED
@@ -25,5 +25,11 @@ module Bypass
25
25
  yield(match.to_s)
26
26
  end
27
27
  end
28
+
29
+ def parse_uri(uri)
30
+ Bypass::URI.parse(uri)
31
+ rescue => ex
32
+ nil
33
+ end
28
34
  end
29
35
  end
@@ -6,8 +6,10 @@ module Bypass
6
6
  def replace(&block)
7
7
  parsed_content.traverse do |node|
8
8
  if node.name == "a" && href = node.get_attribute("href")
9
- url = yield(Bypass::URI.parse(href))
10
- node.set_attribute("href", url.to_s)
9
+ if parsed_href = parse_uri(href)
10
+ url = yield(parsed_href)
11
+ node.set_attribute("href", url.to_s)
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -2,8 +2,10 @@ module Bypass
2
2
  class TextFilter < Filter
3
3
 
4
4
  def replace(&block)
5
- @content = gsub_urls(content) do |url|
6
- yield(Bypass::URI.parse(url)).to_s
5
+ @content = gsub_urls(content) do |url|
6
+ if parsed_url = parse_uri(url)
7
+ yield(parsed_url).to_s
8
+ end
7
9
  end
8
10
  end
9
11
 
@@ -1,3 +1,3 @@
1
1
  module Bypass
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
File without changes
@@ -16,6 +16,13 @@ class Bypass::HTMLFilterTest < Test::Unit::TestCase
16
16
  filter.replace { "foo" }
17
17
  assert_equal "<a>Yahoo</a>", filter.content
18
18
  end
19
+
20
+ should "skip malformed URLs" do
21
+ text = "<a href=\"http://#\">Yahoo</a>"
22
+ filter = Bypass::HTMLFilter.new(text)
23
+ filter.replace { "foo" }
24
+ assert_equal text, filter.content
25
+ end
19
26
  end
20
27
 
21
28
  context "#auto_link" do
@@ -30,5 +30,12 @@ class Bypass::TextFilterTest < Test::Unit::TestCase
30
30
  filter.replace { "foo" }
31
31
  assert_equal "foo,", filter.content
32
32
  end
33
+
34
+ should "skip malformed URLs" do
35
+ text = "http://#"
36
+ filter = Bypass::TextFilter.new(text)
37
+ filter.replace { "foo" }
38
+ assert_equal text, filter.content
39
+ end
33
40
  end
34
41
  end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bypass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Reimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-27 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -86,10 +86,10 @@ files:
86
86
  - lib/bypass/text_filter.rb
87
87
  - lib/bypass/uri.rb
88
88
  - lib/bypass/version.rb
89
- - test/detour/filter_test.rb
90
- - test/detour/html_filter_test.rb
91
- - test/detour/text_filter_test.rb
92
- - test/detour/uri_test.rb
89
+ - test/bypass/filter_test.rb
90
+ - test/bypass/html_filter_test.rb
91
+ - test/bypass/text_filter_test.rb
92
+ - test/bypass/uri_test.rb
93
93
  - test/test_helper.rb
94
94
  homepage: https://github.com/djreimer/bypass
95
95
  licenses: []
@@ -115,8 +115,8 @@ signing_key:
115
115
  specification_version: 4
116
116
  summary: Mutate URLs and hyperlinks in HTML and plain text documents with ease
117
117
  test_files:
118
- - test/detour/filter_test.rb
119
- - test/detour/html_filter_test.rb
120
- - test/detour/text_filter_test.rb
121
- - test/detour/uri_test.rb
118
+ - test/bypass/filter_test.rb
119
+ - test/bypass/html_filter_test.rb
120
+ - test/bypass/text_filter_test.rb
121
+ - test/bypass/uri_test.rb
122
122
  - test/test_helper.rb