Need an iteration in the following code snippet?

Here is a code snippet from the xss_clean method of the Input_Core class of the Kohana structure:

do
{
 // Remove really unwanted tags
 $old_data = $data;
 $data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $data);
}
while ($old_data !== $data);

Is it required ... while loop? I would have thought that calling preg_replace would do all the work in just one iteration.

+5
source share
2 answers

Well, this is necessary if the replacement potentially creates new matches in the next iteration. This is not very wasteful, because it is only an additional check in the worst case.

Walking around the code that it matches, it seems unlikely that it will create new matches by replacement, however: it is very strict that it matches.

: , , , , , , , . , . (, ), , , .

, . <<iframe>iframe>, . -, (, < iframe> ).

EDIT2: , ( ). , *+ ( , , , - ?).

+3

.

preg_replace() , (. 5- , ). , , .

+2

All Articles