geary/test/CMakeLists.txt
Michael James Gratton deb0c415d0 Fix HTML, CSS and JS leaking into conversation list preview. Bug 714317
When generating the preview, only the first 128 bytes of the first MIME
part is fetched and used. If this part is text/html with a significant
amount of embedded CSS, then there is a good chance the string passed to
Geary.HTML::remove_html_tags() will be invalid, or be missing closing
elements. Since that function uses regexes that require balanced tags to
remove script and style blocks, then it was very possible that in these
cases this method will miss removing these blocks.

To solve this, remove_html_tags() is removed and its call sites are
replaced by calls to Geary.HTML::html_to_text(), which has been tidyied
up to produce more human-readable result.

Add unit tests to cover new html_to_text functionality and its call
sites.

* src/engine/util/util-html.vala: Remove remove_html_tags(). Update
  html_to_text() to not just insert line breaks, but also insert spaces
  and alt text, and ignore tags like HEAD, SCRIPT and STYLE, as
  appropriate. Add an optional param to also allow skipping BLOCKQUOTE
  elements, which we don't want in the preview.
2016-12-19 00:45:41 +11:00

66 lines
1.4 KiB
CMake

# Geary build script
# Copyright 2016 Software Freedom Conservancy Inc.
# Copyright 2016 Michael Gratton <mike@vee.net>
set(TEST_SRC
main.vala
testcase.vala # Taken as-is from libgee, courtesy Julien Peeters
engine/rfc822-mailbox-address-test.vala
engine/rfc822-message-data-test.vala
engine/util-html-test.vala
)
# Vala
find_package(Vala REQUIRED)
include(ValaVersion)
include(ValaPrecompile)
pkg_check_modules(DEPS REQUIRED
gee-0.8
gio-2.0
glib-2.0
gmime-2.6
gthread-2.0
)
set(TEST_PACKAGES
glib-2.0 gio-2.0 gee-0.8 gmime-2.6 geary-static
)
set(CFLAGS
${DEPS_CFLAGS}
${DEPS_CFLAGS_OTHER}
-D_BUILD_ROOT_DIR=\"${CMAKE_BINARY_DIR}\"
-D_SOURCE_ROOT_DIR=\"${CMAKE_SOURCE_DIR}\"
)
include_directories(${CMAKE_BINARY_DIR}/src)
set(LIB_PATHS ${DEPS_LIBRARY_DIRS})
link_directories(${LIB_PATHS})
add_definitions(${CFLAGS})
set(VALAC_OPTIONS
--vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
--metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata
--target-glib=${TARGET_GLIB}
--thread
--debug
--enable-checking
--enable-deprecated
--fatal-warnings
${EXTRA_VALA_OPTIONS}
)
vala_precompile(TEST_VALA_C geary-test
${TEST_SRC}
PACKAGES
${TEST_PACKAGES}
OPTIONS
${VALAC_OPTIONS}
--vapidir=${CMAKE_BINARY_DIR}/src
)
add_executable(geary-test ${TEST_VALA_C})
target_link_libraries(geary-test ${DEPS_LIBRARIES} gthread-2.0 geary-static)