Comment 75 for bug 233901

Revision history for this message
In , Jehan-procaccia (jehan-procaccia) wrote :

User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.4) Gecko/20031027
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.4) Gecko/20031027

I use autoconfig, which I documented on
http://www.int-evry.fr/mci/user/procacci/netscape/en/mozilla-autoconfig-en.html
and opened a "bug" ID 222973 about lack of doc, I realized that my ldap based
lockPref gets a white space in front of every
variables fetches from ldap.
here's the symptoms:
Return-Path: <" <email address hidden>>
So mail is rejected :-(
indeed in users prefs.js there's:
user_pref("mail.identity.id1.useremail", " <email address hidden>");

Reproducible: Always

Steps to Reproduce:
1.use autoconfig with variables fetched from ldap, cf
http://www.int-evry.fr/mci/user/procacci/netscape/en/mozilla-autoconfig-en.html#htoc10
2.typical javascript code in my autoconfig file: var ldapmail = getLDAPValue (
values ,"mail" );
3.

Actual Results:
here's the reulted user preference:
user_pref("mail.identity.id1.useremail", " <email address hidden>");
note the unwanted "white space" in from of the email address

Expected Results:
not inserted the white space:
user_pref("mail.identity.id1.useremail", "<email address hidden>");

I found a workaround, cf bug 206294: , incrementing by 1 start_pos in function
getLDAPValue from autoconfig/preffcalls.js, see below bettwen //start //end:

function getLDAPValue(str, key) {

    try {
        if (str == null || key == null)
            return null;

        var search_key = "\n" + key + "=";

        displayError("Jehan getLDAPValue:\nsearch_key:"+search_key+"\nstr"+str);

        var start_pos = str.indexOf(search_key);
        if (start_pos == -1)
            return null;

        start_pos += search_key.length;
//start
        start_pos +=1;
//end
        var end_pos = str.indexOf("\n", start_pos);
        if (end_pos == -1)
            end_pos = str.length;

        var attrib = str.substring(start_pos, end_pos);
        displayError("Jehan
getLDAPValue:\nattrib:"+attrib+"\nstart_pos:"+start_pos+"\nend_pos:"+end_pos);

        return str.substring(start_pos, end_pos);

    }
    catch(e) {
        displayError("getLDAPValue", e);
    }
}