@@ -104,7 +104,6 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-characterdata-substringdata
104
104
PHP_METHOD (DOMCharacterData , substringData )
105
105
{
106
106
zval * id ;
107
- xmlChar * cur ;
108
107
xmlChar * substring ;
109
108
xmlNodePtr node ;
110
109
zend_long offset_input , count_input ;
@@ -119,11 +118,7 @@ PHP_METHOD(DOMCharacterData, substringData)
119
118
120
119
DOM_GET_OBJ (node , id , xmlNodePtr , intern );
121
120
122
- cur = node -> content ;
123
- if (cur == NULL ) {
124
- /* TODO: is this even possible? */
125
- cur = BAD_CAST "" ;
126
- }
121
+ const xmlChar * cur = php_dom_get_content_or_empty (node );
127
122
128
123
length = xmlUTF8Strlen (cur );
129
124
if (ZEND_LONG_INT_OVFL (offset_input ) || ZEND_LONG_INT_OVFL (count_input )) {
@@ -197,7 +192,7 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-characterdata-insertdata
197
192
static void dom_character_data_insert_data (INTERNAL_FUNCTION_PARAMETERS , bool return_true )
198
193
{
199
194
zval * id ;
200
- xmlChar * cur , * first , * second ;
195
+ xmlChar * first , * second ;
201
196
xmlNodePtr node ;
202
197
char * arg ;
203
198
zend_long offset_input ;
@@ -213,11 +208,7 @@ static void dom_character_data_insert_data(INTERNAL_FUNCTION_PARAMETERS, bool re
213
208
214
209
DOM_GET_OBJ (node , id , xmlNodePtr , intern );
215
210
216
- cur = node -> content ;
217
- if (cur == NULL ) {
218
- /* TODO: is this even possible? */
219
- cur = BAD_CAST "" ;
220
- }
211
+ const xmlChar * cur = php_dom_get_content_or_empty (node );
221
212
222
213
length = xmlUTF8Strlen (cur );
223
214
@@ -268,7 +259,7 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-characterdata-deletedata
268
259
static void dom_character_data_delete_data (INTERNAL_FUNCTION_PARAMETERS , bool return_true )
269
260
{
270
261
zval * id ;
271
- xmlChar * cur , * substring , * second ;
262
+ xmlChar * substring , * second ;
272
263
xmlNodePtr node ;
273
264
zend_long offset , count_input ;
274
265
unsigned int count ;
@@ -282,11 +273,7 @@ static void dom_character_data_delete_data(INTERNAL_FUNCTION_PARAMETERS, bool re
282
273
283
274
DOM_GET_OBJ (node , id , xmlNodePtr , intern );
284
275
285
- cur = node -> content ;
286
- if (cur == NULL ) {
287
- /* TODO: is this even possible? */
288
- cur = BAD_CAST "" ;
289
- }
276
+ const xmlChar * cur = php_dom_get_content_or_empty (node );
290
277
291
278
length = xmlUTF8Strlen (cur );
292
279
@@ -340,7 +327,7 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-characterdata-replacedata
340
327
static void dom_character_data_replace_data (INTERNAL_FUNCTION_PARAMETERS , bool return_true )
341
328
{
342
329
zval * id ;
343
- xmlChar * cur , * substring , * second = NULL ;
330
+ xmlChar * substring , * second = NULL ;
344
331
xmlNodePtr node ;
345
332
char * arg ;
346
333
zend_long offset , count_input ;
@@ -356,11 +343,7 @@ static void dom_character_data_replace_data(INTERNAL_FUNCTION_PARAMETERS, bool r
356
343
357
344
DOM_GET_OBJ (node , id , xmlNodePtr , intern );
358
345
359
- cur = node -> content ;
360
- if (cur == NULL ) {
361
- /* TODO: is this even possible? */
362
- cur = BAD_CAST "" ;
363
- }
346
+ const xmlChar * cur = php_dom_get_content_or_empty (node );
364
347
365
348
length = xmlUTF8Strlen (cur );
366
349
0 commit comments