From fb0232883b6f8f8a90098b687982a8420dd07895 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 24 Mar 2020 21:52:31 -0700 Subject: [PATCH] Fabric: Additional temporary checks in prop parsing infra Summary: While ViewConfig infra isn't perfect we need to check some value for correctness during prop-parsing. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D20639055 fbshipit-source-id: 193dcd0769bc7777bc8d60c964ede72ebdaa83e4 --- .../fabric/components/image/conversions.h | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ReactCommon/fabric/components/image/conversions.h b/ReactCommon/fabric/components/image/conversions.h index acd49dad7482e7..2c0757267d260f 100644 --- a/ReactCommon/fabric/components/image/conversions.h +++ b/ReactCommon/fabric/components/image/conversions.h @@ -52,15 +52,24 @@ inline void fromRawValue(const RawValue &value, ImageSource &result) { result.scale = items.find("deprecated") != items.end() ? 0.0 : 1.0; } - if (items.find("url") != items.end()) { + if (items.find("url") != items.end() && + // The following should be removed after codegen is shipped. + // See T45151459. + items.at("url").hasType()) { result.uri = (std::string)items.at("url"); } - if (items.find("uri") != items.end()) { + if (items.find("uri") != items.end() && + // The following should be removed after codegen is shipped. + // See T45151459. + items.at("uri").hasType()) { result.uri = (std::string)items.at("uri"); } - if (items.find("bundle") != items.end()) { + if (items.find("bundle") != items.end() && + // The following should be removed after codegen is shipped. + // See T45151459. + items.at("bundle").hasType()) { result.bundle = (std::string)items.at("bundle"); result.type = ImageSource::Type::Local; } @@ -68,7 +77,10 @@ inline void fromRawValue(const RawValue &value, ImageSource &result) { return; } - abort(); + // The following should be removed after codegen is shipped. + // See T45151459. + result = {}; + result.type = ImageSource::Type::Invalid; } inline std::string toString(const ImageSource &value) {