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 +5 -5
- data/COPYING +0 -0
- data/ext/rinku/autolink.c +20 -3
- data/lib/rinku.rb +1 -1
- data/rinku.gemspec +1 -1
- data/test/autolink_test.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 20e9884a2e337d4058ce73eaa6be94c3c7ab49d464d4d5121de480f3ce08297a
|
4
|
+
data.tar.gz: a42374d316c4138d29391f0bb1ce928d9db9cc2b213ed3801bd8a22b199f95fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 016fdc90a1ce59adae6158424b1d762f6f3d49be0bb55472651417091727cd6a10ef8f7fc8b79a90bea3457d656205bc65c748df752b00e4517b01c810400969
|
7
|
+
data.tar.gz: 4b30082da4e29825b5eae3ad07ce88f7a2f5c98fff1f1a1569a70affbdac954a35fdcc90be50154aacaf2a4b8cf2264647783c6d70a04356ce702389f11983fb
|
data/COPYING
CHANGED
File without changes
|
data/ext/rinku/autolink.c
CHANGED
@@ -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] == '
|
170
|
-
|
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) {
|
data/lib/rinku.rb
CHANGED
data/rinku.gemspec
CHANGED
data/test/autolink_test.rb
CHANGED
@@ -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
|
+
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:
|
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.
|
102
|
+
rubygems_version: 2.7.6
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Mostly autolinking
|