@@ -53,16 +53,23 @@ function is_valid_mf2_object($input) {
53
53
54
54
// If a value of a property is not a string, it must be a valid mf2 object
55
55
foreach ($ property as $ k =>$ val ) {
56
- // e-* get parsed as objects
57
56
if (is_object ($ val )) {
58
- if (!property_exists ($ val , 'value ' ))
59
- return [false , 'Object ' .$ k .' is missing the "value" property ' ];
57
+ // Try to detect e- parsed objects
58
+ if (property_exists ($ val , 'value ' ) && !property_exists ($ val , 'html ' ))
59
+ return [false , 'One of the values of ' .$ key .' is missing the "html" property ' ];
60
+
61
+ if (property_exists ($ val , 'html ' ) && !property_exists ($ val , 'value ' ))
62
+ return [false , 'One of the values of ' .$ key .' is missing the "value" property ' ];
63
+
64
+ // Otherwise this must be a nested object
65
+ list ($ valid , $ error ) = is_valid_mf2_object ($ val );
66
+ if (!$ valid )
67
+ return [false , 'One of the values of " ' .$ key .'" is not a valid mf2 object: ' .$ error ];
60
68
61
- if (!property_exists ($ val , 'html ' ))
62
- return [false , 'Object ' .$ k .' is missing the "html" property ' ];
63
69
} else if (!is_string ($ val )) {
64
70
if (is_numeric ($ val ))
65
71
return [false , 'One of the values of " ' .$ key .'" is a number instead of a string ' ];
72
+
66
73
list ($ valid , $ error ) = is_valid_mf2_object ($ val );
67
74
if ($ error )
68
75
return [false , 'One of the values of " ' .$ key .'" is not a valid mf2 object ' ];
0 commit comments