diff --git a/webapp/components/channel_header.jsx b/webapp/components/channel_header.jsx index 65c856b4a2..6cecc04bda 100644 --- a/webapp/components/channel_header.jsx +++ b/webapp/components/channel_header.jsx @@ -581,9 +581,9 @@ export default class ChannelHeader extends React.Component { ref='headerOverlay' >
diff --git a/webapp/components/message_wrapper.jsx b/webapp/components/message_wrapper.jsx index 5e9939efaa..4dba1024ee 100644 --- a/webapp/components/message_wrapper.jsx +++ b/webapp/components/message_wrapper.jsx @@ -2,6 +2,7 @@ // See License.txt for license information. import * as TextFormatting from 'utils/text_formatting.jsx'; +import * as Utils from 'utils/utils.jsx'; import React from 'react'; @@ -10,9 +11,19 @@ export default class MessageWrapper extends React.Component { super(props); this.state = {}; } + render() { if (this.props.message) { - return ; + const options = Object.assign({}, this.props.options, { + siteURL: Utils.getSiteURL() + }); + + return ( + + ); } return ; diff --git a/webapp/components/post_view/components/post.jsx b/webapp/components/post_view/components/post.jsx index 1b94f717de..e9019bf38b 100644 --- a/webapp/components/post_view/components/post.jsx +++ b/webapp/components/post_view/components/post.jsx @@ -114,10 +114,6 @@ export default class Post extends React.Component { return true; } - if (nextProps.emojis !== this.props.emojis) { - return true; - } - if (nextState.dropdownOpened !== this.state.dropdownOpened) { return true; } @@ -259,7 +255,6 @@ export default class Post extends React.Component { handleCommentClick={this.handleCommentClick} compactDisplay={this.props.compactDisplay} previewCollapsed={this.props.previewCollapsed} - emojis={this.props.emojis} /> @@ -279,7 +274,6 @@ Post.propTypes = { isLastComment: React.PropTypes.bool, shouldHighlight: React.PropTypes.bool, displayNameType: React.PropTypes.string, - hasProfiles: React.PropTypes.bool, currentUser: React.PropTypes.object.isRequired, center: React.PropTypes.bool, compactDisplay: React.PropTypes.bool, @@ -287,7 +281,6 @@ Post.propTypes = { commentCount: React.PropTypes.number, isCommentMention: React.PropTypes.bool, useMilitaryTime: React.PropTypes.bool.isRequired, - emojis: React.PropTypes.object.isRequired, isFlagged: React.PropTypes.bool, status: React.PropTypes.string }; diff --git a/webapp/components/post_view/components/post_body.jsx b/webapp/components/post_view/components/post_body.jsx index 348e7fc93e..8c3b3009fc 100644 --- a/webapp/components/post_view/components/post_body.jsx +++ b/webapp/components/post_view/components/post_body.jsx @@ -6,8 +6,8 @@ import UserStore from 'stores/user_store.jsx'; import * as Utils from 'utils/utils.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; import Constants from 'utils/constants.jsx'; -import * as TextFormatting from 'utils/text_formatting.jsx'; import PostBodyAdditionalContent from './post_body_additional_content.jsx'; +import PostMessageContainer from './post_message_container.jsx'; import PendingPostOptions from './pending_post_options.jsx'; import {FormattedMessage} from 'react-intl'; @@ -43,10 +43,6 @@ export default class PostBody extends React.Component { return true; } - if (nextProps.emojis !== this.props.emojis) { - return true; - } - return false; } @@ -165,10 +161,7 @@ export default class PostBody extends React.Component { ); } else { message = ( - +example.com
' + ); + + assert.equal( + Markdown.format('readme.md').trim(), + 'readme.md
' + ); + + assert.equal( + Markdown.format('@example.com').trim(), + '@example.com
' + ); + + assert.equal( + Markdown.format('./make-compiled-client.sh').trim(), + './make-compiled-client.sh
' + ); + + assert.equal( + Markdown.format('test.:test').trim(), + 'test.:test
' + ); + + assert.equal( + Markdown.format('`https://example.com`').trim(), + '' +
+ '' +
+ '' +
+ 'https://example.com' +
+ '' +
+ '' +
+ '
[link](example.com
' + ); + + done(); + }); + + it('External links', function(done) { + assert.equal( + Markdown.format('http://example.com').trim(), + '' + ); + + assert.equal( + Markdown.format('https://example.com').trim(), + '' + ); + + assert.equal( + Markdown.format('www.example.com').trim(), + '' + ); + + assert.equal( + Markdown.format('www.example.com/index').trim(), + '' + ); + + assert.equal( + Markdown.format('www.example.com/index.html').trim(), + '' + ); + + assert.equal( + Markdown.format('www.example.com/index/sub').trim(), + '' + ); + + assert.equal( + Markdown.format('www1.example.com').trim(), + '' + ); + + assert.equal( + Markdown.format('example.com/index').trim(), + '' + ); + + done(); + }); + + it('IP addresses', function(done) { + assert.equal( + Markdown.format('http://127.0.0.1').trim(), + '' + ); + + assert.equal( + Markdown.format('http://192.168.1.1:4040').trim(), + '' + ); + + assert.equal( + Markdown.format('http://[::1]:80').trim(), + '' + ); + + assert.equal( + Markdown.format('http://[::1]:8065').trim(), + '' + ); + + assert.equal( + Markdown.format('https://[::1]:80').trim(), + '' + ); + + assert.equal( + Markdown.format('http://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:80').trim(), + 'http://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:80
' + ); + + assert.equal( + Markdown.format('http://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:8065').trim(), + 'http://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:8065
' + ); + + assert.equal( + Markdown.format('https://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:443').trim(), + 'https://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:443
' + ); + + assert.equal( + Markdown.format('http://username:password@127.0.0.1').trim(), + 'http://username:password@127.0.0.1
' + ); + + assert.equal( + Markdown.format('http://username:password@[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:80').trim(), + 'http://username:password@[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:80
' + ); + + done(); + }); + + it('Links with anchors', function(done) { + assert.equal( + Markdown.format('https://en.wikipedia.org/wiki/URLs#Syntax').trim(), + 'https://en.wikipedia.org/wiki/URLs#Syntax
' + ); + + assert.equal( + Markdown.format('https://groups.google.com/forum/#!msg').trim(), + 'https://groups.google.com/forum/#!msg
' + ); + + done(); + }); + + it('Links with parameters', function(done) { + assert.equal( + Markdown.format('www.example.com/index?params=1').trim(), + 'www.example.com/index?params=1
' + ); + + assert.equal( + Markdown.format('www.example.com/index?params=1&other=2').trim(), + 'www.example.com/index?params=1&other=2
' + ); + + assert.equal( + Markdown.format('www.example.com/index?params=1;other=2').trim(), + 'www.example.com/index?params=1;other=2
' + ); + + assert.equal( + Markdown.format('http://example.com:8065').trim(), + '' + ); + + assert.equal( + Markdown.format('http://username:password@example.com').trim(), + 'http://username:password@example.com
' + ); + + done(); + }); + + it('Special characters', function(done) { + assert.equal( + Markdown.format('http://www.example.com/_/page').trim(), + '' + ); + + assert.equal( + Markdown.format('www.example.com/_/page').trim(), + '' + ); + + assert.equal( + Markdown.format('https://en.wikipedia.org/wiki/🐬').trim(), + 'https://en.wikipedia.org/wiki/🐬
' + ); + + assert.equal( + Markdown.format('http://✪df.ws/1234').trim(), + '' + ); + + done(); + }); + + it('Brackets', function(done) { + assert.equal( + Markdown.format('https://en.wikipedia.org/wiki/Rendering_(computer_graphics)').trim(), + 'https://en.wikipedia.org/wiki/Rendering_(computer_graphics)
' + ); + + assert.equal( + Markdown.format('http://example.com/more_(than)_one_(parens)').trim(), + 'http://example.com/more_(than)_one_(parens)
' + ); + + assert.equal( + Markdown.format('http://example.com/(something)?after=parens').trim(), + 'http://example.com/(something)?after=parens
' + ); + + assert.equal( + Markdown.format('http://foo.com/unicode_(✪)_in_parens').trim(), + 'http://foo.com/unicode_(✪)_in_parens
' + ); + + done(); + }); + + it('Email addresses', function(done) { + assert.equal( + Markdown.format('test@example.com').trim(), + '' + ); + assert.equal( + Markdown.format('test_underscore@example.com').trim(), + '' + ); + + assert.equal( + Markdown.format('mailto:test@example.com').trim(), + '' + ); + + done(); + }); + + it('Formatted links', function(done) { + assert.equal( + Markdown.format('*https://example.com*').trim(), + '' + ); + + assert.equal( + Markdown.format('_https://example.com_').trim(), + '' + ); + + assert.equal( + Markdown.format('**https://example.com**').trim(), + '' + ); + + assert.equal( + Markdown.format('__https://example.com__').trim(), + '' + ); + + assert.equal( + Markdown.format('***https://example.com***').trim(), + '' + ); + + assert.equal( + Markdown.format('___https://example.com___').trim(), + '' + ); + + assert.equal( + Markdown.format('https://en.wikipedia.org/wiki/Rendering_(computer_graphics)
' + ); + + done(); + }); + + it('Links with text', function(done) { + assert.equal( + Markdown.format('[example link](example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('[example.com](example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('[example.com/other](example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('[example.com/other_link](example.com/example)').trim(), + '' + ); + + assert.equal( + Markdown.format('[link with spaces](example.com/ spaces in the url)').trim(), + '' + ); + + assert.equal( + Markdown.format('[This whole #sentence should be a link](https://example.com)').trim(), + 'This whole #sentence should be a link
' + ); + + assert.equal( + Markdown.format('[email link](mailto:test@example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('[other link](ts3server://example.com)').trim(), + '' + ); + + done(); + }); + + it('Links with tooltips', function(done) { + assert.equal( + Markdown.format('[link](example.com "catch phrase!")').trim(), + '' + ); + + assert.equal( + Markdown.format('[link](example.com "title with "quotes"")').trim(), + '' + ); + assert.equal( + Markdown.format('[link with spaces](example.com/ spaces in the url "and a title")').trim(), + '' + ); + + done(); + }); + + it('Links with surrounding text', function(done) { + assert.equal( + Markdown.format('This is a sentence with a http://example.com in it.').trim(), + 'This is a sentence with a http://example.com in it.
' + ); + + assert.equal( + Markdown.format('This is a sentence with a http://example.com/_/underscore in it.').trim(), + 'This is a sentence with a http://example.com/_/underscore in it.
' + ); + + assert.equal( + Markdown.format('This is a sentence with a http://192.168.1.1:4040 in it.').trim(), + 'This is a sentence with a http://192.168.1.1:4040 in it.
' + ); + + assert.equal( + Markdown.format('This is a sentence with a https://[::1]:80 in it.').trim(), + 'This is a sentence with a https://[::1]:80 in it.
' + ); + + done(); + }); + + it('Links with trailing punctuation', function(done) { + assert.equal( + Markdown.format('This is a link to http://example.com.').trim(), + 'This is a link to http://example.com.
' + ); + + assert.equal( + Markdown.format('This is a link containing http://example.com/something?with,commas,in,url, but not at the end').trim(), + 'This is a link containing http://example.com/something?with,commas,in,url, but not at the end
' + ); + + assert.equal( + Markdown.format('This is a question about a link http://example.com?').trim(), + 'This is a question about a link http://example.com?
' + ); + + done(); + }); + + it('Links with surrounding brackets', function(done) { + assert.equal( + Markdown.format('(http://example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('(see http://example.com)').trim(), + '(see http://example.com)
' + ); + + assert.equal( + Markdown.format('(http://example.com watch this)').trim(), + '(http://example.com watch this)
' + ); + + assert.equal( + Markdown.format('(www.example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('(see www.example.com)').trim(), + '(see www.example.com)
' + ); + + assert.equal( + Markdown.format('(www.example.com watch this)').trim(), + '(www.example.com watch this)
' + ); + assert.equal( + Markdown.format('([link](http://example.com))').trim(), + '(link)
' + ); + + assert.equal( + Markdown.format('(see [link](http://example.com))').trim(), + '(see link)
' + ); + + assert.equal( + Markdown.format('([link](http://example.com) watch this)').trim(), + '(link watch this)
' + ); + + assert.equal( + Markdown.format('(test@example.com)').trim(), + '' + ); + + assert.equal( + Markdown.format('(email test@example.com)').trim(), + '(email test@example.com)
' + ); + + assert.equal( + Markdown.format('(test@example.com email)').trim(), + '(test@example.com email)
' + ); + + assert.equal( + Markdown.format('This is a sentence with a [link](http://example.com) in it.').trim(), + 'This is a sentence with a link in it.
' + ); + + assert.equal( + Markdown.format('This is a sentence with a link (http://example.com) in it.').trim(), + 'This is a sentence with a link (http://example.com) in it.
' + ); + + assert.equal( + Markdown.format('This is a sentence with a (https://en.wikipedia.org/wiki/Rendering_(computer_graphics)) in it.').trim(), + 'This is a sentence with a (https://en.wikipedia.org/wiki/Rendering_(computer_graphics)) in it.
' + ); + + done(); + }); + + it('Searching for links', function(done) { + assert.equal( + TextFormatting.formatText('https://en.wikipedia.org/wiki/Unix', {searchTerm: 'wikipedia'}).trim(), + 'https:/