Maintenance: Improve clipboard handling of website chat

This commit is contained in:
Thorsten Eckel 2021-09-03 10:43:45 +02:00
parent b1e8b3afae
commit b125b3603e
13 changed files with 414 additions and 350 deletions

View File

@ -0,0 +1,16 @@
FROM node:8-alpine
ENV GULP_DIR "/tmp/gulp"
RUN apk update && apk add bash
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
CMD bash # If you want to override CMD
RUN npm install -g gulp
COPY docker-entrypoint.sh /
# enable volume to generate build files into the hosts FS
VOLUME ["$GULP_DIR"]
# start
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -0,0 +1,5 @@
# Zammad Chat build
This folder contains a `docker` image and the required files to build the Zammad Chat from coffeescript and eco files. This workaround is required for now because of the outdated NodeJS 8 dependency.
The build process can easily be started by executing the `build.sh` file. There is nothing more to it except of having `docker` installed and running.

8
public/assets/chat/build.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -o errexit
set -o pipefail
docker build --no-cache -t zammad/chat-build:latest .
docker run --rm -v "$(pwd)/:/tmp/gulp" zammad/chat-build:latest

View File

@ -762,7 +762,11 @@ do(window) ->
console.log('p', docType, text)
if docType is 'html'
html = document.createElement('div')
html.innerHTML = text
# can't log because might contain malicious content
# @log.debug 'HTML clipboard', text
sanitized = DOMPurify.sanitize(text)
@log.debug 'sanitized HTML clipboard', sanitized
html.innerHTML = sanitized
match = false
htmlTmp = text
regex = new RegExp('<(/w|w)\:[A-Za-z]')

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -718,7 +718,9 @@ do($ = window.jQuery, window) ->
text = text.replace(/<div><\/div>/g, '<div><br></div>')
console.log('p', docType, text)
if docType is 'html'
html = $("<div>#{text}</div>")
sanitized = DOMPurify.sanitize(text)
@log.debug 'sanitized HTML clipboard', sanitized
html = $("<div>#{sanitized}</div>")
match = false
htmlTmp = text
regex = new RegExp('<(/w|w)\:[A-Za-z]')

View File

@ -314,6 +314,7 @@
line-height: 1.4em;
font-size: inherit;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
background: none;
@ -329,6 +330,7 @@
.zammad-chat-button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-family: inherit;
font-size: inherit;
@ -349,6 +351,7 @@
.zammad-chat-button:disabled,
.zammad-chat-input:disabled {
cursor: not-allowed;
opacity: 0.3; }
.zammad-chat-is-hidden {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
#!/bin/bash
cd "${GULP_DIR}" || exit
gulp js css no-jquery

View File

@ -25,11 +25,14 @@ gulp.task('js', function(){
var templates = gulp.src('views/*.eco')
.pipe(eco({namespace: 'zammadChatTemplates'}));
var purify = gulp.src('purify.min.js');
var js = gulp.src('chat.coffee')
.pipe(plumber())
.pipe(coffee({bare: true}).on('error', gutil.log));
return merge(templates, js)
.add(purify)
.pipe(concat('chat.js'))
.pipe(gulp.dest('./'))
.pipe(uglify())
@ -42,11 +45,14 @@ gulp.task('no-jquery', function(){
var templates = gulp.src('views/*.eco')
.pipe(eco({namespace: 'zammadChatTemplates'}));
var purify = gulp.src('purify.min.js');
var js = gulp.src('chat-no-jquery.coffee')
.pipe(plumber())
.pipe(coffee({bare: true}).on('error', gutil.log));
return merge(templates, js)
.add(purify)
.pipe(concat('chat-no-jquery.js'))
.pipe(gulp.dest('./'))
.pipe(uglify())

3
public/assets/chat/purify.min.js vendored Normal file

File diff suppressed because one or more lines are too long