Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode regexp for finding header field name and slightly updated rakefile #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
begin
# First, we use a few ruby things...
require 'rubygems'
require 'rake/gempackagetask'
require 'rubygems/package_task'
end
require 'rake/rdoctask'
require 'rdoc/task'
require 'rake/testtask'
require 'shellwords'

Expand Down Expand Up @@ -171,7 +171,7 @@ if defined?(Gem)
#
# Use our Gem::Specification to make some package tasks.
#
Rake::GemPackageTask.new(spec) do |pkg|
Gem::PackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rmail/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def get_tokenize
@sym = SYM_DOMAIN_LITERAL
@lexeme = $1.gsub(/(^|[^\\])[\r\n\t ]+/, '\1').gsub(/\\(.)/, '\1')
break
when /\A[\200-\377\w!$%&\'*+\/=?^_\`{\}|~#-]+/nm
when /\A[[:ascii:]\w!$%&\'*+\/=?^_\`{\}|~#-]+/m
# This is just like SYM_ATOM, but includes all characters
# with high bits. This is so we can allow such tokens in
# the display name portion of an address even though it
Expand Down
11 changes: 10 additions & 1 deletion lib/rmail/header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,20 @@ class Header

class Field # :nodoc:
# fixme, document methadology for this (RFC2822)
EXTRACT_FIELD_NAME_RE = /\A([^\x00-\x1f\x7f-\xff :]+):\s*/no

# ASCII version
#EXTRACT_FIELD_NAME_RE = /\A([^\x00-\x1f\x7f-\xff :]+):\s*/o

# universal version
#
# accoring to RFC2822 the header field name can consist of any
# ASCII char between and including 33 and 126.
EXTRACT_FIELD_NAME_RE = /\A(^\w[-\w]+):\s*/o

class << self
def parse(field)
field = field.to_str

if field =~ EXTRACT_FIELD_NAME_RE
[ $1, $'.chomp ]
else
Expand Down