prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.54k stars 639 forks source link

String#extractScripts evaluates scripts that are not javascript #304

Closed qsiebers closed 7 years ago

qsiebers commented 8 years ago

String#extractScripts passes any scripts in the string to String#evalScripts, regardless of type. To increase integration support with other tools (like handlebars or dot.js) and increase stability a check of the type should be added. Scripts without type should still be evaluated as they default to javascript according to specs.

I've tried to tackle this by changing the Prototype.ScriptFragment regex, but without success. The submitted code is not perfect, but gets the job done. Alternatives are welcome.

savetheclocktower commented 7 years ago

I went with a simpler approach, but I borrowed your ExecutableScript pattern and your unit tests. Thanks!

qsiebers commented 7 years ago

I'm not sure how good I got that regex, I seem to recall having some issues with it. But hey, if the test cases work...