Path: utzoo!attcan!uunet!mcsun!ukc!stl!andrew From: andrew@stl.stc.co.uk (Andrew Macpherson) Newsgroups: comp.mail.elm Subject: Re: configurable delimiters needed in aliases file for x.400 addresses Message-ID: <3221@stl.stc.co.uk> Date: 18 Jul 90 22:50:26 GMT References: <1585@merlin.bhpmrl.oz.au> Sender: news@stl.stc.co.uk Reply-To: "Andrew Macpherson" Organization: STC Technology Limited, London Road, Harlow, Essex, UK Lines: 166 In article <1585@merlin.bhpmrl.oz.au> ianh@bhpmrl.oz.au (Ian Hoyle) writes: | It would be nice to have user configurable delimiters used for aliases. This | is because embedded ='s in x.400 addresses break the alias expansion | producing incorrect addresses. eg | | bhp = bhp keylink = /C=AU/ADMD=TELEMEMO/O=BHP/G=BHP/S=MELBOURNE/@murtoa | | will produce a To: field of | | To: MELBOURNE/@murtoa (bhp keylink = /C=AU/ADMD=TELEMEMO/O=BHP/G=BHP/S) | | which is clearly wrong. Instead of being forced to use ='s why not let the | delimiter be set as an option, say a '#'. | Actually all that is needed is to correctly skip the comment field. It is extremely dissapointing to have one's fixes ignored, but I have supplied Syd with the fix to filter for this over half a year ago. When one gets an acknowledgement, a promise that ones offering will be looked at, and then nothing happens one simply says `to hell with it, someone else will complain eventually'. Anyway, here you go. This is for elm2.2 *** /usr/net/src/elm2.2/utils/newalias.c Sat Feb 24 11:47:50 1990 --- /usr/net/src/elm2.2/utils/newalias.oc Sat Feb 24 11:47:50 1990 *************** *** 223,230 **** char aliases[LONG_STRING], address[LONG_STRING]; char comment[LONG_STRING]; ! char *ch; ! int first, last, i = 0; remove_all(' ', TAB, buffer); --- 223,229 ---- char aliases[LONG_STRING], address[LONG_STRING]; char comment[LONG_STRING]; ! int first, last, i = 0, j = 0; remove_all(' ', TAB, buffer); *************** *** 232,252 **** aliases[i] = buffer[i]; aliases[i] = '\0'; ! first = ++i; - if ((ch = index(&buffer[first], '=')) != NULL) - last = (ch - buffer) + 1; - else - last = first; - - strcpy(address, &buffer[last]); - comment[0] = '\0'; /* default to nothing at all... */ ! if (first < last) { extract_comment(comment, buffer, first, last); } add_to_table(data, aliases, comment, address, table, size); } --- 231,248 ---- aliases[i] = buffer[i]; aliases[i] = '\0'; ! for (i=strlen(buffer)-1; buffer[i] != '=' && i > 0; i--) ! address[j++] = buffer[i]; ! address[j] = '\0'; comment[0] = '\0'; /* default to nothing at all... */ ! if ((first=strlen(aliases)+1) < (last=(strlen(buffer) - j))) { extract_comment(comment, buffer, first, last); } + reverse(address); + add_to_table(data, aliases, comment, address, table, size); } *************** *** 357,403 **** Hacked (literally) to NOT remove ANY characters from within the equals fields. This will only be used if the line contains TWO equalss (and comments with equalss in them are the kiss of death!) - Since we may need '=' in an RFC 987 address, now really look for - the first two equals, Guaranteed to blow up if there are equals - in the comment. - - Also track Quotes, to allow for horrors such as /ADMD="Gold 400" - (Genuine I'm afraid) even though this will almost cerrtainly - blow up elsewhere. NB Quotes must ballance! */ char buffer[LONG_STRING]; ! char *ch; ! register int i = 0, j = 0, first_equals = -1, second_equals = -1; ! register int quoted = 0; for (i = 0; string[i] != '\0' && i < LONG_STRING; i++) { if (string[i] != c1 && string[i] != c2) buffer[j++] = string[i]; - if (string[i] == '"' && (i == 0 || string[i-1] != '\\')) - quoted = !quoted; - - if (i == second_equals && quoted) { - printf("Can't cope with = inside comment\n>>%s<<\n", - string); - quoted = 0; - } - if (first_equals == -1 && string[i] == '=') { first_equals = i; ! if ((ch = index(&string[first_equals + 1], '=')) != NULL) ! second_equals = (ch - string); ! else ! second_equals = first_equals; } ! else if (quoted || (i > first_equals && i < second_equals)) if (string[i] == c1 || string[i] == c2) buffer[j++] = string[i]; } - if (quoted) - printf("Warning: unbalanced quotes '\"'\n>>%s<<\n", string); buffer[j] = '\0'; strcpy(string, buffer); } --- 353,377 ---- Hacked (literally) to NOT remove ANY characters from within the equals fields. This will only be used if the line contains TWO equalss (and comments with equalss in them are the kiss of death!) */ char buffer[LONG_STRING]; ! register int i = 0, j = 0, first_equals = -1, last_equals = -1; for (i = 0; string[i] != '\0' && i < LONG_STRING; i++) { if (string[i] != c1 && string[i] != c2) buffer[j++] = string[i]; if (first_equals == -1 && string[i] == '=') { first_equals = i; ! for (last_equals=strlen(string);string[last_equals] != '='; ! last_equals--) ; } ! else if (i > first_equals && i < last_equals) if (string[i] == c1 || string[i] == c2) buffer[j++] = string[i]; } buffer[j] = '\0'; strcpy(string, buffer); } -- Andrew Macpherson | Drug Trafficing in Malaya: PSI%234237100122::andrew | Think of it as evolution in action! Andrew.Macpherson@stl.stc.co.uk