Add newline after JSON and XML responses

This commit is contained in:
Kijin Sung 2024-04-16 21:38:56 +09:00
parent 114755d13a
commit d0183268ce
3 changed files with 8 additions and 8 deletions

View file

@ -160,13 +160,13 @@ class DisplayHandler extends Handler
*
* @return string
*/
public static function getDebugInfo(&$output = null)
public static function getDebugInfo(&$output = null): string
{
// Check if debugging information has already been printed.
if (self::$debug_printed)
{
return;
return '';
}
else
{
@ -176,7 +176,7 @@ class DisplayHandler extends Handler
// Check if debugging is enabled for this request.
if (!Rhymix\Framework\Debug::isEnabledForCurrentUser())
{
return;
return '';
}
// Do not display debugging information if there is no output.
@ -187,7 +187,7 @@ class DisplayHandler extends Handler
}
if ($output === null && !in_array('file', $display_types))
{
return;
return '';
}
if ($output === null)
{
@ -261,12 +261,12 @@ class DisplayHandler extends Handler
break;
case 'JSON':
unset($_SESSION['_rx_debug_previous']);
if (preg_match('/^(.+)\}$/', $output, $matches))
if (preg_match('/^(.+)\}\n?$/', $output, $matches))
{
$data = json_encode($data);
if (json_last_error() === JSON_ERROR_NONE)
{
$output = $matches[1] . ',"_rx_debug":' . $data . '}';
$output = $matches[1] . ',"_rx_debug":' . $data . "}\n";
}
}
break;

View file

@ -15,7 +15,7 @@ class JSONDisplayHandler
$variables['message'] = $oModule->getMessage();
self::_convertCompat($variables, Context::getRequestMethod());
return json_encode($variables);
return json_encode($variables) . "\n";
}
/**

View file

@ -18,7 +18,7 @@ class XMLDisplayHandler
$xmlDoc .= $this->_makeXmlDoc($variables);
$xmlDoc .= "</response>";
$xmlDoc .= "</response>\n";
return $xmlDoc;
}