redcarpet 1.2.0 → 1.2.1
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.
Potentially problematic release.
This version of redcarpet might be problematic. Click here for more details.
- data/ext/render.c +12 -6
- data/lib/redcarpet.rb +1 -1
- data/redcarpet.gemspec +2 -2
- data/test/redcarpet_test.rb +6 -0
- metadata +4 -4
data/ext/render.c
CHANGED
@@ -22,7 +22,8 @@
|
|
22
22
|
#include <stdio.h>
|
23
23
|
|
24
24
|
|
25
|
-
static int
|
25
|
+
static int
|
26
|
+
is_safe_link(const char *link, size_t link_len)
|
26
27
|
{
|
27
28
|
static const size_t valid_uris_count = 4;
|
28
29
|
static const char *valid_uris[] = {
|
@@ -41,6 +42,12 @@ static int is_safe_link(const char *link, size_t link_len)
|
|
41
42
|
return 0;
|
42
43
|
}
|
43
44
|
|
45
|
+
static inline int
|
46
|
+
is_uri_char(char c)
|
47
|
+
{
|
48
|
+
return isalnum(c) || strchr("/:$-_.+!*'(),", c) != NULL;
|
49
|
+
}
|
50
|
+
|
44
51
|
static int
|
45
52
|
put_scaped_char(struct buf *ob, char c)
|
46
53
|
{
|
@@ -435,17 +442,16 @@ rndr_normal_text(struct buf *ob, struct buf *text, struct mkd_renderopt *options
|
|
435
442
|
*/
|
436
443
|
if (autolink) {
|
437
444
|
/* Autolinking is not standarized in the Markdown spec.
|
438
|
-
* We only check for links after
|
439
|
-
|
440
|
-
if ((i == 0 || isspace(text->data[i - 1]) || text->data[i - 1] == '(') &&
|
445
|
+
* We only check for links immediately after a space */
|
446
|
+
if ((i == 0 || isspace(text->data[i - 1])) &&
|
441
447
|
is_safe_link(text->data + i, text->size - i)) {
|
442
448
|
size_t j = i + i;
|
443
449
|
|
444
|
-
while (j < text->size &&
|
450
|
+
while (j < text->size && is_uri_char(text->data[j]))
|
445
451
|
j++;
|
446
452
|
|
447
453
|
rndr_autolink2(ob, &text->data[i], j - i, MKDA_NORMAL);
|
448
|
-
i = j;
|
454
|
+
i = j - 1;
|
449
455
|
continue;
|
450
456
|
}
|
451
457
|
}
|
data/lib/redcarpet.rb
CHANGED
data/redcarpet.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'redcarpet'
|
3
|
-
s.version = '1.2.
|
3
|
+
s.version = '1.2.1'
|
4
4
|
s.summary = "Ruby bindings for libupskirt"
|
5
|
-
s.date = '2011-04-
|
5
|
+
s.date = '2011-04-04'
|
6
6
|
s.email = 'vicent@github.com'
|
7
7
|
s.homepage = 'http://github.com/tanoku/redcarpet'
|
8
8
|
s.has_rdoc = true
|
data/test/redcarpet_test.rb
CHANGED
@@ -122,4 +122,10 @@ class RedcarpetTest < Test::Unit::TestCase
|
|
122
122
|
assert_equal exp, rd.toc_content.strip
|
123
123
|
end
|
124
124
|
|
125
|
+
def test_whitespace_after_urls
|
126
|
+
rd = Redcarpet.new("Japan: http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm (yes, japan)", :autolink)
|
127
|
+
exp = %{<p>Japan: <a href="http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm">http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm</a> (yes, japan)</p>}
|
128
|
+
assert_equal exp, rd.to_html.strip
|
129
|
+
end
|
130
|
+
|
125
131
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcarpet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Natacha Port\xC3\xA9"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-04-
|
19
|
+
date: 2011-04-04 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|