nealrichardson commented on code in PR #41969:
URL: https://github.com/apache/arrow/pull/41969#discussion_r1626861684
##########
r/R/metadata.R:
##########
@@ -44,23 +44,96 @@
}
.deserialize_arrow_r_metadata <- function(x) {
- tryCatch(
- expr = {
- out <- unserialize(charToRaw(x))
-
- # if this is still raw, try decompressing
- if (is.raw(out)) {
- out <- unserialize(memDecompress(out, type = "gzip"))
- }
- out
- },
+ tryCatch(unserialize_r_metadata(x),
error = function(e) {
+ if (getOption("arrow.debug", FALSE)) {
+ print(conditionMessage(e))
+ }
warning("Invalid metadata$r", call. = FALSE)
NULL
}
)
}
+unserialize_r_metadata <- function(x) {
+ # Check that this is ASCII serialized data (as in, what we wrote)
+ if (!identical(substr(unclass(x), 1, 1), "A")) {
Review Comment:
This is actually about how `base::serialize()` works, signifying that it is
ASCII:
> The format consists of a single line followed by the data: the first line
contains a single character: X for binary serialization and A for ASCII
serialization, followed by a new line.
https://stat.ethz.ch/R-manual/R-devel/library/base/html/serialize.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]