Skip to content

Commit bf421e5

Browse files
committed
trurl: handle zero length query pairs
Added several new test cases for it Fixes #387 Reported-by: joveian on github
1 parent 0ddc31d commit bf421e5

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

tests.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3274,5 +3274,49 @@
32743274
"stderr": "trurl error: --json is mutually exclusive with --get\ntrurl error: Try trurl -h for help\n",
32753275
"returncode": 4
32763276
}
3277+
},
3278+
{
3279+
"input": {
3280+
"arguments": [
3281+
"e?e&&"
3282+
]
3283+
},
3284+
"expected": {
3285+
"stdout": "http://e/?e\n",
3286+
"returncode": 0
3287+
}
3288+
},
3289+
{
3290+
"input": {
3291+
"arguments": [
3292+
"e?e&"
3293+
]
3294+
},
3295+
"expected": {
3296+
"stdout": "http://e/?e\n",
3297+
"returncode": 0
3298+
}
3299+
},
3300+
{
3301+
"input": {
3302+
"arguments": [
3303+
"e?e&&&&&&&&&&&&&&&&&&&&&"
3304+
]
3305+
},
3306+
"expected": {
3307+
"stdout": "http://e/?e\n",
3308+
"returncode": 0
3309+
}
3310+
},
3311+
{
3312+
"input": {
3313+
"arguments": [
3314+
"e?e&&&&&&&&&&a&&&&&&&&&&&"
3315+
]
3316+
},
3317+
"expected": {
3318+
"stdout": "http://e/?e&a\n",
3319+
"returncode": 0
3320+
}
32773321
}
32783322
]

trurl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ static void qpair2query(CURLU *uh, struct option *o)
15721572
for(i = 0; i<nqpairs; i++) {
15731573
char *oldnq = nq;
15741574
nq = curl_maprintf("%s%s%s", nq ? nq : "",
1575-
(nq && *nq && *(qpairs[i].str)) ? o->qsep : "",
1576-
qpairs[i].str);
1575+
(nq && *nq && qpairs[i].len) ? o->qsep : "",
1576+
qpairs[i].len ? qpairs[i].str : "");
15771577
curl_free(oldnq);
15781578
}
15791579
if(nq) {

0 commit comments

Comments
 (0)