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

@tmm1 tmm1 commented on an outdated diff Aug 28, 2012
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
tmm1 added a line comment Aug 28, 2012

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 Oct 9, 2012
Closed

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

@tmm1 tmm1 added a commit that closed this pull request Feb 28, 2013
@tmm1 tmm1 ruby 1.9 compat in smtpserver (fixes #349) c76f6f6
@tmm1 tmm1 closed this in c76f6f6 Feb 28, 2013
@sodabrew sodabrew pushed a commit to sodabrew/eventmachine that referenced this pull request Jan 27, 2015
@ibc ibc in 1.9 String#[] returns character not a character code (copied from e… 5346cdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment