git ssb

30+

cel / git-ssb-web



Commit 38f058f88ea3d8eb9e4f8ea5f16fb622289b3d88

Escape inner text of links by default

Charles Lehner committed on 3/26/2016, 6:42:07 PM
Parent: 0dcd8bc291330e6ea6c2e7fe6836238e1f68f702

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -15,8 +15,9 @@
1515 var asyncMemo = require('asyncmemo')
1616 var multicb = require('multicb')
1717 var schemas = require('ssb-msg-schemas')
1818 var Issues = require('ssb-issues')
19+var paramap = require('pull-paramap')
1920
2021 marked.setOptions({
2122 gfm: true,
2223 mentions: true,
@@ -39,12 +40,13 @@
3940 function flattenPath(parts) {
4041 return '/' + parts.map(encodeURIComponent).join('/')
4142 }
4243
43-function link(parts, html) {
44+function link(parts, text, raw) {
4445 var href = flattenPath(parts)
45- var innerHTML = html == null ? escapeHTML(parts[parts.length-1]) : html
46- return '<a href="' + escapeHTML(href) + '">' + innerHTML + '</a>'
46+ if (text == null) text = parts[parts.length-1]
47+ if (!raw) text = escapeHTML(text)
48+ return '<a href="' + escapeHTML(href) + '">' + text + '</a>'
4749 }
4850
4951 function timestamp(time) {
5052 time = Number(time)
@@ -716,9 +718,9 @@
716718 if (err) return cb(err)
717719 var commitPath = [repo.id, 'commit', commit.id]
718720 var treePath = [repo.id, 'tree', commit.id]
719721 cb(null, '<section class="collapse">' +
720- '<strong>' + link(commitPath, escapeHTML(commit.title)) + '</strong><br>' +
722+ '<strong>' + link(commitPath, commit.title) + '</strong><br>' +
721723 '<code>' + commit.id + '</code> ' +
722724 link(treePath, 'Tree') + '<br>' +
723725 (commit.separateAuthor ? escapeHTML(commit.author.name) + ' authored on ' + commit.author.date.toLocaleString() + '<br>' : '') +
724726 escapeHTML(commit.committer.name) + ' committed on ' + commit.committer.date.toLocaleString() +
@@ -766,9 +768,9 @@
766768 repo.getCommitParsed(rev, function (err, commit) {
767769 if (err) return cb(err)
768770 var commitPath = [repo.id, 'commit', commit.id]
769771 cb(null,
770- 'Latest: <strong>' + link(commitPath, escapeHTML(commit.title)) +
772+ 'Latest: <strong>' + link(commitPath, commit.title) +
771773 '</strong><br>' +
772774 '<code>' + commit.id + '</code><br> ' +
773775 escapeHTML(commit.committer.name) + ' committed on ' +
774776 commit.committer.date.toLocaleString() +
@@ -859,9 +861,9 @@
859861 if (err) return cb(err)
860862 var commitPath = [repo.id, 'commit', commit.id]
861863 var treePath = [repo.id, 'tree', commit.tree]
862864 cb(null,
863- '<p><strong>' + link(commitPath, escapeHTML(commit.title)) +
865+ '<p><strong>' + link(commitPath, commit.title) +
864866 '</strong></p>' +
865867 pre(commit.body) +
866868 '<p>' +
867869 (commit.separateAuthor ? escapeHTML(commit.author.name) +
@@ -925,9 +927,9 @@
925927 }
926928
927929 function renderObject(obj) {
928930 return '<section class="collapse">' +
929- obj.type + ' ' + link([obj.link], escapeHTML(obj.sha1)) + '<br>' +
931+ obj.type + ' ' + link([obj.link], obj.sha1) + '<br>' +
930932 obj.length + ' bytes' +
931933 '</section>'
932934 }
933935
@@ -1051,9 +1053,9 @@
10511053 return renderRepoPage(repo, '', cat([
10521054 pull.once(
10531055 (isPublic ? '' :
10541056 '<div class="right-bar">' + link([repo.id, 'issues', 'new'],
1055- '<button>&plus; New Issue</button>') +
1057+ '<button>&plus; New Issue</button>', true) +
10561058 '</div>') +
10571059 '<h3>Issues</h3>'),
10581060 pull(
10591061 issues.createFeedStream({ project: repo.id }),
package.jsonView
@@ -7,8 +7,9 @@
77 "asyncmemo": "^0.1.0",
88 "multicb": "^1.2.1",
99 "pull-cat": "^1.1.8",
1010 "pull-git-repo": "^0.2.2",
11+ "pull-paramap": "^1.1.2",
1112 "pull-stream": "^3.1.0",
1213 "ssb-client": "^3.0.1",
1314 "ssb-config": "^1.1.0",
1415 "ssb-git-repo": "^1.4.0",

Built with git-ssb-web