-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Markdown support for app descriptions #1594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e7a2151
1e45357
587eca3
d26b902
1a7d713
fcfb420
4d7dee5
6a047a0
ddfc7e6
76bc3bc
aadfadf
6ba7ba6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Joas Schilling <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ Handlebars.registerHelper('level', function() { | |
|
|
||
| OC.Settings = OC.Settings || {}; | ||
| OC.Settings.Apps = OC.Settings.Apps || { | ||
| markedOptions: {}, | ||
|
|
||
| setupGroupsSelect: function($elements) { | ||
| OC.Settings.setupGroupsSelect($elements, { | ||
| placeholder: t('core', 'All') | ||
|
|
@@ -187,7 +189,7 @@ OC.Settings.Apps = OC.Settings.Apps || { | |
| } | ||
|
|
||
| // Parse markdown in app description | ||
| app.description = marked(app.description.trim()); | ||
| app.description = marked(app.description.trim(), OC.Settings.Apps.markedOptions); | ||
|
|
||
| var html = template(app); | ||
| if (selector) { | ||
|
|
@@ -636,6 +638,50 @@ OC.Settings.Apps = OC.Settings.Apps || { | |
| * Initializes the apps list | ||
| */ | ||
| initialize: function($el) { | ||
|
|
||
| var renderer = new marked.Renderer(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really happy with having that code in the "initialize" function. This means that if somebody somehow manages to bypass the sanitization opening the apps page would be enough to insert it into the DOM. IMO that should happen on clicking the "Show description" action.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Especially since markedjs/marked#592 is not really increasing my confidence in this library at all. |
||
| renderer.link = function(href, title, text) { | ||
| try { | ||
| var prot = decodeURIComponent(unescape(href)) | ||
| .replace(/[^\w:]/g, '') | ||
| .toLowerCase(); | ||
| } catch (e) { | ||
| return ''; | ||
| } | ||
|
|
||
| if (prot.indexOf('http:') !== 0 && prot.indexOf('https:') !== 0) { | ||
| return ''; | ||
| } | ||
|
|
||
| var out = '<a href="' + href + '"'; | ||
|
||
| if (title) { | ||
| out += ' title="' + title + '"'; | ||
| } | ||
| out += '>' + text + '</a>'; | ||
| return out; | ||
| }; | ||
| renderer.image = function(href, title, text) { | ||
| if (text) { | ||
| return text; | ||
| } | ||
| return title; | ||
| }; | ||
| renderer.blockquote = function(quote) { | ||
| return quote; | ||
| }; | ||
|
|
||
| OC.Settings.Apps.markedOptions = { | ||
| renderer: renderer, | ||
| gfm: false, | ||
| highlight: false, | ||
| tables: false, | ||
| breaks: false, | ||
| pedantic: false, | ||
| sanitize: true, | ||
| smartLists: true, | ||
| smartypants: false | ||
| }; | ||
|
|
||
| OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search); | ||
| OC.Settings.Apps.loadCategories(); | ||
| OC.Util.History.addOnPopStateHandler(_.bind(this._onPopState, this)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too confident in that myself. I'll also add https://github.com/cure53/DOMPurify as post-processing.