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

(-)java/org/apache/tomcat/util/file/Matcher.java (-4 / +26 lines)
Lines 45-52 Link Here
45
     *         file name, or <code>false</code> otherwise.
45
     *         file name, or <code>false</code> otherwise.
46
     */
46
     */
47
    public static boolean matchName(Set<String> patternSet, String fileName) {
47
    public static boolean matchName(Set<String> patternSet, String fileName) {
48
        char[] charArray = fileName.toCharArray();
48
        for (String pattern: patternSet) {
49
        for (String pattern: patternSet) {
49
            if (match(pattern, fileName, true)) {
50
            if (match(pattern, charArray, true)) {
50
                return true;
51
                return true;
51
            }
52
            }
52
        }
53
        }
Lines 61-67 Link Here
61
     *
62
     *
62
     * @param pattern The pattern to match against.
63
     * @param pattern The pattern to match against.
63
     *                Must not be <code>null</code>.
64
     *                Must not be <code>null</code>.
64
     * @param str     The string which must be matched against the pattern.
65
     * @param strArr     The string which must be matched against the pattern.
65
     *                Must not be <code>null</code>.
66
     *                Must not be <code>null</code>.
66
     * @param caseSensitive Whether or not matching should be performed
67
     * @param caseSensitive Whether or not matching should be performed
67
     *                        case sensitively.
68
     *                        case sensitively.
Lines 70-79 Link Here
70
     * @return <code>true</code> if the string matches against the pattern,
71
     * @return <code>true</code> if the string matches against the pattern,
71
     *         or <code>false</code> otherwise.
72
     *         or <code>false</code> otherwise.
72
     */
73
     */
73
    public static boolean match(String pattern, String str,
74
    public static boolean match(String pattern, char[] strArr,
74
                                boolean caseSensitive) {
75
                                boolean caseSensitive) {
75
        char[] patArr = pattern.toCharArray();
76
        char[] patArr = pattern.toCharArray();
76
        char[] strArr = str.toCharArray();
77
        int patIdxStart = 0;
77
        int patIdxStart = 0;
78
        int patIdxEnd = patArr.length - 1;
78
        int patIdxEnd = patArr.length - 1;
79
        int strIdxStart = 0;
79
        int strIdxStart = 0;
Lines 197-202 Link Here
197
        return allStars(patArr, patIdxStart, patIdxEnd);
197
        return allStars(patArr, patIdxStart, patIdxEnd);
198
    }
198
    }
199
199
200
    /**
201
     * Tests whether or not a string matches against a pattern.
202
     * The pattern may contain two special characters:<br>
203
     * '*' means zero or more characters<br>
204
     * '?' means one and only one character
205
     *
206
     * @param pattern The pattern to match against.
207
     *                Must not be <code>null</code>.
208
     * @param str     The string which must be matched against the pattern.
209
     *                Must not be <code>null</code>.
210
     * @param caseSensitive Whether or not matching should be performed
211
     *                        case sensitively.
212
     *
213
     *
214
     * @return <code>true</code> if the string matches against the pattern,
215
     *         or <code>false</code> otherwise.
216
     */
217
    public static boolean match(String pattern, String str,
218
                                boolean caseSensitive) {
219
        return match(pattern, str.toCharArray(), caseSensitive);
220
    }
221
200
    private static boolean allStars(char[] chars, int start, int end) {
222
    private static boolean allStars(char[] chars, int start, int end) {
201
        for (int i = start; i <= end; ++i) {
223
        for (int i = start; i <= end; ++i) {
202
            if (chars[i] != '*') {
224
            if (chars[i] != '*') {

Return to bug 56801