Angrycreative / bj-lazy-load

WordPress plugin for lazy loading
GNU General Public License v2.0
40 stars 25 forks source link

DON'T BE GREEDY regular expression fix .. #10

Open SGudbrandsson opened 9 years ago

SGudbrandsson commented 9 years ago

The regular expression (that I wrote) on line 230 was too greedy. If the U modifier is used then this is ungreedy by default. The problem is when you have the question mark behind a quantifier then it will inverse that quantifier's greediness. So it will search for an iframe open tag, then search for the last iframe close tag (rather than the next iframe close tag). \ ORIGINAL REGEXP * |<iframe\s+.?|siU

By removing the question mark, the whole expression is not greedy by default, resulting in functionality just like you'd want. \ FIXED REGEXP * |<iframe\s+.|siU

SGudbrandsson commented 9 years ago

oh my .. it removed the code I wrote .. oh well..