View | Details | Raw Unified | Return to bug 40241
Collapse All | Expand All

(-)../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/ResponseIncludeWrapper.java (-4 / +12 lines)
Lines 19-24 Link Here
19
import java.io.IOException;
19
import java.io.IOException;
20
import java.io.OutputStreamWriter;
20
import java.io.OutputStreamWriter;
21
import java.io.PrintWriter;
21
import java.io.PrintWriter;
22
import java.text.ParseException;
23
import java.util.Date;
22
24
23
import javax.servlet.ServletContext;
25
import javax.servlet.ServletContext;
24
import javax.servlet.ServletOutputStream;
26
import javax.servlet.ServletOutputStream;
Lines 207-214 Link Here
207
        String lname = name.toLowerCase();
209
        String lname = name.toLowerCase();
208
        if (lname.equals(LAST_MODIFIED)) {
210
        if (lname.equals(LAST_MODIFIED)) {
209
            try {
211
            try {
210
                lastModified = DateTool.rfc1123Format.parse(value).getTime();
212
                final Date temp = DateTool.rfc1123Format.parse(value);
211
            } catch (Throwable ignore) { }
213
                lastModified = temp.getTime();
214
            } catch(ParseException e) {
215
                // Ignored
216
            }
212
        } else if (lname.equals(CONTENT_TYPE)) {
217
        } else if (lname.equals(CONTENT_TYPE)) {
213
            contentType = value;
218
            contentType = value;
214
        }
219
        }
Lines 227-234 Link Here
227
        String lname = name.toLowerCase();
232
        String lname = name.toLowerCase();
228
        if (lname.equals(LAST_MODIFIED)) {
233
        if (lname.equals(LAST_MODIFIED)) {
229
            try {
234
            try {
230
                lastModified = DateTool.rfc1123Format.parse(value).getTime();
235
                final Date temp = DateTool.rfc1123Format.parse(value);
231
            } catch (Throwable ignore) { }
236
                lastModified = temp.getTime();
237
            } catch(ParseException e) {
238
                // Ignored
239
            }
232
        }
240
        }
233
        else if (lname.equals(CONTENT_TYPE))
241
        else if (lname.equals(CONTENT_TYPE))
