@@ -320,6 +320,7 @@ bool decode_inline_value(lua_State *L, str_iter *src, str_buf *buf, const Tomlua
320320 bool is_float = false;
321321 bool is_date = false;
322322 bool t_used = false;
323+ bool last_was_T_space = false;
323324 bool z_used = false;
324325 bool was_underscore = true;
325326 if (curr .v == '+' ) {
@@ -351,13 +352,13 @@ bool decode_inline_value(lua_State *L, str_iter *src, str_buf *buf, const Tomlua
351352 }
352353 while (iter_peek (src ).ok ) {
353354 char ch = iter_peek (src ).v ;
354- if (ch == '_' ) {
355+ if (ch == '_' && ! last_was_T_space ) {
355356 iter_skip (src );
356357 if (was_underscore ) {
357358 return set_tmlerr (new_tmlerr (L , erridx ), false, 46 , "consecutive underscores not allowed in numbers" );
358359 }
359360 was_underscore = true;
360- } else if (ch == 'e' || ch == 'E' ) {
361+ } else if (( ch == 'e' || ch == 'E' ) && ! last_was_T_space ) {
361362 is_float = true;
362363 buf_push (buf , ch );
363364 iter_skip (src );
@@ -367,37 +368,47 @@ bool decode_inline_value(lua_State *L, str_iter *src, str_buf *buf, const Tomlua
367368 iter_skip (src );
368369 }
369370 was_underscore = false;
370- } else if (ch == ':' ) {
371+ } else if (ch == ':' && ! last_was_T_space ) {
371372 is_date = true;
372373 was_underscore = false;
373374 buf_push (buf , ch );
374375 iter_skip (src );
375- } else if (ch == '-' ) {
376+ } else if (ch == '-' && ! last_was_T_space ) {
376377 is_date = true;
377378 was_underscore = false;
378379 buf_push (buf , ch );
379380 iter_skip (src );
380- } else if (is_date && !t_used && ( ch == 'T' || ch == ' ' ) ) {
381+ } else if (is_date && !t_used && ch == 'T' && ! last_was_T_space ) {
381382 t_used = true;
382383 was_underscore = false;
383384 buf_push (buf , ch );
384385 iter_skip (src );
385- } else if (is_date && !z_used && ch == 'Z' ) {
386+ } else if (is_date && !t_used && ch == ' ' && !last_was_T_space ) {
387+ t_used = true;
388+ was_underscore = false;
389+ last_was_T_space = true;
390+ iter_skip (src );
391+ } else if (is_date && !z_used && ch == 'Z' && !last_was_T_space ) {
386392 z_used = true;
387393 was_underscore = false;
388394 buf_push (buf , ch );
389395 iter_skip (src );
390- } else if (ch == '.' ) {
396+ } else if (ch == '.' && ! last_was_T_space ) {
391397 is_float = true;
392398 was_underscore = false;
393399 buf_push (buf , ch );
394400 iter_skip (src );
395401 } else if (ch >= '0' && ch <= '9' ) {
402+ if (last_was_T_space ) {
403+ if (!buf_push (buf , ' ' )) return set_tmlerr (new_tmlerr (L , erridx ), false, 56 , "failed to push space to date" );
404+ }
405+ last_was_T_space = false;
396406 was_underscore = false;
397407 buf_push (buf , ch );
398408 iter_skip (src );
399409 } else {
400410 was_underscore = false;
411+ last_was_T_space = false;
401412 break ;
402413 }
403414 }
0 commit comments