Révision d20f5bc6
Ajouté par Julien Enselme il y a presque 10 ans
drupal7/includes/xmlrpc.inc | ||
---|---|---|
178 | 178 |
xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close'); |
179 | 179 |
xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata'); |
180 | 180 |
xmlrpc_message_set($xmlrpc_message); |
181 |
if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) { |
|
181 |
|
|
182 |
// Strip XML declaration. |
|
183 |
$header = preg_replace('/<\?xml.*?\?'.'>/s', '', substr($xmlrpc_message->message, 0, 100), 1); |
|
184 |
$xml = trim(substr_replace($xmlrpc_message->message, $header, 0, 100)); |
|
185 |
if ($xml == '') { |
|
186 |
return FALSE; |
|
187 |
} |
|
188 |
// Strip DTD. |
|
189 |
$header = preg_replace('/^<!DOCTYPE[^>]*+>/i', '', substr($xml, 0, 200), 1); |
|
190 |
$xml = trim(substr_replace($xml, $header, 0, 200)); |
|
191 |
if ($xml == '') { |
|
192 |
return FALSE; |
|
193 |
} |
|
194 |
// Confirm the XML now starts with a valid root tag. A root tag can end in [> \t\r\n] |
|
195 |
$root_tag = substr($xml, 0, strcspn(substr($xml, 0, 20), "> \t\r\n")); |
|
196 |
// Reject a second DTD. |
|
197 |
if (strtoupper($root_tag) == '<!DOCTYPE') { |
|
198 |
return FALSE; |
|
199 |
} |
|
200 |
if (!in_array($root_tag, array('<methodCall', '<methodResponse', '<fault'))) { |
|
201 |
return FALSE; |
|
202 |
} |
|
203 |
// Skip parsing if there is an unreasonably large number of tags. |
|
204 |
try { |
|
205 |
$dom = new DOMDocument(); |
|
206 |
@$dom->loadXML($xml); |
|
207 |
if ($dom->getElementsByTagName('*')->length > variable_get('xmlrpc_message_maximum_tag_count', 30000)) { |
|
208 |
return FALSE; |
|
209 |
} |
|
210 |
} |
|
211 |
catch (Exception $e) { |
|
212 |
return FALSE; |
|
213 |
} |
|
214 |
|
|
215 |
if (!xml_parse($xmlrpc_message->_parser, $xml)) { |
|
182 | 216 |
return FALSE; |
183 | 217 |
} |
184 | 218 |
xml_parser_free($xmlrpc_message->_parser); |
Formats disponibles : Unified diff
Udpate to 7.31