234
        {
242
        {
(-)../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/SSIFilter.java (-27 / +53 lines)
Lines 21-26 Link Here
21
import java.io.Reader;
21
import java.io.Reader;
22
import java.io.Writer;
22
import java.io.Writer;
23
import java.util.regex.Matcher;
23
import java.util.regex.Matcher;
24
import java.util.regex.PatternSyntaxException;
24
import java.util.regex.Pattern;
25
import java.util.regex.Pattern;
25
26
26
import javax.servlet.Filter;
27
import javax.servlet.Filter;
Lines 67-107 Link Here
67
    	this.config = config;
68
    	this.config = config;
68
    	
69
    	
69
        String value = null;
70
        String value = null;
70
        try {
71
71
            value = config.getInitParameter("debug");
72
        value = config.getInitParameter("debug");
72
            debug = Integer.parseInt(value);
73
        if (value != null) {
73
        } catch (Throwable t) {
74
            try {
74
            ;
75
                debug = Integer.parseInt(value);
76
            } catch (NumberFormatException e) {
77
                config.getServletContext().log("Invalid format for debug "
78
                    + "initParam; expected an integer, but found \""
79
                    + value + "\".");
80
                debug = 0;
81
            }
75
        }
82
        }
76
        try {
83
77
            value = config.getInitParameter("contentType");
84
        value = config.getInitParameter("contentType");
78
            contentTypeRegEx = Pattern.compile(value);
85
        if (value != null) {
79
        } catch (Throwable t) {
86
            try {
87
                contentTypeRegEx = Pattern.compile(value);
88
            } catch (PatternSyntaxException e) {
89
                contentTypeRegEx = shtmlRegEx;
90
                StringBuffer msg = new StringBuffer();
91
                msg.append("Invalid format for contentType initParam; ");
92
                msg.append("expected regular expression; defaulting to \"");
93
                msg.append(shtmlRegEx.pattern());
94
                msg.append("\".");
95
                config.getServletContext().log(msg.toString());
96
            }
97
        } else {
80
            contentTypeRegEx = shtmlRegEx;
98
            contentTypeRegEx = shtmlRegEx;
81
            StringBuffer msg = new StringBuffer();
99
            StringBuffer msg = new StringBuffer();
82
            msg.append("Invalid format or no contentType initParam; ");
100
            msg.append("No contentType initParam; ");
83
            msg.append("expected regular expression; defaulting to ");
101
            msg.append("expected regular expression; defaulting to \"");
84
            msg.append(shtmlRegEx.pattern());
102
            msg.append(shtmlRegEx.pattern());
103
            msg.append("\".");
85
            config.getServletContext().log(msg.toString());
104
            config.getServletContext().log(msg.toString());
86
        }
105
        }
87
        try {
106
88
            value = config.getInitParameter(
107
        value = config.getInitParameter("isVirtualWebappRelative");
89
                    "isVirtualWebappRelative");
108
        if (value != null) {
90
            isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false;
109
            try {
91
        } catch (Throwable t) {
110
                isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false;
92
            ;
111
            } catch (NumberFormatException e) {
112
                config.getServletContext().log("Invalid format for isVirtualWebappRelative "
113
                    + "initParam; expected an long, but found \""
114
                    + value + "\".");
115
                isVirtualWebappRelative = false;
116
            }
93
        }
117
        }
94
        try {
118
95
            value = config.getInitParameter("expires");
119
        value = config.getInitParameter("expires");
96
            expires = Long.valueOf(value);
120
        if (value != null) {
97
        } catch (NumberFormatException e) {
121
            try {
98
            expires = null;
122
                expires = Long.valueOf(value);
99
            config.getServletContext().log(
123
            } catch (NumberFormatException e) {
100
                "Invalid format for expires initParam; expected integer (seconds)"
124
                expires = null;
101
            );
125
                config.getServletContext().log(
102
        } catch (Throwable t) {
126
                    "Invalid format for expires initParam; expected integer (seconds)"
103
            ;
127
                );
128
            }
104
        }
129
        }
130
105
        if (debug > 0)
131
        if (debug > 0)
106
            config.getServletContext().log(
132
            config.getServletContext().log(
107
                    "SSIFilter.init() SSI invoker started with 'debug'=" + debug);
133
                    "SSIFilter.init() SSI invoker started with 'debug'=" + debug);
(-)../apache-tomcat-5.5.17-src/container/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java (-39 / +55 lines)
Lines 19-24 Link Here
19
import java.io.StringWriter;
19
import java.io.StringWriter;
20
import java.net.URL;
20
import java.net.URL;
21
import java.net.URLConnection;
21
import java.net.URLConnection;
22
import javax.servlet.ServletConfig;
22
import javax.servlet.ServletContext;
23
import javax.servlet.ServletContext;
23
import javax.servlet.ServletException;
24
import javax.servlet.ServletException;
24
import javax.servlet.http.HttpServlet;
25
import javax.servlet.http.HttpServlet;
Lines 58-105 Link Here
58
     *                if an error occurs
59
     *                if an error occurs
59
     */
60
     */
60
    public void init() throws ServletException {
61
    public void init() throws ServletException {
62
        final ServletConfig config = getServletConfig();
61
        String value = null;
63
        String value = null;
62
        try {
64
63
            value = getServletConfig().getInitParameter("debug");
65
        value = config.getInitParameter("debug");
64
            debug = Integer.parseInt(value);
66
        if (value != null) {
65
        } catch (Throwable t) {
67
            try {
66
            ;
68
                debug = Integer.parseInt(value);
67
        }
69
            } catch (NumberFormatException e) {
68
        try {
70
                config.getServletContext().log("Invalid format for debug "
69
            value = getServletConfig().getInitParameter(
71
                    + "initParam; expected an integer, but found \""
70
                    "isVirtualWebappRelative");
72
                    + value + "\".");
71
            isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false;
73
                debug = 0;
72
        } catch (Throwable t) {
74
            }
73
            ;
75
        }
74
        }
76
75
        try {
77
        value = config.getInitParameter("isVirtualWebappRelative");
76
            value = getServletConfig().getInitParameter("expires");
78
        if (value != null) {
77
            expires = Long.valueOf(value);
79
            try {
78
        } catch (NumberFormatException e) {
80
                isVirtualWebappRelative = Integer.parseInt(value) > 0?true:false;
79
            expires = null;
81
            } catch (NumberFormatException e) {
80
            log("Invalid format for expires initParam; expected integer (seconds)");
82
                config.getServletContext().log("Invalid format for isVirtualWebappRelative "
81
        } catch (Throwable t) {
83
                    + "initParam; expected an long, but found \""
82
            ;
84
                    + value + "\".");
83
        }
85
                isVirtualWebappRelative = false;
84
        try {
86
            }
85
            value = getServletConfig().getInitParameter("buffered");
87
        }
86
            buffered = Integer.parseInt(value) > 0?true:false;
88
87
        } catch (Throwable t) {
89
        value = config.getInitParameter("expires");
88
            ;
90
        if (value != null) {
89
        }
91
            try {
90
        try {
92
                expires = new Long(value);
91
            inputEncoding = getServletConfig().getInitParameter("inputEncoding");
93
            } catch (NumberFormatException e) {
92
        } catch (Throwable t) {
94
                config.getServletContext().log("Invalid format for expires "
93
            ;
95
                    + "initParam; expected a long, but found \""
94
        }
96
                    + value + "\".");
95
        try {
97
                expires = null;
96
            value = getServletConfig().getInitParameter("outputEncoding");
97
            if (value != null) {
98
                outputEncoding = value;
99
            }
98
            }
100
        } catch (Throwable t) {
101
            ;
102
        }
99
        }
100
101
        value = config.getInitParameter("buffered");
102
        if (value != null) {
103
            try {
104
                buffered = Integer.parseInt(value) > 0?true:false;
105
            } catch (NumberFormatException e) {
106
                config.getServletContext().log("Invalid format for buffered "
107
                    + "initParam; expected 0 or 1, but found \""
108
                    + value + "\".");
109
                buffered = false;
110
            }
111
        }
112
113
        inputEncoding = getServletConfig().getInitParameter("inputEncoding");
114
        value = getServletConfig().getInitParameter("outputEncoding");
115
        if (value != null) {
116
            outputEncoding = value;
117
        }
118
103
        if (debug > 0)
119
        if (debug > 0)
104
            log("SSIServlet.init() SSI invoker started with 'debug'=" + debug);
120
            log("SSIServlet.init() SSI invoker started with 'debug'=" + debug);
105
    }
121
    }

Return to bug 40241