Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationStepLogger::clean
Strips control characters from a string and caps its length.
A newline in a message would split the entry, since the handler writes the message into the line unencoded, so a caller able to reach a logged exception could otherwise forge a line the readers parse as genuine.
Метод класса: NotificationStepLogger{}
Хуков нет.
Возвращает
string.
Использование
$result = NotificationStepLogger::clean( $value, $limit ): string;
- $value(строка) (обязательный)
- The value.
- $limit(int) (обязательный)
- The most characters to keep.
Код NotificationStepLogger::clean() NotificationStepLogger::clean WC 11.3.0
private static function clean( string $value, int $limit ): string {
// Matched bytewise, because a caller controls these bytes and they need
// not be valid UTF-8.
$value = (string) preg_replace( '/[\x00-\x1F\x7F]+/', ' ', $value );
if ( mb_strlen( $value ) <= $limit ) {
return $value;
}
return mb_substr( $value, 0, $limit ) . '... (truncated)';
}