rinku 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ Rinku is available as a Ruby gem:
16
16
 
17
17
  The Rinku source is available at GitHub:
18
18
 
19
- $ git clone git://github.com/tanoku/rinku.git
19
+ $ git clone git://github.com/vmg/rinku.git
20
20
 
21
21
  Rinku is a standalone library
22
22
  -----------------------------
@@ -101,7 +101,7 @@ Rinku is written by me
101
101
 
102
102
  I am Vicent Marti, and I wrote Rinku.
103
103
  While Rinku is busy doing autolinks, you should be busy following me on twitter.
104
- [`@tanoku`](http://twitter.com/tanoku). Do it.
104
+ [`@vmg`](http://twitter.com/vmg). Do it.
105
105
 
106
106
  Rinku has an awesome license
107
107
  ----------------------------
@@ -49,7 +49,7 @@ sd_autolink_issafe(const uint8_t *link, size_t link_len)
49
49
  }
50
50
 
51
51
  static size_t
52
- autolink_delim(uint8_t *data, size_t link_end, size_t offset, size_t size)
52
+ autolink_delim(uint8_t *data, size_t link_end, size_t max_rewind, size_t size)
53
53
  {
54
54
  uint8_t cclose, copen = 0;
55
55
  size_t i;
@@ -163,13 +163,13 @@ sd_autolink__www(
163
163
  size_t *rewind_p,
164
164
  struct buf *link,
165
165
  uint8_t *data,
166
- size_t offset,
166
+ size_t max_rewind,
167
167
  size_t size,
168
168
  unsigned int flags)
169
169
  {
170
170
  size_t link_end;
171
171
 
172
- if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
172
+ if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
173
173
  return 0;
174
174
 
175
175
  if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0)
@@ -183,7 +183,7 @@ sd_autolink__www(
183
183
  while (link_end < size && !isspace(data[link_end]))
184
184
  link_end++;
185
185
 
186
- link_end = autolink_delim(data, link_end, offset, size);
186
+ link_end = autolink_delim(data, link_end, max_rewind, size);
187
187
 
188
188
  if (link_end == 0)
189
189
  return 0;
@@ -199,14 +199,14 @@ sd_autolink__email(
199
199
  size_t *rewind_p,
200
200
  struct buf *link,
201
201
  uint8_t *data,
202
- size_t offset,
202
+ size_t max_rewind,
203
203
  size_t size,
204
204
  unsigned int flags)
205
205
  {
206
206
  size_t link_end, rewind;
207
207
  int nb = 0, np = 0;
208
208
 
209
- for (rewind = 0; rewind < offset; ++rewind) {
209
+ for (rewind = 0; rewind < max_rewind; ++rewind) {
210
210
  uint8_t c = data[-rewind - 1];
211
211
 
212
212
  if (isalnum(c))
@@ -238,7 +238,7 @@ sd_autolink__email(
238
238
  if (link_end < 2 || nb != 1 || np == 0)
239
239
  return 0;
240
240
 
241
- link_end = autolink_delim(data, link_end, offset, size);
241
+ link_end = autolink_delim(data, link_end, max_rewind, size);
242
242
 
243
243
  if (link_end == 0)
244
244
  return 0;
@@ -254,7 +254,7 @@ sd_autolink__url(
254
254
  size_t *rewind_p,
255
255
  struct buf *link,
256
256
  uint8_t *data,
257
- size_t offset,
257
+ size_t max_rewind,
258
258
  size_t size,
259
259
  unsigned int flags)
260
260
  {
@@ -263,7 +263,7 @@ sd_autolink__url(
263
263
  if (size < 4 || data[1] != '/' || data[2] != '/')
264
264
  return 0;
265
265
 
266
- while (rewind < offset && isalpha(data[-rewind - 1]))
266
+ while (rewind < max_rewind && isalpha(data[-rewind - 1]))
267
267
  rewind++;
268
268
 
269
269
  if (!sd_autolink_issafe(data - rewind, size + rewind))
@@ -283,7 +283,7 @@ sd_autolink__url(
283
283
  while (link_end < size && !isspace(data[link_end]))
284
284
  link_end++;
285
285
 
286
- link_end = autolink_delim(data, link_end, offset, size);
286
+ link_end = autolink_delim(data, link_end, max_rewind, size);
287
287
 
288
288
  if (link_end == 0)
289
289
  return 0;
@@ -194,7 +194,7 @@ rinku_autolink(
194
194
  void (*link_text_cb)(struct buf *ob, const struct buf *link, void *payload),
195
195
  void *payload)
196
196
  {
197
- size_t i, end;
197
+ size_t i, end, last_link_found = 0;
198
198
  struct buf *link = bufnew(16);
199
199
  char active_chars[256];
200
200
  void (*link_url_cb)(struct buf *, const struct buf *, void *);
@@ -249,8 +249,11 @@ rinku_autolink(
249
249
  }
250
250
 
251
251
  link->size = 0;
252
+
252
253
  link_end = g_callbacks[(int)action](
253
- &rewind, link, (uint8_t *)text + end, end, size - end, flags);
254
+ &rewind, link, (uint8_t *)text + end,
255
+ end - last_link_found,
256
+ size - end, flags);
254
257
 
255
258
  /* print the link */
256
259
  if (link_end > 0) {
@@ -272,7 +275,7 @@ rinku_autolink(
272
275
 
273
276
  link_count++;
274
277
  i = end + link_end;
275
- end = i;
278
+ last_link_found = end = i;
276
279
  } else {
277
280
  end = end + 1;
278
281
  }
@@ -1,5 +1,5 @@
1
1
  module Rinku
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  attr_accessor :skip_tags
4
4
  extend self
5
5
  end
@@ -2,14 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'rinku'
5
- s.version = '1.7.0'
5
+ s.version = '1.7.1'
6
6
  s.summary = "Mostly autolinking"
7
7
  s.description = <<-EOF
8
8
  A fast and very smart autolinking library that
9
9
  acts as a drop-in replacement for Rails `auto_link`
10
10
  EOF
11
11
  s.email = 'vicent@github.com'
12
- s.homepage = 'http://github.com/tanoku/rinku'
12
+ s.homepage = 'http://github.com/vmg/rinku'
13
13
  s.authors = ["Vicent Marti"]
14
14
  # = MANIFEST =
15
15
  s.files = %w[
@@ -15,6 +15,10 @@ class RedcarpetAutolinkTest < Test::Unit::TestCase
15
15
  assert_equal expected, Rinku.auto_link(url)
16
16
  end
17
17
 
18
+ def test_segfault
19
+ Rinku.auto_link("a+b@d.com+e@f.com", mode=:all)
20
+ end
21
+
18
22
  def test_escapes_quotes
19
23
  assert_linked %(<a href="http://website.com/&quot;onmouseover=document.body.style.backgroundColor=&quot;pink&quot;;//">http://website.com/"onmouseover=document.body.style.backgroundColor="pink";//</a>),
20
24
  %(http://website.com/"onmouseover=document.body.style.backgroundColor="pink";//)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rinku
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
- - 0
10
- version: 1.7.0
9
+ - 1
10
+ version: 1.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vicent Marti
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-08 00:00:00 +02:00
18
+ date: 2012-10-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -43,7 +43,7 @@ files:
43
43
  - rinku.gemspec
44
44
  - test/autolink_test.rb
45
45
  has_rdoc: true
46
- homepage: http://github.com/tanoku/rinku
46
+ homepage: http://github.com/vmg/rinku
47
47
  licenses: []
48
48
 
49
49
  post_install_message: