Skip to content

Commit

Permalink
actionpack: added missing encoding comments [#4466 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
e2 authored and jeremy committed Apr 25, 2010
1 parent f6e71c6 commit ec7716a
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 39 deletions.
1 change: 1 addition & 0 deletions actionmailer/lib/action_mailer/quoting.rb
@@ -1,3 +1,4 @@
# encoding: us-ascii
module ActionMailer
module Quoting #:nodoc:
# Convert the given text into quoted printable format, with an instruction
Expand Down
@@ -1,3 +1,4 @@
# encoding: us-ascii
# scanner_r.rb
#
#--
Expand Down Expand Up @@ -258,4 +259,4 @@ def scan_error!( msg )
end

end # module TMail
#:startdoc:
#:startdoc:
55 changes: 28 additions & 27 deletions actionmailer/lib/action_mailer/vendor/tmail-1.2.7/tmail/utils.rb
@@ -1,3 +1,4 @@
# encoding: us-ascii
#--
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
#
Expand Down Expand Up @@ -25,29 +26,29 @@
#++

# = TMail - The EMail Swiss Army Knife for Ruby
#
#
# The TMail library provides you with a very complete way to handle and manipulate EMails
# from within your Ruby programs.
#
#
# Used as the backbone for email handling by the Ruby on Rails and Nitro web frameworks as
# well as a bunch of other Ruby apps including the Ruby-Talk mailing list to newsgroup email
# gateway, it is a proven and reliable email handler that won't let you down.
#
#
# Originally created by Minero Aoki, TMail has been recently picked up by Mikel Lindsaar and
# is being actively maintained. Numerous backlogged bug fixes have been applied as well as
# Ruby 1.9 compatibility and a swath of documentation to boot.
#
#
# TMail allows you to treat an email totally as an object and allow you to get on with your
# own programming without having to worry about crafting the perfect email address validation
# parser, or assembling an email from all it's component parts.
#
#
# TMail handles the most complex part of the email - the header. It generates and parses
# headers and provides you with instant access to their innards through simple and logically
# named accessor and setter methods.
#
#
# TMail also provides a wrapper to Net/SMTP as well as Unix Mailbox handling methods to
# directly read emails from your unix mailbox, parse them and use them.
#
#
# Following is the comprehensive list of methods to access TMail::Mail objects. You can also
# check out TMail::Mail, TMail::Address and TMail::Headers for other lists.
module TMail
Expand All @@ -57,9 +58,9 @@ class SyntaxError < StandardError; end

# Provides a new email boundary to separate parts of the email. This is a random
# string based off the current time, so should be fairly unique.
#
#
# For Example:
#
#
# TMail.new_boundary
# #=> "mimepart_47bf656968207_25a8fbb80114"
# TMail.new_boundary
Expand All @@ -70,12 +71,12 @@ def TMail.new_boundary

# Provides a new email message ID. You can use this to generate unique email message
# id's for your email so you can track them.
#
# Optionally takes a fully qualified domain name (default to the current hostname
#
# Optionally takes a fully qualified domain name (default to the current hostname
# returned by Socket.gethostname) that will be appended to the message ID.
#
#
# For Example:
#
#
# email.message_id = TMail.new_message_id
# #=> "<47bf66845380e_25a8fbb80332@baci.local.tmail>"
# email.to_s
Expand All @@ -102,10 +103,10 @@ def TMail.random_tag #:nodoc:
@uniq = 0

#:startdoc:

# Text Utils provides a namespace to define TOKENs, ATOMs, PHRASEs and CONTROL characters that
# are OK per RFC 2822.
#
#
# It also provides methods you can call to determine if a string is safe
module TextUtils

Expand All @@ -118,19 +119,19 @@ module TextUtils
ATOM_UNSAFE = /[#{Regexp.quote aspecial}#{control}#{lwsp}]/n
PHRASE_UNSAFE = /[#{Regexp.quote aspecial}#{control}]/n
TOKEN_UNSAFE = /[#{Regexp.quote tspecial}#{control}#{lwsp}]/n

# Returns true if the string supplied is free from characters not allowed as an ATOM
def atom_safe?( str )
not ATOM_UNSAFE === str
end

# If the string supplied has ATOM unsafe characters in it, will return the string quoted
# If the string supplied has ATOM unsafe characters in it, will return the string quoted
# in double quotes, otherwise returns the string unmodified
def quote_atom( str )
(ATOM_UNSAFE === str) ? dquote(str) : str
end

# If the string supplied has PHRASE unsafe characters in it, will return the string quoted
# If the string supplied has PHRASE unsafe characters in it, will return the string quoted
# in double quotes, otherwise returns the string unmodified
def quote_phrase( str )
(PHRASE_UNSAFE === str) ? dquote(str) : str
Expand All @@ -141,7 +142,7 @@ def token_safe?( str )
not TOKEN_UNSAFE === str
end

# If the string supplied has TOKEN unsafe characters in it, will return the string quoted
# If the string supplied has TOKEN unsafe characters in it, will return the string quoted
# in double quotes, otherwise returns the string unmodified
def quote_token( str )
(TOKEN_UNSAFE === str) ? dquote(str) : str
Expand All @@ -163,7 +164,7 @@ def dquote( str ) #:nodoc:
def unquote( str )
str =~ /^"(.*?)"$/m ? $1 : str
end

# Provides a method to join a domain name by it's parts and also makes it
# ATOM safe by quoting it as needed
def join_domain( arr )
Expand Down Expand Up @@ -256,7 +257,7 @@ def time2str( tm )


MESSAGE_ID = /<[^\@>]+\@[^>]+>/

def message_id?( str )
MESSAGE_ID === str
end
Expand All @@ -267,7 +268,7 @@ def message_id?( str )
def mime_encoded?( str )
MIME_ENCODED === str
end


def decode_params( hash )
new = Hash.new
Expand Down Expand Up @@ -329,7 +330,7 @@ def quote_boundary
end
end
end

# AppleMail generates illegal character contained Content-Type parameter like:
# name==?ISO-2022-JP?B?...=?=
# so quote. (This case is only value fits in one line.)
Expand All @@ -338,11 +339,11 @@ def quote_unquoted_bencode
head, should_quoted, tail = $~.captures
# head: "; name="
# should_quoted: "=?ISO-2022-JP?B?...=?="

head << quote_token(should_quoted) << tail
}
end

# AppleMail generates name=filename attributes in the content type that
# contain spaces. Need to handle this so the TMail Parser can.
def quote_unquoted_name
Expand All @@ -353,9 +354,9 @@ def quote_unquoted_name
head << quote_token(should_quoted) << tail
}
end

#:startdoc:

end

end
@@ -1,3 +1,4 @@
# encoding: us-ascii
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
Expand All @@ -15,12 +16,12 @@
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
Expand Down Expand Up @@ -89,21 +90,21 @@ def feed(aBuf)
@result = {'encoding' => "UTF-16BE", 'confidence' => 1.0}
end
end

@_mGotData = true
if @result['encoding'] and (@result['confidence'] > 0.0)
if @result['encoding'] and (@result['confidence'] > 0.0)
@done = true
return
end

if @_mInputState == EPureAscii
if @_highBitDetector =~ (aBuf)
@_mInputState = EHighbyte
elsif (@_mInputState == EPureAscii) and @_escDetector =~ (@_mLastChar + aBuf)
@_mInputState = EEscAscii
end
end

@_mLastChar = aBuf[-1..-1]
if @_mInputState == EEscAscii
if not @_mEscCharSetProber
Expand All @@ -128,22 +129,22 @@ def feed(aBuf)
end
end
end

end

def close
return if @done
if not @_mGotData
$stderr << "no data received!\n" if $debug
return
end
@done = true
if @_mInputState == EPureAscii

if @_mInputState == EPureAscii
@result = {'encoding' => 'ascii', 'confidence' => 1.0}
return @result
end

if @_mInputState == EHighbyte
confidences = {}
@_mCharSetProbers.each{ |prober| confidences[prober] = prober.get_confidence }
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/controller/assert_select_test.rb
@@ -1,3 +1,4 @@
# encoding: us-ascii
#--
# Copyright (c) 2006 Assaf Arkin (http://labnotes.org)
# Under MIT and/or CC By license.
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/controller/routing_test.rb
@@ -1,3 +1,4 @@
# encoding: us-ascii
require 'abstract_unit'
require 'controller/fake_controllers'
require 'action_controller/routing/route_set'
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/template/text_helper_test.rb
@@ -1,3 +1,4 @@
# encoding: us-ascii
require 'abstract_unit'
require 'testing_sandbox'
begin
Expand Down

0 comments on commit ec7716a

Please sign in to comment.