Skip to content

Commit a0b6ae4

Browse files
Bug Fix
1 parent 1d0aa07 commit a0b6ae4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

about.page

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ color: '#885933'
66
link: 'https://github.com/taufik-nurrohman/y-a-m-l'
77
author: Taufik Nurrohman
88
type: Markdown
9-
version: 3.0.2
9+
version: 3.0.3
1010
...
1111

1212
This extension converts YAML string to PHP data and/or PHP data to YAML string.

engine/plug/from.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function t($value, $array, $lot, $tag) {
113113
if (0 === \strpos($tag, '!!')) {
114114
$tag = \substr($tag, 2);
115115
if ('binary' === $tag) {
116-
return \base64_decode($value ?? 'AA==');
116+
return \base64_decode(\preg_replace('/\s+/', "", \trim($value ?? 'AA==')));
117117
}
118118
if ('bool' === $tag) {
119119
return (bool) $value;

engine/plug/to.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ function to($value, $dent = true): ?string {
3333
$dent = \str_repeat(' ', 4);
3434
}
3535
if (\is_string($raw = $value)) {
36-
if ("" !== $value && \preg_match('/[\x80-\xFF]/', $value)) {
37-
return '!!binary ' . \base64_encode($value);
36+
if ("" !== $value && false !== \strpos($value, "\0")) {
37+
$value = \base64_encode($value);
38+
if (\strlen($value) <= 111) {
39+
return '!!binary ' . $value;
40+
}
41+
return "!!binary |\n" . $dent . \rtrim(\chunk_split($value, 120, "\n" . $dent));
3842
}
3943
$d = 0;
4044
$flow = false;

0 commit comments

Comments
 (0)