Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undertow eat 400 error #552

Closed
xingzheone opened this issue Oct 31, 2021 · 1 comment
Closed

undertow eat 400 error #552

xingzheone opened this issue Oct 31, 2021 · 1 comment

Comments

@xingzheone
Copy link

when http://localhost:3000/some?jn={zhege:12,name:%22feng%22}
private static final String BAD_REQUEST = "HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\nConnection: close\r\n\r\n";

static {
        try {
            HTTP = "HTTP/1.".getBytes("ASCII");
            HTTP_LENGTH = HTTP.length;
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        for(int i = 0; i < 256; ++i) {
            if(i < 32 || i > 126) {
                ALLOWED_TARGET_CHARACTER[i] = false;
            } else {
                switch ((char)i) {
                    case '\"':
                    case '#':
                    case '<':
                    case '>':
                    case '\\':
                    case '^':
                    case '`':
                    case '{':
                    case '|':
                    case '}':
                        ALLOWED_TARGET_CHARACTER[i] = false;
                        break;
                    default:
                        ALLOWED_TARGET_CHARACTER[i] = true;
                }
            }
        }
    }

  public static boolean isTargetCharacterAllowed(char c) {
        return ALLOWED_TARGET_CHARACTER[c];
    }
public static final Option<Boolean> ALLOW_UNESCAPED_CHARACTERS_IN_URL = Option.simple(UndertowOptions.class,"ALLOW_UNESCAPED_CHARACTERS_IN_URL", Boolean.class);

HttpRequestParser.java
if(!allowUnescapedCharactersInUrl && !ALLOWED_TARGET_CHARACTER[next]) {
throw new BadRequestException(UndertowMessages.MESSAGES.invalidCharacterInRequestTarget(next));
}

@yogthos
Copy link
Member

yogthos commented Nov 1, 2021

linking the issue here luminus-framework/ring-undertow-adapter#20

this may need to be fixed upstream in undertow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants