`/eval` and `/eval/action` with an `application/x-www-form-urlencoded` body: a NullPointerException or parse errors at positions of a text that was never sent, instead of a message naming the content type

Aperta
#1,906 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java

Direzione di ricerca

Start by locating the /eval and /eval/action request handlers and tracing how they read application/x-www-form-urlencoded bodies and the script parameter. Check the parameter parsing path for values without = as well. Done when a form request without script returns a 400 naming the content type and parameter, and a parameter without a value is handled as an empty NULL value.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Description

The script of an /eval or /eval/action request can be passed as the whole request body with any content type other than application/x-www-form-urlencoded, or as the script parameter. Most HTTP clients send application/x-www-form-urlencoded by default (curl --data, many SDKs), and a caller who posts the raw script that way gets no hint about the cause:

curl -X POST --data "RETURN 'ok';" http://localhost:7651/eval/action
HTTP 500
lsfusion.interop.base.exception.RemoteInternalException Internal Server Error: java.lang.NullPointerException Cannot invoke "String.equals(Object)" because "value" is null

When the text contains =, the body is split at the first = into a parameter name and a value, and the value is compiled as the script, so the reported positions belong to a text the caller never sent:

curl -X POST --data "run() { EXPORT JSON FROM v = 1; }" http://localhost:7651/eval
HTTP 500
[error]:
	UNIQUE2NSNAME:1:1 extraneous input '1' expecting EOF
curl -X POST --data "EXPORT JSON FROM v = 1;" http://localhost:7651/eval/action
HTTP 500
[error]:
	UNIQUE3NSNAME:1:8 mismatched input '1' expecting '}'
	UNIQUE3NSNAME:2:1 missing EOF at '}'

The same requests with -H "Content-Type: text/plain; charset=utf-8" work. Reproduced on 7.0-SNAPSHOT (master, 2026-10-19), on the application server's HTTP port and through the web server alike.

Expected: a 400 response that names the cause — the body was read as form parameters and no script parameter was found (the raw script is sent with another content type or as the script parameter) — or the raw body accepted as the script when the form has no script parameter.

Fix

In the eval endpoints, when the content type is application/x-www-form-urlencoded and there is no script parameter, answer with a 400 whose message names the content type and the script parameter instead of taking the first body parameter as the script. Independently of that, a parameter without a value must not fail the request while it is parsed: treat it as an empty (NULL) value.

Reason

With a form-urlencoded body the parameters are parsed from the body (the documented behaviour) and the first body parameter is taken as the script. A text without = becomes a parameter with no value, and the value is dereferenced while it is parsed as a string. A text with = becomes a name and a value, and only the value reaches the compiler, which then reports positions inside that fragment. Neither path tells the caller that the content type is the problem, and finding it took trial and error.

Lingua principale
Java
Stelle
214
Fork
46
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lsfusion/platform

Tutte le issue di lsfusion/platform

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.