Username which contains the "@" char ...
Chris, Greetings for the New Year. Monday 08 August 2005 you mentioned, " ... Username which contains the "@" char I've torn my guts out patching n-o ..." pe.RFC2396.Mod is now available. HyperDocTools.Fetch "http://carnot.pathology.ubc.ca/pe.RFC2396.Mod" => pe.RFC2396.Mod ~ It is based upon parts of HyperDocs.Mod. I've changed ESC and UnESC in consideration of these factors. 1. HyperDocs.ESC works "in place". NetSystem must be able to keep distinct source and target strings to avoid UnESCing and ESCing whenever Show is invoked. That is why I needed to ask a few months ago how to detect the identity of two variables. 2. I want to check for array overflow. This can happen when ESC adds characters. Also can happen when the target array is smaller than the source. 3. I want to check that a parameter is legitimate; ie. that 0X terminates the string. 4. HyperDocs.ESC and UnESC shift downstream characters for each escapable character found. Another way requires one shift at most; see ESC1 and UnESC. 5. With a temporary variable, shifting is avoided and the code is shorter; see ESC2. Nevertheless ESC1 seems better than ESC2. Several test cases are at the end of the file. If you can find another which breaks my implementation please let me know. Jan commented, "I prefer longer code over C style functions." My programming experience is too limited. All criticisms are welcome and I'll try to make appropriate improvements. Of course, RFC2396.Mod is no practical help until used in NetSystem.Mod. I'll work on that when time is available. While working here we can reflect that escaping could have been unnecessary with another syntax of the URI. Regards, ... Peter E. Desktops.OpenDoc http://carnot.pathology.ubc.ca/
Op Thursday 05 January 2006 21:49 schreef shark@gulfnet.sd64.bc.ca:
"http://carnot.pathology.ubc.ca/pe.RFC2396.Mod" => pe.RFC2396.Mod ~
Some comments from a nitpicker, which might work and perhaps not. My experience with Oberon is yet minimal. I do mostly Modula-2. ------------------------------------------- PROCEDURE HexVal(ch: CHAR): INTEGER; BEGIN IF (ch >= "0") & (ch <= "9") THEN RETURN ORD(ch)-ORD("0") ELSIF (ch >= "A") & (ch <= "F") THEN RETURN ORD(ch)-ORD("A")+10 ELSIF (ch >= "a") & (ch <= "f") THEN RETURN ORD(ch)-ORD("a")+10 END END HexVal; mine: PROCEDURE HexVal(ch: CHAR): INTEGER; BEGIN ch := CAP (ch); IF (ch >= "0") & (ch <= "9") THEN RETURN ORD(ch)-ORD("0") ELSIF (ch >= "A") & (ch <= "F") THEN RETURN ORD(ch)-ORD("A")+10 END END HexVal; ------------------------------------------- PROCEDURE LogChars(s: ARRAY OF CHAR); VAR i: LONGINT; BEGIN i := 0; WHILE ~((i = LEN(s)) OR (s[i] = 0X)) DO Texts.Write(W, s[i]); INC(i) END; END LogChars; mine: PROCEDURE LogChars(s: ARRAY OF CHAR); VAR i: LONGINT; BEGIN i := 0; WHILE (i < LEN(s)) AND (s[i] # 0X) DO Texts.Write(W, s[i]); INC(i) END; END LogChars; Complex negations are not easy to read. ------------------------------------------- PROCEDURE HexDigit(i: INTEGER): CHAR; BEGIN IF i < 10 THEN RETURN CHR(i+ORD("0")) ELSE RETURN CHR(i-10+ORD("A")) END END HexDigit; mine: PROCEDURE HexDigit(i: INTEGER): CHAR; BEGIN RETURN HexDigs [i]; END HexDigit; Where HexDigs = "0123456789ABCDEF" ------------------------------------------- ELSIF (source[is] = "%") & Strings.IsHexDigit(source[is+1]) & Strings.IsHexDigit(source[is+2]) THEN INC(is); INC(is) (* ELSE literal character *) mine: ELSIF (source[is] = "%") & Strings.IsHexDigit(source[is+1]) & Strings.IsHexDigit(source[is+2]) THEN INC(is, 2) (* ELSE literal character *) Question: what happens when someone enters '%GG' in the string? The condition will be false, so the conversion will not be carried out. But also the indexes are not incremented. Hence the '%' is stripped but the 'GG' part remains in the string. Is this the meaning? ------------------------------------------- PROCEDURE RequiresEscape(ch:CHAR):BOOLEAN; BEGIN IF (ch = 0X) THEN RETURN(FALSE) ELSIF (ch <= 020X) OR (ch = "+") OR (ch = "&") OR (ch = "=") OR (ch = "?") OR (ch = "%") OR (ch = "$") OR (ch = ";") OR (ch = "#") OR (ch = ":") OR (ch = special) THEN RETURN(TRUE) ELSE RETURN(FALSE) END END RequiresEscape; mine: TYPE SpecalChar = ('+', '&', '=', '?', '%', '$', ';', '#', ':'); SpecialCharSet = SET OF SpecialChar; PROCEDURE RequiresEscape(ch:CHAR):BOOLEAN; BEGIN IF (ch = 0X) THEN RETURN(FALSE) ELSIF (ch <= 020X) OR (ch IN SpecialCharSet OR (ch = special) THEN RETURN(TRUE) ELSE RETURN(FALSE) END END RequiresEscape; ------------------------------------------- ELSIF RequiresEscape(source[is]) THEN INC(it); INC(it); INC(it); INC(is) mine: ELSIF RequiresEscape(source[is]) THEN INC(it, 3); INC(is) If you forget one INC (it) you're in for a surprise. ------------------------------------------- IF it < tlen THEN (* The escaped version will fit into the target array. *) ELSE INC(errors); LogString("RFC2396.ESC.ESC1: Escaped version of string "); LogLn; Log(22X); LogString(source); Log(22X); LogLn; LogString("will be too long for the array. Not escaping."); LogLn; RETURN END; THEN what? If only the ELSE is needed, why not invert the Boolean expression? ------------------------------------------- I think you are overcomplicating things with the backward fill/conversion cycle. It doesn't really matter if you do a normal fill/conversion. Your method is slightly easier to code due to the filling with HexDigits. ------------------------------------------- -- Met vriendelijke groeten Jan Verhoeven http://fruttenboel.verhoeven272.nl
Op Thursday 05 January 2006 23:26 I wrote:
-------------------------------------------
I think you are overcomplicating things with the backward fill/conversion cycle. It doesn't really matter if you do a normal fill/conversion. Your method is slightly easier to code due to the filling with HexDigits.
-------------------------------------------
What will happen to the string, if the tail catches up with the head? If the string is 12 tokens long, the tail starts at index 11. Suppose the payload of the string is 9 tokens long and has two SpecialChar's in it. Then the tail will end up in front of the head. -- Met vriendelijke groeten Jan Verhoeven http://fruttenboel.verhoeven272.nl
--- shark@gulfnet.sd64.bc.ca wrote:
Chris,
Greetings for the New Year.
Monday 08 August 2005 you mentioned, " ... Username which contains the "@" char I've torn my guts out patching n-o ..."
pe.RFC2396.Mod is now available. HyperDocTools.Fetch "http://carnot.pathology.ubc.ca/pe.RFC2396.Mod" => pe.RFC2396.Mod ~
Hey Peter. I've been down this road before. The problem is (as I understand it) that the PPP RFC has no provision for escaping charecters. So while this approach is fine for RFC 2396 (the univeral resource identifier) it doesn't help for RFC 1661 (the PPP RFC). At this point I think the best thing is for the PPP code to have an option to set its username and password independent of the NetSystem module. Or, perhaps NetSystem could be changed to "unescape" special charecters once the username and password tokens are parsed. Personal note, I still think it's goofy to have @ in a username. Yes, I've seen ISPs do it now. That doesn't make it any less goofy. But hey, what do I know? Regards, John M. Drake __________________________________________ Yahoo! DSL Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com
participants (3)
-
jan verhoeven -
John Drake -
shark@gulfnet.sd64.bc.ca