Pulled in some fixes from Ruby core
M src/rexml/attribute.rb +2 -0
@@ 17,6 17,8 @@ module REXML
 		attr_writer :normalized	
 		PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um
 
+    NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um
+
 		# Constructor.
     # FIXME: The parser doesn't catch illegal characters in attributes
     #

          
M src/rexml/encodings/SHIFT-JIS.rb +2 -2
@@ 13,8 13,8 @@ module REXML
     rescue LoadError
       require 'nkf'
 
-      SJISTOU8 = '-Swm0'
-      U8TOSJIS = '-Wsm0'
+      SJISTOU8 = '-Swm0x'
+      U8TOSJIS = '-Wsm0x'
 
       def decode_sjis(str)
         NKF.nkf(SJISTOU8, str)

          
M src/rexml/parsers/baseparser.rb +1 -1
@@ 482,7 482,7 @@ module REXML
         rv.gsub!( /\r\n?/, "\n" )
         matches = rv.scan( REFERENCE_RE )
         return rv if matches.size == 0
-        rv.gsub!( /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {|m|
+        rv.gsub!( /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
           m=$1
           m = "0#{m}" if m[0] == ?x
           [Integer(m)].pack('U*')

          
M src/rexml/quickpath.rb +3 -6
@@ 170,15 170,12 @@ module REXML
 			rest = path[ind+1..-1]
 
 			# have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c'
-			predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u ) { 
-				"#$1 #$2 #$3 and #$3 #$4 #$5"
-			}
+			predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u,
+				'\1 \2 \3 and \3 \4 \5' )
 			# Let's do some Ruby trickery to avoid some work:
 			predicate.gsub!( /&/u, "&&" )
 			predicate.gsub!( /=/u, "==" )
-			predicate.gsub!( /@(\w[-\w.]*)/u ) {
-				"attribute(\"#$1\")" 
-			}
+			predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' ) 
 			predicate.gsub!( /\bmod\b/u, "%" )
 			predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
 				fname = $1

          
M src/rexml/rexml.rb +1 -1
@@ 24,7 24,7 @@ module REXML
   COPYRIGHT = "Copyright © 2001-2008 Sean Russell <ser@germane-software.com>"
   DATE = "2008/100"
   VERSION = "3.1.7.4"
-  REVISION = "$Revision$".gsub(/\$Revision:|\$/,'').strip
+  REVISION = "$Revision: 1312 $".gsub(/\$Revision:|\$/,'').strip
 
   Copyright = COPYRIGHT
   Version = VERSION

          
M src/rexml/text.rb +5 -4
@@ 50,7 50,7 @@ module REXML
          |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
          | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
          |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
-       )*$/x; 
+       )*$/nx; 
     end
 
     # Constructor

          
@@ 139,7 139,7 @@ module REXML
             end
           end
         else
-          string.scan(/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/) do |c|
+          string.scan(/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/n) do |c|
             case c.unpack('U')
             when *VALID_CHAR
             else

          
@@ 345,7 345,7 @@ module REXML
         copy.gsub!( SETUTITSBUS[2], SLAICEPS[2] )
         copy.gsub!( SETUTITSBUS[3], SLAICEPS[3] )
         copy.gsub!( SETUTITSBUS[4], SLAICEPS[4] )
-        copy.gsub!( /&#0*((?:\d+)|(?:x[a-f0-9]+));/ ) {|m|
+        copy.gsub!( /&#0*((?:\d+)|(?:x[a-f0-9]+));/ ) {
           m=$1
           #m='0' if m==''
           m = "0#{m}" if m[0] == ?x

          
@@ 380,7 380,8 @@ module REXML
 
     # Unescapes all possible entities
     def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
-      string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) { |ref|
+      string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) {
+        ref = $&
         if ref[1] == ?#
           if ref[2] == ?x
             [ref[3...-1].to_i(16)].pack('U*')