tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tal Dayan" <...@zapta.com>
Subject Patch for bug 330
Date Thu, 18 Jan 2001 20:05:34 GMT
Hi Costin,

Here is our patch for bug 330,  Priority: high, Severity
serious.(http://znutar.cortexity.com/BugRatViewer/ShowReport/330).

Having this patch included the official release of 3.X.X will make Tomcat
usable for us since we could not port our application from WebSphere to
Tomcat 3.2.1 because of this problem.

To apply the patch, all you need to do is to replace the method mangleChar()
in JspCompiler.java with the new code that is included at the end of this
message.

BTW, the file CommandLineCompiler also has a similar mangleChar() method. I
am not sure when this is used but you may want to consolidate the two.

The new encoding has two forms, a short one and a general one. The short one
is used for few common chars such as '_' and '/' and '/'. This encoding maps
into a two char string of the form '_' <l> where <l> is a non hex char (g-z)
(e.g. '_' --> '__', '.' --> '_p' etc). It is a more compact, 'readable'
(e.g. the 'p' in '.'-->'_p' stands for 'period') and is more efficient since
it does not create any object.

The general form is used for the rest of the chars, including Unicode's. It
is of variable length and for most of the common chars (e.g. ASCII) it will
result in a shorter encoding than the one currently used. This encoding uses
the form '_' <hex-rep> 'x' where <hex_rep> is a variable length hex
representation of the numeric value of the char (e.g. "_f4x", "_123ax").

Please review the patch and 'squeeze' it to the next maintenance release of
3.X.X.

Thanks,

Tal



-------- new code ------

    /*
     * Encode special chars using a representation that contains only
     * simple chars that can be used in class names (digits, letters,
     * and '_').
     */
    private static final String mangleChar(char ch) {

        if(ch == File.separatorChar) {
	    ch = '/';
	  }

        /*
         * Use a compact and more readable encoding for few common chars.
         *
         * Note: the char we append after the '_' should not be hex digit
         * to avoid ambiguity with the general encoding we perform for the
rest of
         * the chars.
         */
        if (ch == '_')
        {
          return "__";  // underscore
        }

        if (ch == '-')
        {
          return "_m";  // minus
        }

        if (ch == '.')
        {
          return "_p";  // period
        }

        if (ch == '/')
        {
          return "_s";  // seperator
        }

        /*
         * Encode the general case. We encode the char as follows
         *
         * '_' <hex-rep> 'x'
         *
         * Where h is <hex-rep> is a variable length Hexadecimal
         * represnetation of the numeric value
         * of the char as returned by IntegertoHexString().
         */
        return "_" + Integer.toHexString(ch) + "x";
    }

-------- old code

    private static final String mangleChar(char ch) {

        if(ch == File.separatorChar) {
	    ch = '/';
	}
	String s = Integer.toHexString(ch);
	int nzeros = 5 - s.length();
	char[] result = new char[6];
	result[0] = '_';
	for (int i = 1; i <= nzeros; i++)
	    result[i] = '0';
	for (int i = nzeros+1, j = 0; i < 6; i++, j++)
	    result[i] = s.charAt(j);
	return new String(result);
    }


> -----Original Message-----
> From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
> Sent: Tuesday, January 16, 2001 11:40 AM
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: Proposed name encoding patch
>
>
> It's worth to mention that both JSP encoding and work dir encoding are
> resolved/improved in 3.3 - and the code can be easily ported back /
> reused.
>
> I'll take a look at both patches and try to integrate them into 3.3 also (
> what is not covered already )
>
> --
> Costin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>


Mime
View raw message