From 73a7ad0dfb5dfe37ead860f091488165c79ff9a0 Mon Sep 17 00:00:00 2001 From: Miguel Rincon <mrincon@gitlab.com> Date: Tue, 20 Oct 2020 16:32:09 +0000 Subject: [PATCH] Revert "Merge branch '18324-clickable-links-in-logs' into 'master'" This reverts merge request !40175 --- .../javascripts/jobs/components/log/line.vue | 32 ++------- .../18324-add-links-to-urls-in-job-logs.yml | 5 -- package.json | 1 - .../frontend/jobs/components/log/line_spec.js | 65 ++++--------------- yarn.lock | 5 -- 5 files changed, 19 insertions(+), 89 deletions(-) delete mode 100644 changelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml diff --git a/app/assets/javascripts/jobs/components/log/line.vue b/app/assets/javascripts/jobs/components/log/line.vue index 791664c05d981..e68d5b8eda4da 100644 --- a/app/assets/javascripts/jobs/components/log/line.vue +++ b/app/assets/javascripts/jobs/components/log/line.vue @@ -1,24 +1,6 @@ <script> -import linkifyHtml from 'linkifyjs/html'; -import { sanitize } from '~/lib/dompurify'; -import { isAbsolute } from '~/lib/utils/url_utility'; import LineNumber from './line_number.vue'; -const linkifyOptions = { - attributes: { - // eslint-disable-next-line @gitlab/require-i18n-strings - rel: 'nofollow noopener', - }, - className: 'gl-reset-color!', - defaultProtocol: 'https', - validate: { - email: false, - url(value) { - return isAbsolute(value); - }, - }, -}; - export default { functional: true, props: { @@ -35,15 +17,13 @@ export default { const { line, path } = props; const chars = line.content.map(content => { - const linkfied = linkifyHtml(content.text, linkifyOptions); - return h('span', { - class: ['gl-white-space-pre-wrap', content.style], - domProps: { - innerHTML: sanitize(linkfied, { - ALLOWED_TAGS: ['a'], - }), + return h( + 'span', + { + class: ['gl-white-space-pre-wrap', content.style], }, - }); + content.text, + ); }); return h('div', { class: 'js-line log-line' }, [ diff --git a/changelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml b/changelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml deleted file mode 100644 index 884022e7f8693..0000000000000 --- a/changelogs/unreleased/18324-add-links-to-urls-in-job-logs.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Make URL links in job logs clickable -merge_request: 40175 -author: Åukasz Groszkowski @falxcerebri -type: added diff --git a/package.json b/package.json index 276b10f08191f..c10d9d7a0d12b 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,6 @@ "jszip": "^3.1.3", "jszip-utils": "^0.0.2", "katex": "^0.10.0", - "linkifyjs": "^2.1.9", "lodash": "^4.17.20", "marked": "^0.3.12", "mermaid": "^8.5.2", diff --git a/spec/frontend/jobs/components/log/line_spec.js b/spec/frontend/jobs/components/log/line_spec.js index 1a30921fece28..c2412a807c35c 100644 --- a/spec/frontend/jobs/components/log/line_spec.js +++ b/spec/frontend/jobs/components/log/line_spec.js @@ -2,25 +2,21 @@ import { shallowMount } from '@vue/test-utils'; import Line from '~/jobs/components/log/line.vue'; import LineNumber from '~/jobs/components/log/line_number.vue'; -const httpUrl = 'http://example.com'; -const httpsUrl = 'https://example.com'; - -const mockProps = ({ text = 'Running with gitlab-runner 12.1.0 (de7731dd)' } = {}) => ({ - line: { - content: [ - { - text, - style: 'term-fg-l-green', - }, - ], - lineNumber: 0, - }, - path: '/jashkenas/underscore/-/jobs/335', -}); - describe('Job Log Line', () => { let wrapper; - let data; + + const data = { + line: { + content: [ + { + text: 'Running with gitlab-runner 12.1.0 (de7731dd)', + style: 'term-fg-l-green', + }, + ], + lineNumber: 0, + }, + path: '/jashkenas/underscore/-/jobs/335', + }; const createComponent = (props = {}) => { wrapper = shallowMount(Line, { @@ -31,7 +27,6 @@ describe('Job Log Line', () => { }; beforeEach(() => { - data = mockProps(); createComponent(data); }); @@ -50,38 +45,4 @@ describe('Job Log Line', () => { it('renders the provided style as a class attribute', () => { expect(wrapper.find('span').classes()).toContain(data.line.content[0].style); }); - - describe('when the line contains a link', () => { - const findLink = () => wrapper.find('span a'); - - it('renders an http link', () => { - createComponent(mockProps({ text: httpUrl })); - - expect(findLink().text()).toBe(httpUrl); - expect(findLink().attributes().href).toEqual(httpUrl); - }); - - it('renders an https link', () => { - createComponent(mockProps({ text: httpsUrl })); - - expect(findLink().text()).toBe(httpsUrl); - expect(findLink().attributes().href).toEqual(httpsUrl); - }); - - it('renders a link with rel nofollow and noopener', () => { - createComponent(mockProps({ text: httpsUrl })); - - expect(findLink().attributes().rel).toBe('nofollow noopener'); - }); - - test.each` - type | text - ${'ftp'} | ${'ftp://example.com/file'} - ${'email'} | ${'email@example.com'} - ${'no scheme'} | ${'example.com/page'} - `('does not render a $type link', ({ text }) => { - createComponent(mockProps({ text })); - expect(findLink().exists()).toBe(false); - }); - }); }); diff --git a/yarn.lock b/yarn.lock index 714035006e6f6..f8f8709a50695 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7550,11 +7550,6 @@ linkify-it@^2.0.0: dependencies: uc.micro "^1.0.1" -linkifyjs@^2.1.9: - version "2.1.9" - resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-2.1.9.tgz#af06e45a2866ff06c4766582590d098a4d584702" - integrity sha512-74ivurkK6WHvHFozVaGtQWV38FzBwSTGNmJolEgFp7QgR2bl6ArUWlvT4GcHKbPe1z3nWYi+VUdDZk16zDOVug== - load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" -- GitLab