Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

in 1.9 String#[] returns character not a character code #349

Closed
wants to merge 1 commit into from

4 participants

@gregolsen

I've faced a bug when a dot at the beginning of the line was duplicated.
That was caused by this line in SmtpServer#process_data_line:
ln.slice!(0...1) if ln[0] == 46
In 1.8 String#[] indeed returns a character code, but for 1.9 it simply returns a character (String#getbyte can be used instead)
For compatibility with 1.8.7 String#start_with? used instead
Update
String#ord used instead of String#start_with?

@ibc

Very good point and 100% right. Unfortunatelly EM developers will ignore your good pull request (as they do always, this project is just DEAD).

Please, could you send the pull request to EventMachine-LE instead?:

https://github.com/ibc/EventMachine-LE

lib/em/protocols/smtpserver.rb
@@ -541,7 +541,7 @@ def process_data_line ln
@state.delete :data
else
# slice off leading . if any
- ln.slice!(0...1) if ln[0] == 46
+ ln.slice!(0...1) if ln.start_with?('.')
@tmm1 Owner
tmm1 added a note

Use ln[0].ord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@travisbot

This pull request fails (merged 83f9e90 into 9473a1b).

@ibc ibc referenced this pull request in ibc/EventMachine-LE
Closed

Integrate https://github.com/eventmachine/eventmachine/pull/349 #10

@tmm1 tmm1 closed this in c76f6f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/em/protocols/smtpserver.rb
View
2  lib/em/protocols/smtpserver.rb
@@ -541,7 +541,7 @@ def process_data_line ln
@state.delete :data
else
# slice off leading . if any
- ln.slice!(0...1) if ln[0] == 46
+ ln.slice!(0...1) if ln[0] && ln[0].ord == 46
@databuffer << ln
if @databuffer.length > @@parms[:chunksize]
receive_data_chunk @databuffer
Something went wrong with that request. Please try again.