IE5/Mac whitespace parsing bug

The only style information in the stylesheet are the following two classes. All other elements should follow the browser defaults. In IE5/Mac, however, extra whitespace causes the wrong styles to be picked up if the actual class name is a substring (or superstring) of some other class name.

 .testylong {
  margin-left: 20px;
  margin-bottom:5px;
  border: 1px solid blue;
  color: #060;
  padding: 20px;
  background: #ccc;
}
.test {
  border: 1px solid red;
  color: #c09;
  background: #fdd;
 }
class="testylong" (green text on grey background, padding, margins, 1-pixel blue border).

The divs below incorrectly applies wrong selector css rules due to the trailing whitespace.

class="testy " (note trailing whitespace). This is incorrectly rendered the same as the class="testylong".
class=" testy" (note leading whitespace). This is incorrectly rendered using the styles of both classes testylong and test (red border, magenta text, pink background), since test was defined later in the stylesheet. Note that trailing whitespace causes IE to pick up styles where the actual class name is a substring of the incorrectly adopted style. With leading whitespace, styles of classes that are substrings of the actual class, are also picked up.
class="testy x" (multiple classes). This is incorrectly rendered the same as the class="testylong".
class="testy" (no whitespace). This is correctly rendered without styling.
class="test " (trailing whitespace). This is picks up its own styles (red border, magenta text, pink background) but also adopts the styles of class testylong (padding and margin-left).
CodeBitch
7 December 2002