Download & Extend

unnecessary line breaks added to mail variables on every settings form save

Project:Public Bookings
Version:6.x-3.x-dev
Component:Public Bookings
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Issue tags:i18n, internationalization, mail, variables

Issue Summary

Hi tirsales!

I've found that unnecessary line breaks are added to mail variables after saving the settings form.
Now I have around 60 line breaks between lines in all the mail variables.

After some submission of the settings form, I have found that every mail variables' line breaks are multiplicated.

I test my page using linux, so I'm not sure whether this issue is related to linux line breaks.

I get a huge amount of this warning after the submission:
warning: Illegal offset type in isset or empty in ../includes/common.inc on line 912.
warning: Illegal offset type in ../includes/common.inc on line 913.
warning: Illegal offset type in ../includes/common.inc on line 916.
warning: Illegal offset type in isset or empty in ../modules/locale/locale.module on line 347.
.....

I've set all the string variables in the settings.php file to use internationalization, so this may also be the cause:

$conf['i18n_variables'] = array(
  'publicbookings_all_body_footer',
  'publicbookings_all_body_header',
  'publicbookings_all_subject_postfix',
  'publicbookings_all_subject_prefix',
  ...
);

Guilty lines seem to be in the publicbookings.admin.inc:
line 808:

      case 'string':
        $values[$name] = strtr($values[$name],"\r\n","\n");
        $values[$name] = strtr($values[$name],"\n<br>","\n");
        $values[$name] = strtr($values[$name],"<br>\n","\n");
        $values[$name] = strtr($values[$name],"<br>","\n");
        $values[$name] = strtr($values[$name],"\n","\n<br>");
        variable_set($n, $values[$name]);
        break;

Maybe you have already seen this issue and can tell me what can be the cause.

other information:
Drupal 6.19 - PHP 5.3
Views 2.11, CCK 2.8, Date 2.6, i18n 1.7
Bookings API 3.x-dev (10/23/10), Public Bookings 3.x-dev (11/06/10)

Comments

#1

The problem is known ... I haven't figured out (yet) which newlines to use best. (If you simply comment those code-lines out the "many lines"-problem will be fixed - but no newlines will be displayed :/)

'\n' alone won't work on non-NIX systems (the testsystem for this is a Win2k-machine)
'\r\n' will delete some text on some systems (yes.. I didn't expect this one)
'
' will be disregarded in ascii-mailreaders (most of them will regard '\n', thus the '\n
')
etc

:/

#2

That was quick! :)

I checked the _user_mail_text and system_settings_form_submit in drupal core, what are called, when submitting the user settings form, where e-mail text fields are.
I've not found anything what changes line breaks. If it's not necessary in core, may not be necessary here. I comment out the lines you mentioned.
Thanks

#3

Actually those lines of code didn't exist some days ego - but I found the problem that some mailclients did not show "linebreaks" in mails :/
So ... some kind of change is needed, but I haven't found out which one :(