    private static boolean queryContainsDoubleDots(@Nullable Bytes query) {
        if (query == null) {
            return false;
        }

        final int length = query.length;
        boolean lookingForEquals = true;
        byte b0 = 0;
        byte b1 = 0;
        byte b2 = '/';
        for (int i = 0; i < length; i++) {
            byte b3 = query.data[i];

            // Treat the delimiters as `/` so that we can use isSlash() for matching them.
            switch (b3) {
                case '=':
                    // Treat only the first `=` as `/`, e.g.
                    // - `foo=..` and `foo=../` should be flagged.
                    // - `foo=..=` shouldn't be flagged because `..=` is not a relative path.
                    if (lookingForEquals) {
                        lookingForEquals = false;
                        b3 = '/';
                    }
                    break;
                case '&':
                case ';':
                    b3 = '/';
                    lookingForEquals = true;
                    break;
            }

            // Flag if the last four bytes are `/../` or `/..&`
            if (b1 == '.' && b2 == '.' && isSlash(b0) && isSlash(b3)) {
                return true;
            }

            b0 = b1;
            b1 = b2;
            b2 = b3;
        }

        return b1 == '.' && b2 == '.' && isSlash(b0);
    }
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.