Skip to content

Commit

Permalink
escape ini quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Dec 15, 2024
1 parent 3c85d5c commit 8ffceb3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/data/src/Format/IniFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ protected static function getValueAsINI(mixed $value): string
return match (gettype($value)) {
'integer', 'double' => $value,
'boolean' => $value ? 'true' : 'false',
'string' => '"' . str_replace(["\r\n", "\n"], '\\n', $value) . '"',
'string' => '"' . static::escapeString($value) . '"',
};
}

protected static function escapeString(string $value): string
{
$value = str_replace(["\r\n", "\n"], '\\n', $value);

return str_replace('"', '\\"', $value);
}
}

0 comments on commit 8ffceb3

Please sign in to comment.