Skip to content

Commit 187e8d4

Browse files
[FIX] RESTXQ, Uploading files: ignore empty uploads forms
1 parent ef4f7c9 commit 187e8d4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

basex-api/src/main/java/org/basex/http/restxq/RestXqFunction.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,15 @@ private RestXqError error(final Value value, final QNm name) throws QueryExcepti
519519
* @throws IOException I/O exception
520520
* @throws QueryException query exception
521521
*/
522-
private void addMultipart(final IOContent body, final Map<String, Value> pars,
523-
final String ext) throws IOException, QueryException {
522+
private void addMultipart(final IOContent body, final Map<String, Value> pars, final String ext)
523+
throws IOException, QueryException {
524524

525525
final MainOptions opts = context.context.options;
526526
final HTTPPayload hp = new HTTPPayload(body.inputStream(), false, null, opts);
527527
final HashMap<String, Value> map = hp.multiForm(ext);
528528
for(final Map.Entry<String, Value> entry : map.entrySet()) {
529-
pars.put(entry.getKey(), entry.getValue());
529+
final String key = entry.getKey();
530+
if(!key.isEmpty()) pars.put(key, entry.getValue());
530531
}
531532
}
532533

@@ -539,9 +540,7 @@ private void addMultipart(final IOContent body, final Map<String, Value> pars,
539540
* @return cache
540541
* @throws IOException I/O exception
541542
*/
542-
private static IOContent cache(final HTTPContext http, final IOContent cache)
543-
throws IOException {
544-
543+
private static IOContent cache(final HTTPContext http, final IOContent cache) throws IOException {
545544
if(cache != null) return cache;
546545
final BufferInput bi = new BufferInput(http.req.getInputStream());
547546
final IOContent io = new IOContent(bi.content());
@@ -554,9 +553,7 @@ private static IOContent cache(final HTTPContext http, final IOContent cache)
554553
* @param body request body
555554
* @param pars map parameters
556555
*/
557-
private static void addURLEncoded(final IOContent body,
558-
final Map<String, Value> pars) {
559-
556+
private static void addURLEncoded(final IOContent body, final Map<String, Value> pars) {
560557
for(final String nv : body.toString().split("&")) {
561558
final String[] parts = nv.split("=", 2);
562559
if(parts.length < 2) continue;

0 commit comments

Comments
 (0)