Dynmap-Forge/Fabric

Dynmap-Forge/Fabric

888k Downloads

String index out of range: 6 error, causes the dynmap to stop updating.

MrPowerGamerBR opened this issue ยท 1 comments

commented

Issue Description: Randomly Dynmap throws an error, causing the map to stop update/players frozen in the map.

The only thing that I know is that, after this error happens, dynmap stops working (you can still see the map but it won't update, players are also frozen in the map)

[X] I have looked at all other issues and this is not a duplicate
[ ] I have been able to replicate this

If I had to guess I think it is related to strings with latin characters (my player base is from Brazil), so when dynmap tries to strip colors from the string (?), it throws an error.

If I had to guess by looking at the source code

    // Strip color - assume we're returning safe html text
    public static String stripColor(String s) {
        s = DynmapChatColor.stripColor(s);    /* Strip standard color encoding */
        /* Handle Essentials nickname encoding too */
        int idx = 0;
        while((idx = s.indexOf('&', idx)) >= 0) {
            char c = s.charAt(idx+1);   /* Get next character */
            if(c == '&') {  /* Another ampersand */
                s = s.substring(0, idx) + s.substring(idx+1);
            }
            else {
                s = s.substring(0, idx) + s.substring(idx+2);
            }
            idx++;
        }
        // Apply sanitize policy before returning
        return sanitizeHTML(s);
    }

I didn't test, but what would happen if dynmap tried to strip color from a "hello&" string? Wouldn't it cause a IndexOutOfBoundsException since it is always trying to get the idx + 1 character?

commented

I didn't test, but what would happen if dynmap tried to strip color from a "hello&" string? Wouldn't it cause a IndexOutOfBoundsException since it is always trying to get the idx + 1 character?

I can confirm this by the way