Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,7 @@ if (isSomeString!T)
{
if (f.spec == 's')
{
bool invalidSeq = false;
try
{
// ignore other specifications and quote
Expand All @@ -1537,18 +1538,25 @@ if (isSomeString!T)
// \uFFFE and \uFFFF are considered valid by isValidDchar,
// so need checking for interchange.
if (c == 0xFFFE || c == 0xFFFF)
goto InvalidSeq;

{
invalidSeq = true;
goto LinvalidSeq;
}
formatChar(app, c);
}
put(app, '\"');

put(w, app.data());
}
catch (UtfException e)
catch (UtfException)
{
InvalidSeq:
// If val contains invalid UTF sequence, formatted like HexString literal
invalidSeq = true;
}

LinvalidSeq:
if (invalidSeq)
{
static if (is(typeof(val[0]) : const(char)))
{
enum postfix = 'c';
Expand Down