redcarpet 1.11.0 → 1.11.1

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.

data/ext/markdown.c CHANGED
@@ -205,6 +205,7 @@ static size_t
205
205
  is_mail_autolink(char *data, size_t size)
206
206
  {
207
207
  size_t i = 0, nb = 0;
208
+
208
209
  /* address is assumed to be: [-@._a-zA-Z0-9]+ with exactly one '@' */
209
210
  while (i < size && (data[i] == '-' || data[i] == '.'
210
211
  || data[i] == '_' || data[i] == '@'
@@ -239,17 +240,18 @@ tag_length(char *data, size_t size, enum mkd_autolink *autolink)
239
240
  while (i < size && (isalpha(data[i]) || data[i] == '.' || data[i] == '+' || data[i] == '-'))
240
241
  i++;
241
242
 
243
+ if (i > 1 && data[i] == '@') {
244
+ if ((j = is_mail_autolink(data + i, size - i)) != 0) {
245
+ *autolink = MKDA_EMAIL;
246
+ return i + j;
247
+ }
248
+ }
249
+
242
250
  if (i > 2 && data[i] == ':') {
243
251
  *autolink = MKDA_NORMAL;
244
252
  i++;
245
253
  }
246
254
 
247
- /*
248
- * FIXME: check for double slashes after the URI id?
249
- * There are some protocols that don't have them, e.g.
250
- * news:resource
251
- */
252
-
253
255
  /* completing autolink test: no whitespace or ' or " */
254
256
  if (i >= size || i == '>')
255
257
  *autolink = MKDA_NOT_AUTOLINK;
@@ -262,11 +264,8 @@ tag_length(char *data, size_t size, enum mkd_autolink *autolink)
262
264
  if (i >= size) return 0;
263
265
  if (i > j && data[i] == '>') return i + 1;
264
266
  /* one of the forbidden chars has been found */
265
- *autolink = MKDA_NOT_AUTOLINK; }
266
- else if ((j = is_mail_autolink(data + i, size - i)) != 0) {
267
- *autolink = (i == 8)
268
- ? MKDA_EXPLICIT_EMAIL : MKDA_IMPLICIT_EMAIL;
269
- return i + j; }
267
+ *autolink = MKDA_NOT_AUTOLINK;
268
+ }
270
269
 
271
270
  /* looking for sometinhg looking like a tag end */
272
271
  while (i < size && data[i] != '>') i += 1;
data/ext/markdown.h CHANGED
@@ -28,9 +28,8 @@
28
28
  /* mkd_autolink • type of autolink */
29
29
  enum mkd_autolink {
30
30
  MKDA_NOT_AUTOLINK, /* used internally when it is not an autolink*/
31
- MKDA_NORMAL, /* normal http/http/ftp/etc link */
32
- MKDA_EXPLICIT_EMAIL, /* e-mail link with explit mailto: */
33
- MKDA_IMPLICIT_EMAIL /* e-mail link without mailto: */
31
+ MKDA_NORMAL, /* normal http/http/ftp/mailto/etc link */
32
+ MKDA_EMAIL, /* e-mail link without explit mailto: */
34
33
  };
35
34
 
36
35
  enum mkd_extensions {
data/ext/xhtml.c CHANGED
@@ -114,19 +114,27 @@ rndr_autolink(struct buf *ob, struct buf *link, enum mkd_autolink type, void *op
114
114
  if (!link || !link->size)
115
115
  return 0;
116
116
 
117
- if ((options->flags & XHTML_SAFELINK) != 0 && !is_safe_link(link->data, link->size))
117
+ if ((options->flags & XHTML_SAFELINK) != 0 &&
118
+ !is_safe_link(link->data, link->size) &&
119
+ type != MKDA_EMAIL)
118
120
  return 0;
119
121
 
120
122
  BUFPUTSL(ob, "<a href=\"");
121
- if (type == MKDA_IMPLICIT_EMAIL)
123
+ if (type == MKDA_EMAIL)
122
124
  BUFPUTSL(ob, "mailto:");
123
125
  bufput(ob, link->data, link->size);
124
126
  BUFPUTSL(ob, "\">");
125
127
 
126
- if (type == MKDA_EXPLICIT_EMAIL && link->size > 7)
128
+ /*
129
+ * Pretty printing: if we get an email address as
130
+ * an actual URI, e.g. `mailto:foo@bar.com`, we don't
131
+ * want to print the `mailto:` prefix
132
+ */
133
+ if (bufprefix(link, "mailto:") == 0) {
127
134
  lus_attr_escape(ob, link->data + 7, link->size - 7);
128
- else
135
+ } else {
129
136
  lus_attr_escape(ob, link->data, link->size);
137
+ }
130
138
 
131
139
  BUFPUTSL(ob, "</a>");
132
140
 
data/lib/redcarpet.rb CHANGED
@@ -26,7 +26,7 @@
26
26
  # end
27
27
  #
28
28
  class Redcarpet
29
- VERSION = '1.11.0'
29
+ VERSION = '1.11.1'
30
30
 
31
31
  # Original Markdown formatted text.
32
32
  attr_reader :text
data/redcarpet.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'redcarpet'
3
- s.version = '1.11.0'
3
+ s.version = '1.11.1'
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-04-23'
6
+ s.date = '2011-04-25'
7
7
  s.email = 'vicent@github.com'
8
8
  s.homepage = 'http://github.com/tanoku/redcarpet'
9
9
  s.has_rdoc = true
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: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 11
9
- - 0
10
- version: 1.11.0
9
+ - 1
10
+ version: 1.11.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-23 00:00:00 +03:00
19
+ date: 2011-04-25 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies: []
22
22