phmLabs / LiveTest2

LiveTest2
MIT License
5 stars 9 forks source link

make Document->getExternalDependencies regex non-greedy to avoid edge-cas... #43

Closed jfmaeck closed 9 years ago

jfmaeck commented 9 years ago

The original greedy regex had problems recoginizing dynamically inserted scripts:

Example Source Code:

...
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/vendor/jquery/jquery.min.js"><\/script>')</script>
...

Example output before patch (greedy regex):

array(2) {

array(2) {
  [0]=>
  string(59) "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
  [1]=>
  string(40) "/vendor/jquery/jquery.min.js"><\/script>"
}

Example output after patch (non-greedy regex):

array(2) {
  [0]=>
  string(59) "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
  [1]=>
  string(28) "/vendor/jquery/jquery.min.js"
}
digitalkaoz commented 9 years ago

yeah look good. thank you!