File tree Expand file tree Collapse file tree
test/java/io/qameta/allure/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010<#-- @ftlvariable name="reportName" type="java.lang.String" -->
1111<#-- @ftlvariable name="reportLanguage" type="java.lang.String" -->
1212<!DOCTYPE html>
13- <html dir =" ltr" lang =" ${reportLanguage!" en " }" >
13+ <html dir =" ltr" lang =" ${( reportLanguage!" en " )?html }" >
1414<head >
1515 <meta charset =" utf-8" >
1616 <meta name =" allure-report-uuid" content =" ${reportUuid}" >
Original file line number Diff line number Diff line change @@ -104,6 +104,29 @@ void shouldEscapeHtmlInReportName(@TempDir final Path tempDirectory) {
104104 .doesNotContain (hostile );
105105 }
106106
107+ /**
108+ * Verifies that a hostile {@code reportLanguage} containing live HTML
109+ * cannot escape the {@code lang} attribute on the root {@code <html>} tag.
110+ */
111+ @ Description
112+ @ Test
113+ void shouldEscapeHtmlInReportLanguage (@ TempDir final Path tempDirectory ) {
114+ final String hostile = "en\" ><script>alert('xss')</script>" ;
115+ final Configuration configuration = ConfigurationBuilder .empty ()
116+ .withReportLanguage (hostile )
117+ .build ();
118+ final InMemoryReportStorage reportStorage = new InMemoryReportStorage ();
119+ generateReport (configuration , reportStorage , tempDirectory );
120+
121+ final Path indexHtml = tempDirectory .resolve ("index.html" );
122+
123+ assertThat (indexHtml )
124+ .isRegularFile ()
125+ .content (StandardCharsets .UTF_8 )
126+ .as ("hostile reportLanguage must not break out of the lang attribute" )
127+ .doesNotContain (hostile );
128+ }
129+
107130 /**
108131 * Verifies setting language for web report generation.
109132 */
You can’t perform that action at this time.
0 commit comments