redcarpet 1.17.1 → 1.17.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of redcarpet might be problematic. Click here for more details.

@@ -47,6 +47,13 @@ static size_t
47
47
  autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
48
48
  {
49
49
  char cclose, copen = 0;
50
+ size_t i;
51
+
52
+ for (i = 0; i < link_end; ++i)
53
+ if (data[i] == '<') {
54
+ link_end = i;
55
+ break;
56
+ }
50
57
 
51
58
  while (link_end > 0) {
52
59
  if (strchr("?!.,", data[link_end - 1]) != NULL)
@@ -63,11 +70,6 @@ autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
63
70
  else
64
71
  link_end--;
65
72
  }
66
-
67
- else if (data[link_end - 1] == '>') {
68
- while (link_end > 0 && data[link_end] != '<')
69
- link_end--;
70
- }
71
73
  else break;
72
74
  }
73
75
 
@@ -125,11 +127,29 @@ autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
125
127
  return link_end;
126
128
  }
127
129
 
130
+ static size_t
131
+ check_domain(char *data, size_t size)
132
+ {
133
+ size_t i, np = 0;
134
+
135
+ if (!isalnum(data[0]))
136
+ return 0;
137
+
138
+ for (i = 1; i < size - 1; ++i) {
139
+ if (data[i] == '.') np++;
140
+ else if (!isalnum(data[i]) && data[i] != '-') break;
141
+ }
142
+
143
+ if (!isalnum(data[i - 1]) || np == 0)
144
+ return 0;
145
+
146
+ return i;
147
+ }
148
+
128
149
  size_t
129
150
  ups_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
130
151
  {
131
152
  size_t link_end;
132
- int np = 0;
133
153
 
134
154
  if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
135
155
  return 0;
@@ -137,17 +157,14 @@ ups_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset,
137
157
  if (size < 4 || memcmp(data, "www.", STRLEN("www.")) != 0)
138
158
  return 0;
139
159
 
140
- link_end = 0;
141
- while (link_end < size && !isspace(data[link_end])) {
142
- if (data[link_end] == '.')
143
- np++;
144
-
145
- link_end++;
146
- }
160
+ link_end = check_domain(data, size);
147
161
 
148
- if (np < 2)
162
+ if (link_end == 0)
149
163
  return 0;
150
164
 
165
+ while (link_end < size && !isspace(data[link_end]))
166
+ link_end++;
167
+
151
168
  link_end = autolink_delim(data, link_end, offset, size);
152
169
 
153
170
  if (link_end == 0)
@@ -211,7 +228,7 @@ ups_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offse
211
228
  size_t
212
229
  ups_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
213
230
  {
214
- size_t link_end, rewind = 0;
231
+ size_t link_end, rewind = 0, domain_len;
215
232
 
216
233
  if (size < 4 || data[1] != '/' || data[2] != '/')
217
234
  return 0;
@@ -221,8 +238,13 @@ ups_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset,
221
238
 
222
239
  if (!is_safe_link(data - rewind, size + rewind))
223
240
  return 0;
241
+ link_end = STRLEN("://");
242
+
243
+ domain_len = check_domain(data + link_end, size - link_end);
244
+ if (domain_len == 0)
245
+ return 0;
224
246
 
225
- link_end = 0;
247
+ link_end += domain_len;
226
248
  while (link_end < size && !isspace(data[link_end]))
227
249
  link_end++;
228
250
 
@@ -19,12 +19,6 @@
19
19
 
20
20
  #include "buffer.h"
21
21
 
22
- typedef enum {
23
- AUTOLINK_URLS = (1 << 0),
24
- AUTOLINK_EMAILS = (1 << 1),
25
- AUTOLINK_ALL = AUTOLINK_URLS|AUTOLINK_EMAILS
26
- } autolink_mode;
27
-
28
22
  extern size_t
29
23
  ups_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
30
24
 
@@ -26,7 +26,7 @@
26
26
  # end
27
27
  #
28
28
  class Redcarpet
29
- VERSION = '1.17.1'
29
+ VERSION = '1.17.2'
30
30
 
31
31
  # Original Markdown formatted text.
32
32
  attr_reader :text
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'redcarpet'
3
- s.version = '1.17.1'
3
+ s.version = '1.17.2'
4
4
  s.summary = "Ruby bindings for libupskirt"
5
5
  s.description = 'A fast and safe Markdown to (X)HTML parser'
6
- s.date = '2011-06-09'
6
+ s.date = '2011-06-19'
7
7
  s.email = 'vicent@github.com'
8
8
  s.homepage = 'http://github.com/tanoku/redcarpet'
9
9
  s.authors = ["Natacha Porté", "Vicent Martí"]
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: 81
5
- prerelease: false
4
+ hash: 87
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 17
9
- - 1
10
- version: 1.17.1
9
+ - 2
10
+ version: 1.17.2
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-06-09 00:00:00 +02:00
19
+ date: 2011-06-19 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements: []
84
84
 
85
85
  rubyforge_project:
86
- rubygems_version: 1.3.7
86
+ rubygems_version: 1.6.2
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: Ruby bindings for libupskirt