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 1414<head >
1515 <meta charset =" utf-8" >
1616 <meta name =" allure-report-uuid" content =" ${reportUuid}" >
17- <title >${reportName!"Allure Report" } </title >
17+ <title >${( reportName!"Allure Report")?html } </title >
1818 <link rel =" icon" href =" ${faviconUrl}" >
1919 <!-- allure-core-head:start -->
2020 <#list coreStyleUrls as styleUrl >
Original file line number Diff line number Diff line change @@ -81,6 +81,29 @@ void shouldDisableAnalytics(@TempDir final Path tempDirectory) {
8181 .doesNotContain ("dataLayer" );
8282 }
8383
84+ /**
85+ * Verifies that a hostile {@code reportName} containing live HTML / JS
86+ * is HTML-escaped rather than rendered raw into the {@code <title>} tag.
87+ */
88+ @ Description
89+ @ Test
90+ void shouldEscapeHtmlInReportName (@ TempDir final Path tempDirectory ) {
91+ final String hostile = "<script>alert('xss')</script>" ;
92+ final Configuration configuration = ConfigurationBuilder .empty ()
93+ .withReportName (hostile )
94+ .build ();
95+ final InMemoryReportStorage reportStorage = new InMemoryReportStorage ();
96+ generateReport (configuration , reportStorage , tempDirectory );
97+
98+ final Path indexHtml = tempDirectory .resolve ("index.html" );
99+
100+ assertThat (indexHtml )
101+ .isRegularFile ()
102+ .content (StandardCharsets .UTF_8 )
103+ .as ("hostile reportName must not appear as live HTML in the generated report" )
104+ .doesNotContain (hostile );
105+ }
106+
84107 /**
85108 * Verifies setting language for web report generation.
86109 */
You can’t perform that action at this time.
0 commit comments