OWASP / PHP-ESAPI

Migrated from code.google.com to a more active public repository.
Other
65 stars 26 forks source link

Wrong encoder used for tests in EncoderTest #5

Open renaatdemuynck opened 9 years ago

renaatdemuynck commented 9 years ago

Canonicalization tests 108 through 125 (JavaScript & CSS) fail in EncoderTest because the wrong encoder is used. I verified this by putting a var_dump of the encoder instance in test 108:

  ["_codecs":"DefaultEncoder":private]=>
  array(2) {
    [0]=>
    object(HTMLEntityCodec)#2002 (0) {
    }
    [1]=>
    object(PercentCodec)#1973 (0) {
    }
  }

This clearly shows it uses the wrong codecs. This is because each assertion is being done in a separate test. Before each test setUp() is run which resets the encoder to the one needed for HTML tests.

There are at least four ways to solve this issue:

I tested the first option and it resolves all failed tests for JavaScript and CSS codecs.