< prev index next >

src/java.base/share/native/libjli/args.c

Print this page
rev 51884 : 8210810: Escaped character at specific position in argument file is not handled properly
Contributed-by: Bo Zhang <zhangbodut@gmail.com>
Reviewed-by: henryjen


 246                     JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
 247                     token = JLI_List_combine(pctx->parts);
 248                     JLI_List_free(pctx->parts);
 249                     pctx->parts = JLI_List_new(4);
 250                 }
 251                 pctx->cptr = nextc + 1;
 252                 pctx->state = FIND_NEXT;
 253                 return token;
 254             case '#':
 255                 if (pctx->state == IN_QUOTE) {
 256                     continue;
 257                 }
 258                 pctx->state = IN_COMMENT;
 259                 break;
 260             case '\\':
 261                 if (pctx->state != IN_QUOTE) {
 262                     continue;
 263                 }
 264                 JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
 265                 pctx->state = IN_ESCAPE;


 266                 break;
 267             case '\'':
 268             case '"':
 269                 if (pctx->state == IN_QUOTE && pctx->quote_char != ch) {
 270                     // not matching quote
 271                     continue;
 272                 }
 273                 // partial before quote
 274                 if (anchor != nextc) {
 275                     JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
 276                 }
 277                 // anchor after quote character
 278                 anchor = nextc + 1;
 279                 if (pctx->state == IN_TOKEN) {
 280                     pctx->quote_char = ch;
 281                     pctx->state = IN_QUOTE;
 282                 } else {
 283                     pctx->state = IN_TOKEN;
 284                 }
 285                 break;




 246                     JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
 247                     token = JLI_List_combine(pctx->parts);
 248                     JLI_List_free(pctx->parts);
 249                     pctx->parts = JLI_List_new(4);
 250                 }
 251                 pctx->cptr = nextc + 1;
 252                 pctx->state = FIND_NEXT;
 253                 return token;
 254             case '#':
 255                 if (pctx->state == IN_QUOTE) {
 256                     continue;
 257                 }
 258                 pctx->state = IN_COMMENT;
 259                 break;
 260             case '\\':
 261                 if (pctx->state != IN_QUOTE) {
 262                     continue;
 263                 }
 264                 JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
 265                 pctx->state = IN_ESCAPE;
 266                 // anchor after backslash character
 267                 anchor = nextc + 1;
 268                 break;
 269             case '\'':
 270             case '"':
 271                 if (pctx->state == IN_QUOTE && pctx->quote_char != ch) {
 272                     // not matching quote
 273                     continue;
 274                 }
 275                 // partial before quote
 276                 if (anchor != nextc) {
 277                     JLI_List_addSubstring(pctx->parts, anchor, nextc - anchor);
 278                 }
 279                 // anchor after quote character
 280                 anchor = nextc + 1;
 281                 if (pctx->state == IN_TOKEN) {
 282                     pctx->quote_char = ch;
 283                     pctx->state = IN_QUOTE;
 284                 } else {
 285                     pctx->state = IN_TOKEN;
 286                 }
 287                 break;


< prev index next >