logo

etc_portage

Unnamed repository; edit this file 'description' to name the repository. git clone https://hacktivis.me/git/etc_portage.git

0007-escape-HTML-in-paths.patch (1940B)


  1. From 028c7526bac907c91ef8afc6c3ae0f6d424bd229 Mon Sep 17 00:00:00 2001
  2. From: Hiltjo Posthuma <hiltjo@codemadness.org>
  3. Date: Sat, 16 Mar 2019 13:07:58 +0100
  4. Subject: [PATCH 07/22] escape HTML in paths
  5. - escape paths in diff line.
  6. - escape path in anchor href attribute in files.html
  7. ---
  8. stagit.c | 16 ++++++++++++----
  9. 1 file changed, 12 insertions(+), 4 deletions(-)
  10. diff --git a/stagit.c b/stagit.c
  11. index 1fc6c1e..a6cfebc 100644
  12. --- a/stagit.c
  13. +++ b/stagit.c
  14. @@ -532,9 +532,15 @@ printshowfile(FILE *fp, struct commitinfo *ci)
  15. for (i = 0; i < ci->ndeltas; i++) {
  16. patch = ci->deltas[i]->patch;
  17. delta = git_patch_get_delta(patch);
  18. - fprintf(fp, "<b>diff --git a/<a id=\"h%zu\" href=\"%sfile/%s.html\">%s</a> b/<a href=\"%sfile/%s.html\">%s</a></b>\n",
  19. - i, relpath, delta->old_file.path, delta->old_file.path,
  20. - relpath, delta->new_file.path, delta->new_file.path);
  21. + fprintf(fp, "<b>diff --git a/<a id=\"h%zu\" href=\"%sfile/", i, relpath);
  22. + xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path));
  23. + fputs(".html\">", fp);
  24. + xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path));
  25. + fprintf(fp, "</a> b/<a href=\"%sfile/", relpath);
  26. + xmlencode(fp, delta->new_file.path, strlen(delta->new_file.path));
  27. + fprintf(fp, ".html\">");
  28. + xmlencode(fp, delta->new_file.path, strlen(delta->new_file.path));
  29. + fprintf(fp, "</a></b>\n");
  30. /* check binary data */
  31. if (delta->flags & GIT_DIFF_FLAG_BINARY) {
  32. @@ -881,7 +887,9 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
  33. fputs("<tr><td>", fp);
  34. fputs(filemode(git_tree_entry_filemode(entry)), fp);
  35. - fprintf(fp, "</td><td><a href=\"%s%s\">", relpath, filepath);
  36. + fprintf(fp, "</td><td><a href=\"%s", relpath);
  37. + xmlencode(fp, filepath, strlen(filepath));
  38. + fputs("\">", fp);
  39. xmlencode(fp, entrypath, strlen(entrypath));
  40. fputs("</a></td><td class=\"num\" align=\"right\">", fp);
  41. if (lc > 0)
  42. --
  43. 2.26.2