Skip to content

Commit

Permalink
Merge pull request #28 from gentlementlegen/fix/character-escaping
Browse files Browse the repository at this point in the history
fix: more characters are escaped (backtick, ampersand)
  • Loading branch information
gitcoindev authored Jun 3, 2024
2 parents ca12c26 + 550869c commit 10c7f78
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ export class GithubCommentModule implements Module {

function buildIncentiveRow(commentScore: GithubCommentScore) {
// Properly escape carriage returns for HTML rendering
const formatting = stringify(commentScore.score?.formatting?.content).replace(/[\n\r]/g, "
");
const formatting = stringify(commentScore.score?.formatting).replace(/[\n\r]/g, "
");
// Makes sure any HTML injected in the templated is not rendered itself
const sanitizedContent = commentScore.content.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
const sanitizedContent = commentScore.content
.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll("`", "&#96;");
return `
<tr>
<td>
Expand Down
Loading

1 comment on commit 10c7f78

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 78%
77.92% (360/462) 66.19% (139/210) 81.05% (77/95)

JUnit

Tests Skipped Failures Errors Time
23 0 💤 0 ❌ 0 🔥 8.327s ⏱️
Coverage Report (78%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files77.9266.1981.0578.12 
src75.928073.3377.88 
   get-authentication-token.ts100100100100 
   github-types.ts100100100100 
   index.ts251000256–10
   issue-activity.ts96.0781.811009646–47
   run.ts60751006023–29
   start.ts54.545057.146062–63, 100–118, 130
src/configuration83.335010082.6 
   comment-types.ts0000 
   config-reader.ts66.665010066.6612, 20–22
   constants.ts100100100100 
   content-evaluator-config.ts100100100100 
   data-purge-config.ts100100100100 
   formatting-evaluator-config.ts100100100100 
   github-comment-config.ts100100100100 
   incentives.ts100100100100 
   permit-generation-configuration.ts100100100100 
   user-extractor-config.ts100100100100 
src/data-collection83.3365.3810082.85 
   collect-linked-pulls.ts83.3365.3810082.8510, 19, 60–64
src/parser77.4364.1882.1477.14 
   content-evaluator-module.ts62.6845.4558.336023–24, 56–57, 75–112, 141–145
   data-purge-module.ts81.8190.910081.8115–16
   formatting-evaluator-module.ts92.56010092.374–75, 87
   github-comment-module.ts84.746510084.7439–50, 58–59, 68, 119
   permit-generation-module.ts6637.555.556650–51, 58–65, 107, 124–138, 144, 165–171, 178–179
   processor.ts91.6683.3310091.6634–35, 72
   user-extractor-module.ts7676.1983.337616–17, 34, 47, 49–50
src/types83.335010083.33 
   env-type.ts100100100100 
   payout.ts80501008018

Please sign in to comment.