Explorar el Código

Fix the handling of Unicode characters in log and assertion messages (#8372)

Currently, any UTF-8 characters outside the ascii set may be encoded incorrectly.
Konstantin Varlamov hace 4 años
padre
commit
bd64ba6f8a

+ 4 - 0
Firestore/CHANGELOG.md

@@ -1,3 +1,7 @@
+# v8.4.0
+- [fixed] Fixed handling of Unicode characters in log and assertion messages
+  (#8372).
+
 # v8.2.0
 - [changed] Passing in an empty document ID, collection group ID, or collection
   path will now result in a more readable error (#8218).

+ 2 - 2
Firestore/core/src/util/exception_apple.mm

@@ -60,8 +60,8 @@ ABSL_ATTRIBUTE_NORETURN void ObjcThrowHandler(ExceptionType type,
         handleFailureInFunction:MakeNSString(func)
                            file:MakeNSString(file)
                      lineNumber:line
-                    description:@"%@: %s", ExceptionName(type),
-                                message.c_str()];
+                    description:@"%@: %@", ExceptionName(type),
+                                MakeNSString(message)];
     std::terminate();
   } else {
     @throw MakeException(type, message);  // NOLINT

+ 1 - 1
Firestore/core/src/util/log_apple.mm

@@ -85,7 +85,7 @@ bool LogIsLoggable(LogLevel level) {
 }
 
 void LogMessage(LogLevel level, const std::string& message) {
-  LogMessageV(level, @"%s", message.c_str());
+  LogMessageV(level, @"%@", MakeNSString(message));
 }
 
 }  // namespace util