/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. *
*/
HtmlWriter aHtml(aStream);
aHtml.prettyPrint(false);
aHtml.start("abc"_ostr);
aHtml.characters("hello");
aHtml.end();
aHtml.characters(" "); // Should not try to close a not opened tag
aHtml.start("abc"_ostr);
aHtml.characters("world"); // Should close opening tag
aHtml.end();
CPPUNIT_TEST_FIXTURE(Test, testAttributeValueEncode)
{ // Given a HTML writer:
SvMemoryStream aStream;
HtmlWriter aHtml(aStream);
aHtml.prettyPrint(false);
// When writing an attribute with a value that needs encoding:
aHtml.start("element"_ostr);
aHtml.attribute("attribute", "a&b");
aHtml.end();
// Then make sure that the encoding is performed:
OString aString = extractFromStream(aStream); // Without the accompanying fix in place, this test would have failed with: // - Expected: <element attribute="a&b"/> // - Actual : <element attribute="a&b"/> // i.e. attribute value was not encoded in HTML, but it was in e.g. XML.
CPPUNIT_ASSERT_EQUAL("a&b\"/>"_ostr, aString);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.