maccesch / cmsplugin-contact

Extendable contact plugin for django-cms with spam protection and i18n
BSD 2-Clause "Simplified" License
71 stars 62 forks source link

remove newlines from subject string #20

Closed airtonix closed 12 years ago

airtonix commented 12 years ago

the subject text created from the subject.txt template needs to have new lines stripped.

splitlines isn't enough.

cmsplugin_contact/cmsplugins.py:100

render_to_string(self.subject_template, {
                'subject': subject,
            }).strip("\n")
mitar commented 12 years ago

Why is not enough?

airtonix commented 12 years ago

well when i test the contact form plugin that uses striplines, and fail silently = false, it complains about having new lines in the subject line.

but when i replace splitlines with strip("\n") the plugin works as expected.

mitar commented 12 years ago

Are you sure you are using version with splitlines?

Which Python/OS you have?

What does Python prompt return for you for:

"foo\nbar\n".splitlines()
airtonix commented 12 years ago

This is on our local ubuntu maverick development server

Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "foo\nbar\n".splitlines()
['foo', 'bar']

This is on our production server

Python 2.7.1 (r271:86832, Dec  1 2010, 06:29:57) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "foo\nbar\n".splitlines()
['foo', 'bar']

I see what you are trying to have me demonstrate and I understand that if the output of this demonstration is as it is, then there should not be problems with the creation of the emails subject line. However there is.

I will run some more tests tomorrow night to see where things are going wrong.

mitar commented 12 years ago

No, I was thinking that maybe some Windows thingy is going on. Like that splitlines splits only on \n, while you have both \r\n in there, so then in the next step things fail at \r.

Please test more.