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

(-)java/org/apache/catalina/valves/rewrite/Substitution.java (-4 / +8 lines)
Lines 40-53 Link Here
40
        public int n;
40
        public int n;
41
        @Override
41
        @Override
42
        public String evaluate(Matcher rule, Matcher cond, Resolver resolver) {
42
        public String evaluate(Matcher rule, Matcher cond, Resolver resolver) {
43
            String result = rule.group(n);
44
            if (result == null) {
45
                result = "";
46
            }
43
            if (escapeBackReferences) {
47
            if (escapeBackReferences) {
44
                // Note: This should be consistent with the way httpd behaves.
48
                // Note: This should be consistent with the way httpd behaves.
45
                //       We might want to consider providing a dedicated decoder
49
                //       We might want to consider providing a dedicated decoder
46
                //       with an option to add additional safe characters to
50
                //       with an option to add additional safe characters to
47
                //       provide users with more flexibility
51
                //       provide users with more flexibility
48
                return RewriteValve.ENCODER.encode(rule.group(n), resolver.getUriEncoding());
52
                return RewriteValve.ENCODER.encode(result, resolver.getUriEncoding());
49
            } else {
53
            } else {
50
                return rule.group(n);
54
                return result;
51
            }
55
            }
52
        }
56
        }
53
    }
57
    }
Lines 56-62 Link Here
56
        public int n;
60
        public int n;
57
        @Override
61
        @Override
58
        public String evaluate(Matcher rule, Matcher cond, Resolver resolver) {
62
        public String evaluate(Matcher rule, Matcher cond, Resolver resolver) {
59
            return cond.group(n);
63
            return (cond.group(n) == null ? "" : cond.group(n));
60
        }
64
        }
61
    }
65
    }
62
66
Lines 95-101 Link Here
95
    public class MapElement extends SubstitutionElement {
99
    public class MapElement extends SubstitutionElement {
96
        public RewriteMap map = null;
100
        public RewriteMap map = null;
97
        public String key;
101
        public String key;
98
        public String defaultValue = null;
102
        public String defaultValue = "";
99
        public int n;
103
        public int n;
100
        @Override
104
        @Override
101
        public String evaluate(Matcher rule, Matcher cond, Resolver resolver) {
105
        public String evaluate(Matcher rule, Matcher cond, Resolver resolver) {

Return to bug 60413