0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 08:21:52 +00:00

Fix quadratic behavior in DOMLex due to array_shift.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang 2013-09-17 00:48:42 -07:00
parent cf44f399f8
commit 412bae13b5
6 changed files with 188 additions and 128 deletions

2
NEWS
View File

@ -17,6 +17,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
Michael Gusev <mgusev@sugarcrm.com> for fixing. Michael Gusev <mgusev@sugarcrm.com> for fixing.
! New directive %Core.AllowHostnameUnderscore which allows underscores ! New directive %Core.AllowHostnameUnderscore which allows underscores
in hostnames. in hostnames.
- Eliminate quadratic behavior in DOMLex by using a proper queue.
Thanks Ole Laursen for noticing this.
- Made Linkify URL parser a bit less permissive, so that non-breaking - Made Linkify URL parser a bit less permissive, so that non-breaking
spaces and commas are not included as part of URL. Thanks nAS for fixing. spaces and commas are not included as part of URL. Thanks nAS for fixing.
- Fix some bad interactions with %HTML.Allowed and injectors. Thanks - Fix some bad interactions with %HTML.Allowed and injectors. Thanks

View File

@ -2,551 +2,551 @@
<usage> <usage>
<directive id="Core.CollectErrors"> <directive id="Core.CollectErrors">
<file name="HTMLPurifier.php"> <file name="HTMLPurifier.php">
<line>150</line> <line>162</line>
</file> </file>
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>81</line> <line>85</line>
<line>284</line> <line>315</line>
</file> </file>
<file name="HTMLPurifier/Lexer/DirectLex.php"> <file name="HTMLPurifier/Lexer/DirectLex.php">
<line>53</line> <line>67</line>
<line>73</line> <line>87</line>
<line>348</line> <line>385</line>
</file> </file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>50</line> <line>57</line>
</file> </file>
</directive> </directive>
<directive id="CSS.MaxImgLength"> <directive id="CSS.MaxImgLength">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>157</line> <line>226</line>
</file> </file>
</directive> </directive>
<directive id="CSS.Proprietary"> <directive id="CSS.Proprietary">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>215</line> <line>319</line>
</file> </file>
</directive> </directive>
<directive id="CSS.AllowTricky"> <directive id="CSS.AllowTricky">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>219</line> <line>323</line>
</file> </file>
</directive> </directive>
<directive id="CSS.Trusted"> <directive id="CSS.Trusted">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>223</line> <line>327</line>
</file> </file>
</directive> </directive>
<directive id="CSS.AllowImportant"> <directive id="CSS.AllowImportant">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>227</line> <line>331</line>
</file> </file>
</directive> </directive>
<directive id="CSS.AllowedProperties"> <directive id="CSS.AllowedProperties">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>302</line> <line>447</line>
</file> </file>
</directive> </directive>
<directive id="CSS.ForbiddenProperties"> <directive id="CSS.ForbiddenProperties">
<file name="HTMLPurifier/CSSDefinition.php"> <file name="HTMLPurifier/CSSDefinition.php">
<line>316</line> <line>463</line>
</file> </file>
</directive> </directive>
<directive id="Cache.DefinitionImpl"> <directive id="Cache.DefinitionImpl">
<file name="HTMLPurifier/DefinitionCacheFactory.php"> <file name="HTMLPurifier/DefinitionCacheFactory.php">
<line>59</line> <line>66</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Doctype"> <directive id="HTML.Doctype">
<file name="HTMLPurifier/DoctypeRegistry.php"> <file name="HTMLPurifier/DoctypeRegistry.php">
<line>83</line> <line>119</line>
</file> </file>
</directive> </directive>
<directive id="HTML.CustomDoctype"> <directive id="HTML.CustomDoctype">
<file name="HTMLPurifier/DoctypeRegistry.php"> <file name="HTMLPurifier/DoctypeRegistry.php">
<line>85</line> <line>123</line>
</file> </file>
</directive> </directive>
<directive id="HTML.XHTML"> <directive id="HTML.XHTML">
<file name="HTMLPurifier/DoctypeRegistry.php"> <file name="HTMLPurifier/DoctypeRegistry.php">
<line>88</line> <line>128</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Strict"> <directive id="HTML.Strict">
<file name="HTMLPurifier/DoctypeRegistry.php"> <file name="HTMLPurifier/DoctypeRegistry.php">
<line>93</line> <line>133</line>
</file> </file>
</directive> </directive>
<directive id="Core.Encoding"> <directive id="Core.Encoding">
<file name="HTMLPurifier/Encoder.php"> <file name="HTMLPurifier/Encoder.php">
<line>337</line> <line>374</line>
<line>372</line> <line>422</line>
</file> </file>
</directive> </directive>
<directive id="Test.ForceNoIconv"> <directive id="Test.ForceNoIconv">
<file name="HTMLPurifier/Encoder.php"> <file name="HTMLPurifier/Encoder.php">
<line>341</line> <line>382</line>
<line>379</line> <line>433</line>
</file> </file>
</directive> </directive>
<directive id="Core.EscapeNonASCIICharacters"> <directive id="Core.EscapeNonASCIICharacters">
<file name="HTMLPurifier/Encoder.php"> <file name="HTMLPurifier/Encoder.php">
<line>373</line> <line>423</line>
</file> </file>
</directive> </directive>
<directive id="Output.CommentScriptContents"> <directive id="Output.CommentScriptContents">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>61</line> <line>70</line>
</file> </file>
</directive> </directive>
<directive id="Output.FixInnerHTML"> <directive id="Output.FixInnerHTML">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>62</line> <line>71</line>
</file> </file>
</directive> </directive>
<directive id="Output.SortAttr"> <directive id="Output.SortAttr">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>63</line> <line>72</line>
</file> </file>
</directive> </directive>
<directive id="Output.FlashCompat"> <directive id="Output.FlashCompat">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>64</line> <line>73</line>
</file> </file>
</directive> </directive>
<directive id="Output.TidyFormat"> <directive id="Output.TidyFormat">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>93</line> <line>104</line>
</file> </file>
</directive> </directive>
<directive id="Core.NormalizeNewlines"> <directive id="Core.NormalizeNewlines">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>107</line> <line>122</line>
</file> </file>
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>266</line> <line>297</line>
</file> </file>
</directive> </directive>
<directive id="Output.Newline"> <directive id="Output.Newline">
<file name="HTMLPurifier/Generator.php"> <file name="HTMLPurifier/Generator.php">
<line>108</line> <line>123</line>
</file> </file>
</directive> </directive>
<directive id="HTML.BlockWrapper"> <directive id="HTML.BlockWrapper">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>222</line> <line>263</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Parent"> <directive id="HTML.Parent">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>230</line> <line>273</line>
</file> </file>
</directive> </directive>
<directive id="HTML.AllowedElements"> <directive id="HTML.AllowedElements">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>247</line> <line>291</line>
</file> </file>
</directive> </directive>
<directive id="HTML.AllowedAttributes"> <directive id="HTML.AllowedAttributes">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>248</line> <line>292</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Allowed"> <directive id="HTML.Allowed">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>251</line> <line>295</line>
</file> </file>
</directive> </directive>
<directive id="HTML.ForbiddenElements"> <directive id="HTML.ForbiddenElements">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>342</line> <line>399</line>
</file> </file>
</directive> </directive>
<directive id="HTML.ForbiddenAttributes"> <directive id="HTML.ForbiddenAttributes">
<file name="HTMLPurifier/HTMLDefinition.php"> <file name="HTMLPurifier/HTMLDefinition.php">
<line>343</line> <line>400</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Trusted"> <directive id="HTML.Trusted">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>204</line> <line>234</line>
</file> </file>
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>271</line> <line>302</line>
</file> </file>
<file name="HTMLPurifier/HTMLModule/Image.php"> <file name="HTMLPurifier/HTMLModule/Image.php">
<line>27</line> <line>37</line>
</file> </file>
<file name="HTMLPurifier/Lexer/DirectLex.php"> <file name="HTMLPurifier/Lexer/DirectLex.php">
<line>36</line> <line>47</line>
</file> </file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>23</line> <line>30</line>
</file> </file>
</directive> </directive>
<directive id="HTML.AllowedModules"> <directive id="HTML.AllowedModules">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>211</line> <line>241</line>
</file> </file>
</directive> </directive>
<directive id="HTML.CoreModules"> <directive id="HTML.CoreModules">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>212</line> <line>242</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Proprietary"> <directive id="HTML.Proprietary">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>222</line> <line>256</line>
</file> </file>
</directive> </directive>
<directive id="HTML.SafeObject"> <directive id="HTML.SafeObject">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>225</line> <line>259</line>
</file> </file>
</directive> </directive>
<directive id="HTML.SafeEmbed"> <directive id="HTML.SafeEmbed">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>228</line> <line>262</line>
</file> </file>
</directive> </directive>
<directive id="HTML.SafeScripting"> <directive id="HTML.SafeScripting">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>231</line> <line>265</line>
</file> </file>
<file name="HTMLPurifier/HTMLModule/SafeScripting.php"> <file name="HTMLPurifier/HTMLModule/SafeScripting.php">
<line>17</line> <line>22</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Nofollow"> <directive id="HTML.Nofollow">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>234</line> <line>268</line>
</file> </file>
</directive> </directive>
<directive id="HTML.TargetBlank"> <directive id="HTML.TargetBlank">
<file name="HTMLPurifier/HTMLModuleManager.php"> <file name="HTMLPurifier/HTMLModuleManager.php">
<line>237</line> <line>271</line>
</file> </file>
</directive> </directive>
<directive id="Attr.IDBlacklist"> <directive id="Attr.IDBlacklist">
<file name="HTMLPurifier/IDAccumulator.php"> <file name="HTMLPurifier/IDAccumulator.php">
<line>26</line> <line>27</line>
</file> </file>
</directive> </directive>
<directive id="Core.Language"> <directive id="Core.Language">
<file name="HTMLPurifier/LanguageFactory.php"> <file name="HTMLPurifier/LanguageFactory.php">
<line>88</line> <line>93</line>
</file> </file>
</directive> </directive>
<directive id="Core.LexerImpl"> <directive id="Core.LexerImpl">
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>76</line> <line>80</line>
</file> </file>
</directive> </directive>
<directive id="Core.MaintainLineNumbers"> <directive id="Core.MaintainLineNumbers">
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>80</line> <line>84</line>
</file> </file>
<file name="HTMLPurifier/Lexer/DirectLex.php"> <file name="HTMLPurifier/Lexer/DirectLex.php">
<line>48</line> <line>62</line>
</file> </file>
</directive> </directive>
<directive id="Core.ConvertDocumentToFragment"> <directive id="Core.ConvertDocumentToFragment">
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>282</line> <line>313</line>
</file> </file>
</directive> </directive>
<directive id="Core.RemoveProcessingInstructions"> <directive id="Core.RemoveProcessingInstructions">
<file name="HTMLPurifier/Lexer.php"> <file name="HTMLPurifier/Lexer.php">
<line>303</line> <line>334</line>
</file> </file>
</directive> </directive>
<directive id="URI."> <directive id="URI.">
<file name="HTMLPurifier/URIDefinition.php"> <file name="HTMLPurifier/URIDefinition.php">
<line>60</line> <line>65</line>
</file> </file>
<file name="HTMLPurifier/URIFilter/Munge.php"> <file name="HTMLPurifier/URIFilter/Munge.php">
<line>12</line> <line>46</line>
</file> </file>
</directive> </directive>
<directive id="URI.Host"> <directive id="URI.Host">
<file name="HTMLPurifier/URIDefinition.php"> <file name="HTMLPurifier/URIDefinition.php">
<line>70</line> <line>76</line>
</file> </file>
<file name="HTMLPurifier/URIScheme.php"> <file name="HTMLPurifier/URIScheme.php">
<line>81</line> <line>89</line>
</file> </file>
</directive> </directive>
<directive id="URI.Base"> <directive id="URI.Base">
<file name="HTMLPurifier/URIDefinition.php"> <file name="HTMLPurifier/URIDefinition.php">
<line>71</line> <line>77</line>
</file> </file>
</directive> </directive>
<directive id="URI.DefaultScheme"> <directive id="URI.DefaultScheme">
<file name="HTMLPurifier/URIDefinition.php"> <file name="HTMLPurifier/URIDefinition.php">
<line>78</line> <line>84</line>
</file> </file>
</directive> </directive>
<directive id="URI.AllowedSchemes"> <directive id="URI.AllowedSchemes">
<file name="HTMLPurifier/URISchemeRegistry.php"> <file name="HTMLPurifier/URISchemeRegistry.php">
<line>41</line> <line>48</line>
</file> </file>
</directive> </directive>
<directive id="URI.OverrideAllowedSchemes"> <directive id="URI.OverrideAllowedSchemes">
<file name="HTMLPurifier/URISchemeRegistry.php"> <file name="HTMLPurifier/URISchemeRegistry.php">
<line>42</line> <line>49</line>
</file> </file>
</directive> </directive>
<directive id="URI.Disable"> <directive id="URI.Disable">
<file name="HTMLPurifier/AttrDef/URI.php"> <file name="HTMLPurifier/AttrDef/URI.php">
<line>28</line> <line>47</line>
</file> </file>
</directive> </directive>
<directive id="Core.ColorKeywords"> <directive id="Core.ColorKeywords">
<file name="HTMLPurifier/AttrDef/CSS/Color.php"> <file name="HTMLPurifier/AttrDef/CSS/Color.php">
<line>12</line> <line>19</line>
</file> </file>
<file name="HTMLPurifier/AttrDef/HTML/Color.php"> <file name="HTMLPurifier/AttrDef/HTML/Color.php">
<line>12</line> <line>19</line>
</file> </file>
</directive> </directive>
<directive id="CSS.AllowedFonts"> <directive id="CSS.AllowedFonts">
<file name="HTMLPurifier/AttrDef/CSS/FontFamily.php"> <file name="HTMLPurifier/AttrDef/CSS/FontFamily.php">
<line>50</line> <line>64</line>
</file> </file>
</directive> </directive>
<directive id="Attr.AllowedClasses"> <directive id="Attr.AllowedClasses">
<file name="HTMLPurifier/AttrDef/HTML/Class.php"> <file name="HTMLPurifier/AttrDef/HTML/Class.php">
<line>18</line> <line>33</line>
</file> </file>
</directive> </directive>
<directive id="Attr.ForbiddenClasses"> <directive id="Attr.ForbiddenClasses">
<file name="HTMLPurifier/AttrDef/HTML/Class.php"> <file name="HTMLPurifier/AttrDef/HTML/Class.php">
<line>19</line> <line>34</line>
</file> </file>
</directive> </directive>
<directive id="Attr.AllowedFrameTargets"> <directive id="Attr.AllowedFrameTargets">
<file name="HTMLPurifier/AttrDef/HTML/FrameTarget.php"> <file name="HTMLPurifier/AttrDef/HTML/FrameTarget.php">
<line>15</line> <line>32</line>
</file> </file>
</directive> </directive>
<directive id="Attr.EnableID"> <directive id="Attr.EnableID">
<file name="HTMLPurifier/AttrDef/HTML/ID.php"> <file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>30</line> <line>41</line>
</file> </file>
</directive> </directive>
<directive id="Attr.IDPrefix"> <directive id="Attr.IDPrefix">
<file name="HTMLPurifier/AttrDef/HTML/ID.php"> <file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>36</line> <line>51</line>
</file> </file>
</directive> </directive>
<directive id="Attr.IDPrefixLocal"> <directive id="Attr.IDPrefixLocal">
<file name="HTMLPurifier/AttrDef/HTML/ID.php"> <file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>38</line> <line>53</line>
<line>41</line> <line>58</line>
</file> </file>
</directive> </directive>
<directive id="Attr.IDBlacklistRegexp"> <directive id="Attr.IDBlacklistRegexp">
<file name="HTMLPurifier/AttrDef/HTML/ID.php"> <file name="HTMLPurifier/AttrDef/HTML/ID.php">
<line>64</line> <line>89</line>
</file> </file>
</directive> </directive>
<directive id="Attr."> <directive id="Attr.">
<file name="HTMLPurifier/AttrDef/HTML/LinkTypes.php"> <file name="HTMLPurifier/AttrDef/HTML/LinkTypes.php">
<line>30</line> <line>46</line>
</file> </file>
</directive> </directive>
<directive id="Core.AllowHostnameUnderscore"> <directive id="Core.AllowHostnameUnderscore">
<file name="HTMLPurifier/AttrDef/URI/Host.php"> <file name="HTMLPurifier/AttrDef/URI/Host.php">
<line>61</line> <line>77</line>
</file> </file>
</directive> </directive>
<directive id="Core.EnableIDNA"> <directive id="Core.EnableIDNA">
<file name="HTMLPurifier/AttrDef/URI/Host.php"> <file name="HTMLPurifier/AttrDef/URI/Host.php">
<line>80</line> <line>96</line>
</file> </file>
</directive> </directive>
<directive id="Attr.DefaultTextDir"> <directive id="Attr.DefaultTextDir">
<file name="HTMLPurifier/AttrTransform/BdoDir.php"> <file name="HTMLPurifier/AttrTransform/BdoDir.php">
<line>13</line> <line>22</line>
</file> </file>
</directive> </directive>
<directive id="Core.RemoveInvalidImg"> <directive id="Core.RemoveInvalidImg">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php"> <file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>18</line> <line>24</line>
</file> </file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>20</line> <line>27</line>
</file> </file>
</directive> </directive>
<directive id="Attr.DefaultInvalidImage"> <directive id="Attr.DefaultInvalidImage">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php"> <file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>19</line> <line>27</line>
</file> </file>
</directive> </directive>
<directive id="Attr.DefaultImageAlt"> <directive id="Attr.DefaultImageAlt">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php"> <file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>25</line> <line>33</line>
</file> </file>
</directive> </directive>
<directive id="Attr.DefaultInvalidImageAlt"> <directive id="Attr.DefaultInvalidImageAlt">
<file name="HTMLPurifier/AttrTransform/ImgRequired.php"> <file name="HTMLPurifier/AttrTransform/ImgRequired.php">
<line>33</line> <line>41</line>
</file> </file>
</directive> </directive>
<directive id="HTML.Attr.Name.UseCDATA"> <directive id="HTML.Attr.Name.UseCDATA">
<file name="HTMLPurifier/AttrTransform/Name.php"> <file name="HTMLPurifier/AttrTransform/Name.php">
<line>11</line> <line>18</line>
</file> </file>
<file name="HTMLPurifier/HTMLModule/Name.php"> <file name="HTMLPurifier/HTMLModule/Name.php">
<line>13</line> <line>19</line>
</file> </file>
</directive> </directive>
<directive id="HTML.FlashAllowFullScreen"> <directive id="HTML.FlashAllowFullScreen">
<file name="HTMLPurifier/AttrTransform/SafeParam.php"> <file name="HTMLPurifier/AttrTransform/SafeParam.php">
<line>38</line> <line>53</line>
</file> </file>
</directive> </directive>
<directive id="Core.EscapeInvalidChildren"> <directive id="Core.EscapeInvalidChildren">
<file name="HTMLPurifier/ChildDef/Required.php"> <file name="HTMLPurifier/ChildDef/Required.php">
<line>62</line> <line>86</line>
</file> </file>
</directive> </directive>
<directive id="Cache.SerializerPath"> <directive id="Cache.SerializerPath">
<file name="HTMLPurifier/DefinitionCache/Serializer.php"> <file name="HTMLPurifier/DefinitionCache/Serializer.php">
<line>91</line> <line>171</line>
</file> </file>
</directive> </directive>
<directive id="Cache.SerializerPermissions"> <directive id="Cache.SerializerPermissions">
<file name="HTMLPurifier/DefinitionCache/Serializer.php"> <file name="HTMLPurifier/DefinitionCache/Serializer.php">
<line>107</line> <line>188</line>
<line>124</line> <line>206</line>
</file> </file>
</directive> </directive>
<directive id="Filter.ExtractStyleBlocks.TidyImpl"> <directive id="Filter.ExtractStyleBlocks.TidyImpl">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php"> <file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>55</line> <line>94</line>
</file> </file>
</directive> </directive>
<directive id="Filter.ExtractStyleBlocks.Scope"> <directive id="Filter.ExtractStyleBlocks.Scope">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php"> <file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>79</line> <line>122</line>
</file> </file>
</directive> </directive>
<directive id="Filter.ExtractStyleBlocks.Escaping"> <directive id="Filter.ExtractStyleBlocks.Escaping">
<file name="HTMLPurifier/Filter/ExtractStyleBlocks.php"> <file name="HTMLPurifier/Filter/ExtractStyleBlocks.php">
<line>277</line> <line>327</line>
</file> </file>
</directive> </directive>
<directive id="HTML.SafeIframe"> <directive id="HTML.SafeIframe">
<file name="HTMLPurifier/HTMLModule/Iframe.php"> <file name="HTMLPurifier/HTMLModule/Iframe.php">
<line>17</line> <line>28</line>
</file> </file>
<file name="HTMLPurifier/URIFilter/SafeIframe.php"> <file name="HTMLPurifier/URIFilter/SafeIframe.php">
<line>23</line> <line>48</line>
</file> </file>
</directive> </directive>
<directive id="HTML.MaxImgLength"> <directive id="HTML.MaxImgLength">
<file name="HTMLPurifier/HTMLModule/Image.php"> <file name="HTMLPurifier/HTMLModule/Image.php">
<line>14</line> <line>21</line>
</file> </file>
<file name="HTMLPurifier/HTMLModule/SafeEmbed.php"> <file name="HTMLPurifier/HTMLModule/SafeEmbed.php">
<line>13</line> <line>18</line>
</file> </file>
<file name="HTMLPurifier/HTMLModule/SafeObject.php"> <file name="HTMLPurifier/HTMLModule/SafeObject.php">
<line>19</line> <line>24</line>
</file> </file>
</directive> </directive>
<directive id="HTML.TidyLevel"> <directive id="HTML.TidyLevel">
<file name="HTMLPurifier/HTMLModule/Tidy.php"> <file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>45</line> <line>50</line>
</file> </file>
</directive> </directive>
<directive id="HTML.TidyAdd"> <directive id="HTML.TidyAdd">
<file name="HTMLPurifier/HTMLModule/Tidy.php"> <file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>49</line> <line>54</line>
</file> </file>
</directive> </directive>
<directive id="HTML.TidyRemove"> <directive id="HTML.TidyRemove">
<file name="HTMLPurifier/HTMLModule/Tidy.php"> <file name="HTMLPurifier/HTMLModule/Tidy.php">
<line>50</line> <line>55</line>
</file> </file>
</directive> </directive>
<directive id="AutoFormat.PurifierLinkify.DocURL"> <directive id="AutoFormat.PurifierLinkify.DocURL">
<file name="HTMLPurifier/Injector/PurifierLinkify.php"> <file name="HTMLPurifier/Injector/PurifierLinkify.php">
<line>15</line> <line>31</line>
</file> </file>
</directive> </directive>
<directive id="AutoFormat.RemoveEmpty.RemoveNbsp"> <directive id="AutoFormat.RemoveEmpty.RemoveNbsp">
<file name="HTMLPurifier/Injector/RemoveEmpty.php"> <file name="HTMLPurifier/Injector/RemoveEmpty.php">
<line>15</line> <line>46</line>
</file> </file>
</directive> </directive>
<directive id="AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions"> <directive id="AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions">
<file name="HTMLPurifier/Injector/RemoveEmpty.php"> <file name="HTMLPurifier/Injector/RemoveEmpty.php">
<line>16</line> <line>47</line>
</file> </file>
</directive> </directive>
<directive id="Core.AggressivelyFixLt"> <directive id="Core.AggressivelyFixLt">
<file name="HTMLPurifier/Lexer/DOMLex.php"> <file name="HTMLPurifier/Lexer/DOMLex.php">
<line>44</line> <line>54</line>
</file> </file>
</directive> </directive>
<directive id="Core.DirectLexLineNumberSyncInterval"> <directive id="Core.DirectLexLineNumberSyncInterval">
<file name="HTMLPurifier/Lexer/DirectLex.php"> <file name="HTMLPurifier/Lexer/DirectLex.php">
<line>70</line> <line>84</line>
</file> </file>
</directive> </directive>
<directive id="Core.DisableExcludes"> <directive id="Core.DisableExcludes">
<file name="HTMLPurifier/Strategy/FixNesting.php"> <file name="HTMLPurifier/Strategy/FixNesting.php">
<line>57</line> <line>64</line>
</file> </file>
</directive> </directive>
<directive id="Core.EscapeInvalidTags"> <directive id="Core.EscapeInvalidTags">
<file name="HTMLPurifier/Strategy/MakeWellFormed.php"> <file name="HTMLPurifier/Strategy/MakeWellFormed.php">
<line>53</line> <line>66</line>
</file> </file>
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>19</line> <line>26</line>
</file> </file>
</directive> </directive>
<directive id="HTML.AllowedComments"> <directive id="HTML.AllowedComments">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>24</line> <line>31</line>
</file> </file>
</directive> </directive>
<directive id="HTML.AllowedCommentsRegexp"> <directive id="HTML.AllowedCommentsRegexp">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>25</line> <line>32</line>
</file> </file>
</directive> </directive>
<directive id="Core.RemoveScriptContents"> <directive id="Core.RemoveScriptContents">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>28</line> <line>35</line>
</file> </file>
</directive> </directive>
<directive id="Core.HiddenElements"> <directive id="Core.HiddenElements">
<file name="HTMLPurifier/Strategy/RemoveForeignElements.php"> <file name="HTMLPurifier/Strategy/RemoveForeignElements.php">
<line>29</line> <line>36</line>
</file> </file>
</directive> </directive>
<directive id="URI.HostBlacklist"> <directive id="URI.HostBlacklist">
<file name="HTMLPurifier/URIFilter/HostBlacklist.php"> <file name="HTMLPurifier/URIFilter/HostBlacklist.php">
<line>12</line> <line>25</line>
</file> </file>
</directive> </directive>
<directive id="URI.MungeResources"> <directive id="URI.MungeResources">
<file name="HTMLPurifier/URIFilter/Munge.php"> <file name="HTMLPurifier/URIFilter/Munge.php">
<line>14</line> <line>48</line>
</file> </file>
</directive> </directive>
<directive id="URI.MungeSecretKey"> <directive id="URI.MungeSecretKey">
<file name="HTMLPurifier/URIFilter/Munge.php"> <file name="HTMLPurifier/URIFilter/Munge.php">
<line>15</line> <line>49</line>
</file> </file>
</directive> </directive>
<directive id="URI.SafeIframeRegexp"> <directive id="URI.SafeIframeRegexp">
<file name="HTMLPurifier/URIFilter/SafeIframe.php"> <file name="HTMLPurifier/URIFilter/SafeIframe.php">
<line>18</line> <line>35</line>
</file> </file>
</directive> </directive>
</usage> </usage>

