rinku 2.0.4 → 2.0.5

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
- SHA1:
3
- metadata.gz: 8d97faec12db81c05ee7700322b7ad7b72a1d883
4
- data.tar.gz: 4b606e2f512b27c6203c18b8abdb3bc31d232435
2
+ SHA256:
3
+ metadata.gz: 20e9884a2e337d4058ce73eaa6be94c3c7ab49d464d4d5121de480f3ce08297a
4
+ data.tar.gz: a42374d316c4138d29391f0bb1ce928d9db9cc2b213ed3801bd8a22b199f95fc
5
5
  SHA512:
6
- metadata.gz: 7425f53947c3bc6c91bf794f80a0d7829b3d3c40fc1c04c389139264cd7478a49950020f475b97a7ff863cc845ae3bcd9e39aac0f53f89ddb15a4a61b27442a0
7
- data.tar.gz: 7b10ef7ed9c9e58489e93886574f1739ee8a03075e767d11b74fbe0fd4b08fcb93348d0b4a1df95e037b77282e7ec782eac712a49c558765ca77fe8ff74d6d48
6
+ metadata.gz: 016fdc90a1ce59adae6158424b1d762f6f3d49be0bb55472651417091727cd6a10ef8f7fc8b79a90bea3457d656205bc65c748df752b00e4517b01c810400969
7
+ data.tar.gz: 4b30082da4e29825b5eae3ad07ce88f7a2f5c98fff1f1a1569a70affbdac954a35fdcc90be50154aacaf2a4b8cf2264647783c6d70a04356ce702389f11983fb
data/COPYING CHANGED
File without changes
@@ -27,6 +27,14 @@
27
27
  #define strncasecmp _strnicmp
28
28
  #endif
29
29
 
30
+ static int
31
+ is_valid_hostchar(const uint8_t *link, size_t link_len)
32
+ {
33
+ size_t pos = 0;
34
+ int32_t ch = utf8proc_next(link, &pos);
35
+ return !utf8proc_is_space(ch) && !utf8proc_is_punctuation(ch);
36
+ }
37
+
30
38
  bool
31
39
  autolink_issafe(const uint8_t *link, size_t link_len)
32
40
  {
@@ -160,16 +168,25 @@ static bool
160
168
  check_domain(const uint8_t *data, size_t size,
161
169
  struct autolink_pos *link, bool allow_short)
162
170
  {
163
- size_t i, np = 0;
171
+ size_t i, np = 0, uscore1 = 0, uscore2 = 0;
164
172
 
165
173
  if (!rinku_isalnum(data[link->start]))
166
174
  return false;
167
175
 
168
176
  for (i = link->start + 1; i < size - 1; ++i) {
169
- if (data[i] == '.') np++;
170
- else if (!rinku_isalnum(data[i]) && data[i] != '-') break;
177
+ if (data[i] == '_') {
178
+ uscore2++;
179
+ } else if (data[i] == '.') {
180
+ uscore1 = uscore2;
181
+ uscore2 = 0;
182
+ np++;
183
+ } else if (!is_valid_hostchar(data + i, size - i) && data[i] != '-')
184
+ break;
171
185
  }
172
186
 
187
+ if (uscore1 > 0 || uscore2 > 0)
188
+ return false;
189
+
173
190
  link->end = i;
174
191
 
175
192
  if (allow_short) {
@@ -1,5 +1,5 @@
1
1
  module Rinku
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
 
4
4
  class << self
5
5
  attr_accessor :skip_tags
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rinku'
3
- s.version = '2.0.4'
3
+ s.version = '2.0.5'
4
4
  s.summary = "Mostly autolinking"
5
5
  s.description = <<-EOF
6
6
  A fast and very smart autolinking library that
@@ -430,4 +430,12 @@ This is just a test. <a href="http://www.pokemon.com">http://www.pokemon.com</a>
430
430
  assert_linked "'<a href=\"http://example.com\">http://example.com</a>'", "'http://example.com'"
431
431
  assert_linked "\"<a href=\"http://example.com\">http://example.com</a>\"\"", "\"http://example.com\"\""
432
432
  end
433
+
434
+ def test_underscore_in_domain
435
+ assert_linked "http://foo_bar.com", "http://foo_bar.com"
436
+ end
437
+
438
+ def test_underscore_in_subdomain
439
+ assert_linked "<a href=\"http://foo_bar.xyz.com\">http://foo_bar.xyz.com</a>", "http://foo_bar.xyz.com"
440
+ end
433
441
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rinku
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicent Marti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-30 00:00:00.000000000 Z
11
+ date: 2019-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.5.1
102
+ rubygems_version: 2.7.6
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Mostly autolinking