Mattermost-server: Pasting code from GitHub results in broken markup and loss of text

Created on 19 Nov 2019  路  5Comments  路  Source: mattermost/mattermost-server

Summary

In Mattermost 5.14 and up till latest version pasting a code from Github results in a somehow broken formatting. Go to any repo in Github, copy and paste code (not from raw file, but via normal github code viewer) into Mattermost new message field, in web client and you will see it.

Steps to reproduce

5.16.3

For example, go here https://github.com/containers/libpod/blob/master/contrib/imgts/lib_entrypoint.sh#L24 and copy lines 24 to 34. The paste it into new message field.

Expected behavior

I expect this:

image

(Note I had to copy code, paste it into my text editor, copy again and paste to Mattermost to make this screenshot).

Observed behavior (that appears unintentional)

But instead pasting results in this:

image

Possible fixes

No idea! :)

Bug ReporScheduled for Release

Most helpful comment

All 5 comments

I confirm the issue with latest mattermost build: pasting the code from GitHub repo into a chat message adds all extra markup chars like line breaks, tabs etc and looks like this:

|// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.|
|---|
|聽 | // See License.txt for license information.|
|聽 | 聽|
|聽 | package app|

the code example is taken from mattermost server repo https://github.com/mattermost/mattermost-server/blob/master/app/app.go#L1

it would be nice to have clean markup instead like this:

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

@hmhealey Do you know if this is related to https://mattermost.atlassian.net/browse/MM-10003 or is a separate issue?

No, that ticket would only affect Markdown after it's posted.

It looks like the code that handles pasting data from Excel is broken because the pasted text is being turned into a table. That feature was added back in January, so it may have been broken since back then (https://github.com/mattermost/mattermost-webapp/pull/2246), but the code for it was updated early in October as well (https://github.com/mattermost/mattermost-webapp/pull/3812).

This is fixed for upcoming v5.20 release,

Was this page helpful?
0 / 5 - 0 ratings