-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(serenity-bdd): escape HTML tags in scenaio name and title
Older versions of Serenity BDD don't escape HTML tags in scenario name and title. This can lead to reports getting truncated when a valid HTML tag, like `\<title /\>`, is used in scenario name. This change ensures that Serenity/JS escapes HTML tags it Serenity BDD json reports it produces. Related tickets: closes #1630
- Loading branch information
Showing
5 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/processors/mappers/escapeHtml.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @package | ||
* @param text | ||
*/ | ||
export function escapeHtml(text: string): string { | ||
const replacements = { | ||
'&': '&', | ||
'"': '"', | ||
'\'': ''', | ||
'<': '<', | ||
'>': '>' | ||
}; | ||
|
||
return text.replace( /["&'<>]/g, character => replacements[character] ); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/processors/mappers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './dashify'; | ||
export * from './errorReportFrom'; | ||
export * from './escapeHtml'; | ||
export * from './outcomeReportFrom'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters