Last Comment Bug 229271 - unwanted "white space" in function getLDAPValue from autoconfig/prefcalls.js
: unwanted "white space" in function getLDAPValue from autoconfig/prefcalls.js
Status: RESOLVED FIXED
: fixed1.7.5
Product: Core
Classification: Components
Component: Preferences: Backend (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: timeless
:
Mentors:
http://bonsai.mozilla.org/cvsblame.cg...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-12-23 08:54 PST by Jehan Procaccia
Modified: 2005-07-20 09:55 PDT (History)
9 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
drop unwanted whitespace (989 bytes, patch)
2004-07-07 23:47 PDT, timeless
alecf: review+
dmose: superreview+
mozilla: approval1.7.5+
asa: approval1.8a2+
Details | Diff | Review

Description Jehan Procaccia 2003-12-23 08:54:07 PST
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: <" jehan.procaccia"@int-evry.fr>
So mail is rejected :-(
indeed in users prefs.js there's:
user_pref("mail.identity.id1.useremail", " Jehan.Procaccia@int-evry.fr");

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", " Jehan.Procaccia@int-evry.fr");
note the unwanted "white space" in from of the email address

Expected Results:  
not inserted the white space:
user_pref("mail.identity.id1.useremail", "Jehan.Procaccia@int-evry.fr");

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);
    }
}
Comment 1 simon annear 2004-07-07 19:26:33 PDT
I have confirmed that this bug exists in Mozilla/5.0 (Windows; U; Windows NT
5.0; en-US; rv:1.7) Gecko/20040514

The resolution based on Jehan's workaround is just to add a single line to the
prefcalls.js file which increments the start_pos value by 1

diff prefcalls.js.orig prefcalls.js.new
181a182
     start_pos += 1;



Comment 2 timeless 2004-07-07 23:45:04 PDT
attachment 57051 [details] [diff] [review] <bug 89137 comment 35> introduced the space.

I can't see any reason for it.
Comment 3 timeless 2004-07-07 23:47:06 PDT
Created attachment 152586 [details] [diff] [review]
drop unwanted whitespace
Comment 4 Jehan Procaccia 2004-07-08 01:57:11 PDT
Very good, I'am glad you finally corrected this bug .
However, in which release can I expect this patch beeing applied ?
Thanks .
Comment 5 Alec Flett 2004-07-08 09:06:33 PDT
Comment on attachment 152586 [details] [diff] [review]
drop unwanted whitespace

r=alecf
Comment 6 Dan Mosedale (:dmose) 2004-07-08 10:41:41 PDT
Comment on attachment 152586 [details] [diff] [review]
drop unwanted whitespace

sr=dmose
Comment 7 Asa Dotzler [:asa] 2004-07-09 12:37:00 PDT
Comment on attachment 152586 [details] [diff] [review]
drop unwanted whitespace

a=asa (on behalf of drivers) for checkin to 1.8a2
Comment 8 timeless 2004-07-18 07:51:02 PDT
mozilla/extensions/pref/autoconfig/src/nsLDAPSyncQuery.cpp 	1.11
Comment 9 Mats Larsson 2004-11-08 04:48:28 PST
Any chance this will be fixed in 1.7.x?
Comment 10 timeless 2004-11-09 10:52:36 PST
Mats.Larsson@ericsson.com: given that it's sat here w/ the approval1.7.x? flag
for four months, i doubt it.
Comment 11 Mike Kaply [:mkaply] (Out June 27-July 5) 2004-11-09 10:54:28 PST
Comment on attachment 152586 [details] [diff] [review]
drop unwanted whitespace

Sorry about that.
Comment 12 timeless 2004-11-09 11:17:23 PST
mozilla/extensions/pref/autoconfig/src/nsLDAPSyncQuery.cpp 	1.7.2.1
Comment 13 Jehan Procaccia 2005-04-05 07:42:54 PDT
Indeed , since my fedora Core 2 system recently updated from mozilla 1.7.3 to
mozilla-1.7.6-1.2.5, now there's no need to hack prefcalls.js with "start_pos
+=1;", in fact if I continue with this hack I lose (as expected) the first
letter of the email address (fetch from ldap)  .

Thanks for the correction ! this bug is really  solve to me now :-)  .

By the way (out of subject !) ... is autoconfig still working with 
firefox/thunderbird (I desperatly hope so !) .

Note You need to log in before you can comment on or make changes to this bug.