2626use function is_resource ;
2727use function proc_close ;
2828use function proc_open ;
29+ use function str_contains ;
2930use function str_replace ;
3031use function str_starts_with ;
3132use function stream_get_contents ;
@@ -335,9 +336,14 @@ private function settingsToParameters(array $settings): array
335336 }
336337
337338 /**
338- * Wraps the value portion of a "name=value" INI setting in double quotes
339- * so PHP's INI parser treats characters such as `;` (comment) and `"`
340- * (string delimiter) as literal data instead of metacharacters.
339+ * Quotes the value portion of a "name=value" INI setting only when it
340+ * contains characters PHP's INI parser would otherwise interpret as
341+ * metacharacters (`;` starts a comment, `"` is a string delimiter).
342+ *
343+ * Quoting is avoided for plain values so that boolean keywords such as
344+ * `On` / `Off` keep their special INI semantics; wrapping them in quotes
345+ * turns them into the literal strings `"On"` / `"Off"` and breaks
346+ * settings like `output_buffering`.
341347 */
342348 private function quoteSettingValue (string $ setting ): string
343349 {
@@ -347,9 +353,14 @@ private function quoteSettingValue(string $setting): string
347353 return $ setting ;
348354 }
349355
350- $ name = substr ($ setting , 0 , $ position );
351356 $ value = substr ($ setting , $ position + 1 );
352357
358+ if (!str_contains ($ value , '; ' ) && !str_contains ($ value , '" ' )) {
359+ return $ setting ;
360+ }
361+
362+ $ name = substr ($ setting , 0 , $ position );
363+
353364 return $ name . '=" ' . str_replace ('" ' , '\\" ' , $ value ) . '" ' ;
354365 }
355366}
0 commit comments