You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: tests/PhpWord/Writer/HTMLTest.php
+22
Original file line number
Diff line number
Diff line change
@@ -147,6 +147,28 @@ public function testSave()
147
147
unlink($file);
148
148
}
149
149
150
+
publicfunctiontestEscaping()
151
+
{
152
+
$file = __DIR__ . '/../_files/temp.html';
153
+
154
+
$phpWord = newPhpWord();
155
+
Settings::setOutputEscapingEnabled(true);
156
+
157
+
$docProps = $phpWord->getDocInfo();
158
+
$docProps->setTitle('"Test" & <hack>');
159
+
160
+
$writer = newHTML($phpWord);
161
+
162
+
$writer->save($file);
163
+
$this->assertFileExists($file);
164
+
$html = file_get_contents($file);
165
+
166
+
$this->assertInternalType('int', strpos($html, '<title>"Test" & <hack></title>'), 'Quotes, ampersand, and tag should be escaped in title value');
167
+
$this->assertInternalType('int', strpos($html, '<meta name="title" content=""Test" & <hack>" />'), 'Quotes, ampersand, and tag should be escaped in attribute');
0 commit comments