View File

@ -57,6 +57,7 @@ require 'HTMLPurifier/Lexer.php';
require 'HTMLPurifier/PercentEncoder.php'; require 'HTMLPurifier/PercentEncoder.php';
require 'HTMLPurifier/PropertyList.php'; require 'HTMLPurifier/PropertyList.php';
require 'HTMLPurifier/PropertyListIterator.php'; require 'HTMLPurifier/PropertyListIterator.php';
require 'HTMLPurifier/Queue.php';
require 'HTMLPurifier/Strategy.php'; require 'HTMLPurifier/Strategy.php';
require 'HTMLPurifier/StringHash.php'; require 'HTMLPurifier/StringHash.php';
require 'HTMLPurifier/StringHashParser.php'; require 'HTMLPurifier/StringHashParser.php';

View File

@ -51,6 +51,7 @@ require_once $__dir . '/HTMLPurifier/Lexer.php';
require_once $__dir . '/HTMLPurifier/PercentEncoder.php'; require_once $__dir . '/HTMLPurifier/PercentEncoder.php';
require_once $__dir . '/HTMLPurifier/PropertyList.php'; require_once $__dir . '/HTMLPurifier/PropertyList.php';
require_once $__dir . '/HTMLPurifier/PropertyListIterator.php'; require_once $__dir . '/HTMLPurifier/PropertyListIterator.php';
require_once $__dir . '/HTMLPurifier/Queue.php';
require_once $__dir . '/HTMLPurifier/Strategy.php'; require_once $__dir . '/HTMLPurifier/Strategy.php';
require_once $__dir . '/HTMLPurifier/StringHash.php'; require_once $__dir . '/HTMLPurifier/StringHash.php';
require_once $__dir . '/HTMLPurifier/StringHashParser.php'; require_once $__dir . '/HTMLPurifier/StringHashParser.php';

