actionpack 3.0.8.rc4 → 3.0.8

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

Potentially problematic release.


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

@@ -3,7 +3,7 @@ module ActionPack
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 8
6
- PRE = "rc4"
6
+ PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
@@ -115,13 +115,12 @@ module ActionView
115
115
  end
116
116
  options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
117
117
 
118
- text = sanitize(text) unless options[:sanitize] == false
119
- if text.blank? || phrases.blank?
120
- text
121
- else
118
+ if text.present? && phrases.present?
122
119
  match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')
123
- text.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i, options[:highlighter])
124
- end.html_safe
120
+ text = text.to_str.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i, options[:highlighter])
121
+ end
122
+ text = sanitize(text) unless options[:sanitize] == false
123
+ text
125
124
  end
126
125
 
127
126
  # Extracts an excerpt from +text+ that matches the first instance of +phrase+.
@@ -251,14 +250,16 @@ module ActionView
251
250
  # simple_format("Look ma! A class!", :class => 'description')
252
251
  # # => "<p class='description'>Look ma! A class!</p>"
253
252
  def simple_format(text, html_options={}, options={})
254
- text = ''.html_safe if text.nil?
253
+ text = text ? text.to_str : ''
254
+ text = text.dup if text.frozen?
255
255
  start_tag = tag('p', html_options, true)
256
- text = sanitize(text) unless options[:sanitize] == false
257
256
  text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
258
257
  text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
259
258
  text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
260
259
  text.insert 0, start_tag
261
- text.html_safe.safe_concat("</p>")
260
+ text.concat("</p>")
261
+ text = sanitize(text) unless options[:sanitize] == false
262
+ text
262
263
  end
263
264
 
264
265
  # Turns all URLs and e-mail addresses into clickable links. The <tt>:link</tt> option
@@ -477,7 +478,7 @@ module ActionView
477
478
  # is yielded and the result is used as the link text.
478
479
  def auto_link_urls(text, html_options = {}, options = {})
479
480
  link_attributes = html_options.stringify_keys
480
- text.gsub(AUTO_LINK_RE) do
481
+ text.to_str.gsub(AUTO_LINK_RE) do
481
482
  scheme, href = $1, $&
482
483
  punctuation = []
483
484
 
@@ -494,14 +495,11 @@ module ActionView
494
495
  end
495
496
  end
496
497
 
497
- link_text = block_given?? yield(href) : href
498
+ link_text = block_given? ? yield(href) : href
498
499
  href = 'http://' + href unless scheme
499
500
 
500
- unless options[:sanitize] == false
501
- link_text = sanitize(link_text)
502
- href = sanitize(href)
503
- end
504
- content_tag(:a, link_text, link_attributes.merge('href' => href), !!options[:sanitize]) + punctuation.reverse.join('')
501
+ sanitize = options[:sanitize] != false
502
+ content_tag(:a, link_text, link_attributes.merge('href' => href), sanitize) + punctuation.reverse.join('')
505
503
  end
506
504
  end
507
505
  end
@@ -509,18 +507,14 @@ module ActionView
509
507
  # Turns all email addresses into clickable links. If a block is given,
510
508
  # each email is yielded and the result is used as the link text.
511
509
  def auto_link_email_addresses(text, html_options = {}, options = {})
512
- text.gsub(AUTO_EMAIL_RE) do
510
+ text.to_str.gsub(AUTO_EMAIL_RE) do
513
511
  text = $&
514
512
 
515
513
  if auto_linked?($`, $')
516
514
  text.html_safe
517
515
  else
518
- display_text = (block_given?) ? yield(text) : text
519
-
520
- unless options[:sanitize] == false
521
- text = sanitize(text)
522
- display_text = sanitize(display_text) unless text == display_text
523
- end
516
+ display_text = block_given? ? yield(text) : text
517
+ display_text = sanitize(display_text) unless options[:sanitize] == false
524
518
  mail_to text, display_text, html_options
525
519
  end
526
520
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424061
5
- prerelease: 6
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 8
10
- - rc
11
- - 4
12
- version: 3.0.8.rc4
10
+ version: 3.0.8
13
11
  platform: ruby
14
12
  authors:
15
13
  - David Heinemeier Hansson
@@ -17,7 +15,7 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2011-05-31 00:00:00 Z
18
+ date: 2011-06-07 00:00:00 Z
21
19
  dependencies:
22
20
  - !ruby/object:Gem::Dependency
23
21
  name: activesupport
@@ -27,14 +25,12 @@ dependencies:
27
25
  requirements:
28
26
  - - "="
29
27
  - !ruby/object:Gem::Version
30
- hash: 15424061
28
+ hash: 23
31
29
  segments:
32
30
  - 3
33
31
  - 0
34
32
  - 8
35
- - rc
36
- - 4
37
- version: 3.0.8.rc4
33
+ version: 3.0.8
38
34
  type: :runtime
39
35
  version_requirements: *id001
40
36
  - !ruby/object:Gem::Dependency
@@ -45,14 +41,12 @@ dependencies:
45
41
  requirements:
46
42
  - - "="
47
43
  - !ruby/object:Gem::Version
48
- hash: 15424061
44
+ hash: 23
49
45
  segments:
50
46
  - 3
51
47
  - 0
52
48
  - 8
53
- - rc
54
- - 4
55
- version: 3.0.8.rc4
49
+ version: 3.0.8
56
50
  type: :runtime
57
51
  version_requirements: *id002
58
52
  - !ruby/object:Gem::Dependency
@@ -362,14 +356,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
362
356
  required_rubygems_version: !ruby/object:Gem::Requirement
363
357
  none: false
364
358
  requirements:
365
- - - ">"
359
+ - - ">="
366
360
  - !ruby/object:Gem::Version
367
- hash: 25
361
+ hash: 3
368
362
  segments:
369
- - 1
370
- - 3
371
- - 1
372
- version: 1.3.1
363
+ - 0
364
+ version: "0"
373
365
  requirements:
374
366
  - none
375
367
  rubyforge_project: actionpack