diff -Naru from/BogoYaml.php to/BogoYaml.php --- from/BogoYaml.php 2005-03-21 10:37:04.000000000 +0900 +++ to/BogoYaml.php 2006-12-02 04:55:06.962523200 +0900 @@ -471,11 +471,33 @@ return $ret; } + function _strip_slash_callback($matches) + { + static $table = array( + '0' => "\x00", + 'a' => "\x07", + 'b' => "\x08", + 't' => "\t", + 'n' => "\n", + 'v' => "\x0b", + 'f' => "\x0c", + 'r' => "\r", + 'e' => "\x1b", + ' ' => ' ', + '"' => '"', + '\\'=> '\\', + ); + if (isset($table[$matches[1]])) + return $table[$matches[1]]; + else + return $matches[1]; + } + function _strip_slash($str) { - return str_replace( - array('\0', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '\e', '\ ', '\"', '\\\\'), - array("\x00", "\x07", "\x08", "\t", "\n", "\x0b", "\x0c", "\r", "\x1b", ' ', '"' , '\\'), + return preg_replace_callback( + '/\\\\(.)/', # /\\(.)/ + array('BogoYaml', '_strip_slash_callback'), $str ); }