View File

@ -92,11 +92,11 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
protected function tokenizeDOM($node, &$tokens) protected function tokenizeDOM($node, &$tokens)
{ {
$level = 0; $level = 0;
$nodes = array($level => array($node)); $nodes = array($level => new HTMLPurifier_Queue(array($node)));
$closingNodes = array(); $closingNodes = array();
do { do {
while (!empty($nodes[$level])) { while (!$nodes[$level]->isEmpty()) {
$node = array_shift($nodes[$level]); // FIFO $node = $nodes[$level]->shift(); // FIFO
$collect = $level > 0 ? true : false; $collect = $level > 0 ? true : false;
$needEndingTag = $this->createStartNode($node, $tokens, $collect); $needEndingTag = $this->createStartNode($node, $tokens, $collect);
if ($needEndingTag) { if ($needEndingTag) {
@ -104,9 +104,9 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
} }
if ($node->childNodes && $node->childNodes->length) { if ($node->childNodes && $node->childNodes->length) {
$level++; $level++;
$nodes[$level] = array(); $nodes[$level] = new HTMLPurifier_Queue();
foreach ($node->childNodes as $childNode) { foreach ($node->childNodes as $childNode) {
array_push($nodes[$level], $childNode); $nodes[$level]->push($childNode);
} }
} }
} }

View File

@ -0,0 +1,56 @@
<?php
/**
* A simple array-backed queue, based off of the classic Okasaki
* persistent amortized queue. The basic idea is to maintain two
* stacks: an input stack and an output stack. When the output
* stack runs out, reverse the input stack and use it as the output
* stack.
*
* We don't use the SPL implementation because it's only supported
* on PHP 5.3 and later.
*
* Exercise: Prove that push/pop on this queue take amortized O(1) time.
*
* Exercise: Extend this queue to be a deque, while preserving amortized
* O(1) time. Some care must be taken on rebalancing to avoid quadratic
* behaviour caused by repeatedly shuffling data from the input stack
* to the output stack and back.
*/
class HTMLPurifier_Queue {
private $input;
private $output;
public function __construct($input = array()) {
$this->input = $input;
$this->output = array();
}
/**
* Shifts an element off the front of the queue.
*/
public function shift() {
if (empty($this->output)) {
$this->output = array_reverse($this->input);
$this->input = array();
}
if (empty($this->output)) {
return NULL;
}
return array_pop($this->output);
}
/**
* Pushes an element onto the front of the queue.
*/
public function push($x) {
array_push($this->input, $x);
}
/**
* Checks if it's empty.
*/
public function isEmpty() {
return empty($this->input) && empty($this->output);
}
}