Troubles with UTF-8 strings and autoconfiguration script mozilla.js

RESOLVED EXPIRED

Status

RESOLVED EXPIRED
15 years ago
13 years ago

People

(Reporter: sasha, Unassigned)

Tracking

Trunk
x86
Windows 2000

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113

this is my autoconfiguration script mozilla.js

-----------------

try {                                                                 
var env_user = getenv("USERNAME");                                    
var env_home = getenv("HOMEPATH");                                    
var env_mozdebug = getenv("MOZILLA_DEBUG");                           
                                                                      
function processLDAPValues (values) {                                 
                                                                      
var uid = getLDAPValue(values, "uid");                                
var sn = getLDAPValue(values, "sn");                                  
var givenName = getLDAPValue(values, "givenName");                    
var mail = getLDAPValue(values, "mail");                              
                                                                      
uid = uid.replace(/^\s+/, "");                                        
sn = sn.replace(/^\s+/, "");                                          
givenName = givenName.replace(/^\s+/, "");                            
mail = mail.replace(/^\s+/, "");                                      
                                                                      
if (env_mozdebug) {                                                   
displayError(                                                         
"AutoConfig",                                                         
"0.06\n" +                                                            
"env_user: [" + env_user + "]\n" +                                    
"sn: [" + sn + "]\n" +                                                
"givenName: [" + givenName + "]\n" +                                  
"uid: [" + uid + "]\n" +                                              
"mail: [" + mail + "\n" );                                            
}                                                                     
/**/                                                                  
                                                                      
lockPref("general.config.vendor", "mozweb32");                        
lockPref("autoadmin.global_config_url", "http://server.my/mozilla.js");
lockPref("browser.bookmarks.added_static_root", true);                
lockPref("browser.cache.disk.capacity", 10240);                       
lockPref("browser.cache.disk.parent_directory", "C:\\TEMP");          
lockPref("browser.downloadmanager.behavior", 1);                      
lockPref("mail.identity.id1.fullName", sn + givenName);

/**/                                                            
                                                                
}                                                               
                                                                
getLDAPAttributes("myldapserver", "ou=People,dc=mynet",
"uid="+env_user, "uid,sn,givenName,mail");                      
                                                                
} catch(e) {                                                    
displayError("lockedPref", e);                                  
}                                                               
----------------------

sn, givenName  -  FirstName & LastName
In mail client I see only some bad symbols.
But when env MOZILLA_DEBUG is set I see "AutoConfig alert" with normal Russian
strings correctly converted from UTF-8.


Reproducible: Always
Steps to Reproduce:
1. IN C:\Program Files\mozilla.org\Mozilla\defaults\pref\all.js
add lines:
pref("general.config.filename", "mozweb32.cfg");
pref("general.config.vendor", "mozweb32");

2. Make file mozweb32.js with lines:
lockPref("general.config.vendor", "mozweb32");
lockPref("autoadmin.global_config_url", http://server.my/mozilla.js");

3. using mozilla.pl
#!/usr/bin/perl
use strict;
use Getopt::Std;
use vars qw/$opt_s/;

getopts("s:");
if(!defined $opt_s) {
die "Missing shift\n";
}

my $buffer;
while(1) {
my $n=sysread STDIN, $buffer, 1;
if($n == 0) {
last;
}
my $byte = unpack("c", $buffer);
$byte += 512 + $opt_s;
$buffer = pack("c", $byte);
syswrite STDOUT, $buffer, 1;
}
-------
get mozweb32.cfg
$ ./mozilla.pl -s 13 < mozweb32.js > mozweb32.cfg

4. place mozweb32.cfg in C:\Program Files\mozilla.org\Mozilla
5. make autoconfiguration script mozilla.js
--------------------
try {                                                                 
var env_user = getenv("USERNAME");                                    
var env_home = getenv("HOMEPATH");                                    
var env_mozdebug = getenv("MOZILLA_DEBUG");                           
                                                                      
function processLDAPValues (values) {                                 
                                                                      
var uid = getLDAPValue(values, "uid");                                
var sn = getLDAPValue(values, "sn");                                  
var givenName = getLDAPValue(values, "givenName");                    
var mail = getLDAPValue(values, "mail");                              
                                                                      
uid = uid.replace(/^\s+/, "");                                        
sn = sn.replace(/^\s+/, "");                                          
givenName = givenName.replace(/^\s+/, "");                            
mail = mail.replace(/^\s+/, "");                                      
                                                                      
if (env_mozdebug) {                                                   
displayError(                                                         
"AutoConfig",                                                         
"0.06\n" +                                                            
"env_user: [" + env_user + "]\n" +                                    
"sn: [" + sn + "]\n" +                                                
"givenName: [" + givenName + "]\n" +                                  
"uid: [" + uid + "]\n" +                                              
"mail: [" + mail + "\n" );                                            
}                                                                     
/**/                                                                  
                                                                      
lockPref("mail.identity.id1.fullName", sn + givenName);

/**/                                                            
                                                                
}                                                               
                                                                
getLDAPAttributes("myldapserver", "ou=People,dc=mynet",
"uid="+env_user, "uid,sn,givenName,mail");                      
                                                                
} catch(e) {                                                    
displayError("lockedPref", e);                                  
}                   
---------------------------


6. place mozilla.js on http://server.my/mozilla.js   
as defined in mozweb32.js mozweb32.cfg

7. Setup in windows variable MOZILLA_DEBUG=true
8. Start Mozilla. See AutoConfig alert.
9. Start MozillaMail. Compose new message. See wrong strings in From: field.
Actual Results:  
1. Correct strings converted from UTF-8 in AutoConfig alert.
2. Bad strings in From: field when composing new mail.

Expected Results:  
Correct strings converted from UTF-8.
Darin, do you know who's nominally in charge of this code?  This sounds like a
bug in getenv()....

Comment 2

15 years ago
Boris: I don't have a clue who owns the pref autoconfig stuff.  cc'ing some folks.

I think this code was owned by bnesse, but he's no longer hacking on mozilla :-(

Comment 3

15 years ago
hmm... yeah, there's no real owner. the code is in
mozilla/extensions/pref/autoconfig

as for getenv(), its just a wrapper around nsIEnvironment, which uses
NS_CopyNativeToUnicode and vice versa to do look up environment values.

looks like the environment variable strings are expected to be in the native
character set, not UTF8

Not sure this is a bug, but is this a change of behavior since pre-1.6? I wonder
what the old nsIProcess did with environment strings...

Comment 4

15 years ago
ah, I just found in an old tree that we used to just do a raw "string" - so the
old behavior was not to convert from any charset, but rather just to inflate the
ASCII out to Unicode.

Why are USERNAME and HOMEPATH UTF8 here? Why aren't they in the system charset?

perhaps autoconfig needs to supply a special version of getenv() that converts
from UTF8? 

Comment 5

15 years ago
I guess I'm the de facto owner of the autoconfig code. However, it sounds like
this could be fixed on user end...is it a problem to set those environment
variable values in the native charset, as Alec suggests? It seems like we should
be consistent in our handling of environment variable values...and it sounds
like we expect them to be in the native charset.
Product: Browser → Seamonkey
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → EXPIRED
You need to log in before you can comment on or make changes to this bug.