Skip to content
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

Release 2.4.2 #1742

Merged
merged 58 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2453b2a
set lang attr on <html> according to user's choice
binotaliu Apr 10, 2020
bdd2de7
set default lang attr for note to 'en'
binotaliu Apr 10, 2020
9b899c7
escape attribute value for lang
binotaliu Apr 10, 2020
3df0903
Convert "include" directives to functions
Aug 22, 2020
0aff524
Make permission labels translatable.
Sep 1, 2020
66fdf7b
Make permission and status translatable
Sep 1, 2020
dec2f98
Make "Expand all" translatable
Sep 3, 2020
ffac645
Remove the semicolons
Sep 11, 2020
ac43db8
Fix matchInContainer false positives
tamo Sep 25, 2020
4002306
Update public/js/index.js
tamo May 12, 2021
ad1bfa6
Update public/js/index.js
tamo May 12, 2021
9343d32
Merge branch 'patch-1' of https://github.com/tamo/codimd into patch-1
May 13, 2021
5e70965
fix: handle when request url has no valid referer
jackycute May 13, 2021
db5fc50
fix: avoid append zero suffix on exporting user data
jackycute May 13, 2021
3af5408
Merge pull request #1680 from hackmdio/bugfix/fix-export-user-data-fi…
a60814billy May 13, 2021
54f6e55
Merge pull request #1679 from hackmdio/bugfix/fix-no-referrer-for-ret…
a60814billy May 13, 2021
a41c4db
fix: S3 client config passing for image upload
jackycute May 13, 2021
e9293b0
feat: add TeX mhchem extensions for MathJax
jackycute May 13, 2021
a913c61
feat: bump package-lock codimd version
jackycute May 18, 2021
b6837f1
feat: upgrade flowchart.js to version 1.15.0
jackycute May 18, 2021
599fd41
Merge pull request #1683 from hackmdio/bugfix/fix-image-upload-s3-config
a60814billy May 19, 2021
b27f147
Merge pull request #1684 from hackmdio/feature/support-mhchem-mathjax
a60814billy May 25, 2021
8c20d9f
Merge pull request #1685 from hackmdio/feature/upgrade-flowchart.js-1…
a60814billy May 25, 2021
2338113
chore: add dev container
a60814billy May 25, 2021
34f502c
Add test and build actions
Yukaii Jun 10, 2021
71dce28
Add doctoc check
Yukaii Jun 10, 2021
2432397
Fix doctoc workflow
Yukaii Jun 10, 2021
dcfdb01
Remove travis CI config
Yukaii Jun 10, 2021
282fcab
Merge pull request #1694 from hackmdio/chore/github-actions
a60814billy Jun 16, 2021
0280a2e
feat: implement CSRF token in export user data
a60814billy Jun 11, 2021
b8203ae
fix: profile dropdown should not set active class
a60814billy Jun 11, 2021
6966881
fix: strip html tags for gist id to avoid stored XSS on showing error…
jackycute Jun 2, 2021
2eefe77
fix: strip html tags for gist file, gist line, gist highlight line, g…
jackycute Jun 9, 2021
e75e28c
feat: upgrade mermaid to version 8.10.1
jackycute May 31, 2021
16a1e82
feat: upgrade mermaid to version 8.10.2
jackycute Jun 16, 2021
82b7800
Merge pull request #1691 from hackmdio/bugfix/fix-gist-id-stored-XSS
a60814billy Jun 16, 2021
e623b72
Merge pull request #1690 from hackmdio/feature/upgrade-mermaid-8.10.1
a60814billy Jun 16, 2021
1bdedf1
Merge pull request #1688 from hackmdio/chore/dev-container
jackycute Jun 16, 2021
9c280b0
Add support for arm64 build
YadominJinta Jul 5, 2021
6b8950d
Merge pull request #1481 from ghost/lang-attr
jackycute Jul 9, 2021
4b78202
Merge pull request #1605 from tamo/patch-1
jackycute Jul 9, 2021
620197f
Merge pull request #1580 from tamo/master
a60814billy Jul 9, 2021
e7a5ea8
Merge pull request #1587 from tamo/more-i18n
a60814billy Jul 9, 2021
3b1e270
Merge pull request #1701 from YadominJinta/develop
a60814billy Jul 9, 2021
b2e2743
fix: may referernce out of bound index in clearDuplicatedHistory
a60814billy Jul 31, 2021
80fc6bc
chore: upgrade codemirror to 5.61.3
Yukaii Sep 27, 2021
5db11d2
Merge pull request #1706 from hackmdio/fix/incorrect-array-index-refe…
Yukaii Oct 15, 2021
e45194e
Merge pull request #1695 from hackmdio/feat/csrf-export-user-data
Yukaii Oct 15, 2021
e1ea214
chore: remove unused uglifyjs-webpack-plugin dep
Yukaii Oct 19, 2021
08592f8
feat: deprecate sequelize.import usage
Yukaii Oct 19, 2021
5b564c6
Merge pull request #1724 from hackmdio/refactor/sequelize-import
Yukaii Oct 22, 2021
bfda919
chore: upgrade codemirror to 5.63.2
Yukaii Oct 22, 2021
32f3246
Merge pull request #1716 from hackmdio/chore/upgrade-codemirror
Yukaii Oct 25, 2021
ded6b58
Merge pull request #1723 from hackmdio/chore/remove-uglifyjs
Yukaii Oct 25, 2021
212d8b3
Update de.json
Jan 16, 2022
be3b2a9
Merge pull request #1741 from rubstudent/develop
a60814billy Jan 18, 2022
ce1b1cc
doc(release-note): Releaes 2.4.1
a60814billy Jan 18, 2022
b55bf97
doc(release-note): change release version to 2.4.2
a60814billy Aug 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# [Choice] Node.js version: 16, 14, 12
ARG VARIANT=12-buster
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# [Optional] Uncomment if you want to install more global node modules
RUN su node -c "npm install -g npm@6"
58 changes: 58 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "CodiMD",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh",
"sqltools.connections": [{
"name": "Container Database",
"driver": "PostgreSQL",
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"database": "codimd",
"username": "codimd",
"password": "codimd"
}],
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"visualstudioexptteam.vscodeintellicode",
"christian-kohler.path-intellisense",
"standard.vscode-standard",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg",
"eamodio.gitlens",
"codestream.codestream",
"github.vscode-pull-request-github",
"cschleiden.vscode-github-actions",
"hbenl.vscode-mocha-test-adapter",
"hbenl.vscode-test-explorer"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

"portsAttributes": {
"3000": {
"label": "CodiMD server",
"onAutoForward": "notify"
},
"5432": {
"label": "PostgreSQL",
"onAutoForward": "notify"
}
},

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
"postCreateCommand": "sudo chown -R node:node node_modules && /workspace/bin/setup",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
46 changes: 46 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: 12-buster
environment:
- CMD_DB_URL=postgres://codimd:codimd@localhost/codimd
- CMD_USECDN=false
volumes:
- ..:/workspace:cached
- node_modules:/workspace/node_modules:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.

# Uncomment the next line to use a non-root user for all processes.
# user: vscode

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:12.7-alpine
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=codimd
- POSTGRES_PASSWORD=codimd
- POSTGRES_DB=codimd

# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
node_modules:
postgres-data:
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Test and Build'

on:
push:
pull_request:
workflow_dispatch:

jobs:
test-and-build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- uses: actions/setup-node@v2
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
check-latest: true

- run: npm ci
- run: npm run test:ci
- run: npm run build

doctoc:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.event.pull_request

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
name: Use Node.js 12
with:
node-version: 12
check-latest: true
- name: Install doctoc-check
run: |
npm install -g doctoc
cp README.md README.md.orig
npm run doctoc
diff -q README.md README.md.orig
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

5 changes: 4 additions & 1 deletion deployments/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ARG RUNTIME
ARG BUILDPACK

FROM hackmdio/buildpack:node-10-0baafb79 as BUILD
FROM $BUILDPACK as BUILD

COPY --chown=hackmd:hackmd . .
ENV QT_QPA_PLATFORM=offscreen

RUN set -xe && \
git reset --hard && \
Expand All @@ -18,6 +20,7 @@ RUN set -xe && \

FROM $RUNTIME
USER hackmd
ENV QT_QPA_PLATFORM=offscreen
WORKDIR /home/hackmd/app
COPY --chown=1500:1500 --from=BUILD /home/hackmd/app .
RUN npm install --production && npm cache clean --force && rm -rf /tmp/{core-js-banners,phantomjs}
Expand Down
11 changes: 8 additions & 3 deletions deployments/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail
set -eo pipefail
set -x

if [[ -z $1 || -z $2 ]];then
echo "build.sh [runtime image] [buildpack image]"
exit 1
fi

CURRENT_DIR=$(dirname "$BASH_SOURCE")

GIT_SHA1="$(git rev-parse HEAD)"
Expand All @@ -11,6 +16,6 @@ GIT_TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/

DOCKER_TAG="${GIT_TAG:-$GIT_SHORT_ID}"

docker build --build-arg RUNTIME=hackmdio/runtime:node-10-d27854ef -t "hackmdio/hackmd:$DOCKER_TAG" -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."
docker build --build-arg RUNTIME=$1 --build-arg BUILDPACK=$2 -t "hackmdio/hackmd:$DOCKER_TAG" -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."

docker build --build-arg RUNTIME=hackmdio/runtime:node-10-cjk-d27854ef -t "hackmdio/hackmd:$DOCKER_TAG-cjk" -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."
docker build --build-arg RUNTIME=$1 --build-arg BUILDPACK=$2 -t "hackmdio/hackmd:$DOCKER_TAG-cjk" -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."
11 changes: 9 additions & 2 deletions lib/auth/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ exports.setReturnToFromReferer = function setReturnToFromReferer (req) {
if (!req.session) req.session = {}

var referer = req.get('referer')
var refererSearchParams = new URLSearchParams(new URL(referer).search)
var nextURL = refererSearchParams.get('next')
var nextURL
if (referer) {
try {
var refererSearchParams = new URLSearchParams(new URL(referer).search)
nextURL = refererSearchParams.get('next')
} catch (err) {
logger.warn(err)
}
}

if (nextURL) {
var isRelativeNextURL = nextURL.indexOf('://') === -1 && !nextURL.startsWith('//')
Expand Down
3 changes: 2 additions & 1 deletion lib/homepage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ exports.showIndex = async (req, res) => {
errorMessage: req.flash('error'),
privacyStatement: fs.existsSync(path.join(config.docsPath, 'privacy.md')),
termsOfUse: fs.existsSync(path.join(config.docsPath, 'terms-of-use.md')),
deleteToken: deleteToken
deleteToken: deleteToken,
csrfToken: req.csrfToken()
}

if (!isLogin) {
Expand Down
11 changes: 10 additions & 1 deletion lib/imageRouter/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ const logger = require('../logger')
const { S3Client } = require('@aws-sdk/client-s3-node/S3Client')
const { PutObjectCommand } = require('@aws-sdk/client-s3-node/commands/PutObjectCommand')

const s3 = new S3Client(config.s3)
const credentials = {
accessKeyId: config.s3.accessKeyId,
secretAccessKey: config.s3.secretAccessKey
}

const s3 = new S3Client({
credentials,
region: config.s3.region,
endpoint: config.s3.endpoint
})

exports.uploadImage = function (imagePath, callback) {
if (!imagePath || typeof imagePath !== 'string') {
Expand Down
2 changes: 1 addition & 1 deletion lib/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fs.readdirSync(__dirname)
return (file.indexOf('.') !== 0) && (file !== 'index.js')
})
.forEach(function (file) {
var model = sequelize.import(path.join(__dirname, file))
var model = require(path.join(__dirname, file))(sequelize, Sequelize)
db[model.name] = model
})

Expand Down
7 changes: 5 additions & 2 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ const appRouter = Router()

// register route

const csurf = require('csurf')
const csurfMiddleware = csurf({ cookie: true })

// get index
appRouter.get('/', wrap(indexController.showIndex))
appRouter.get('/', csurfMiddleware, wrap(indexController.showIndex))

// ----- error page -----
// get 403 forbidden
Expand Down Expand Up @@ -52,7 +55,7 @@ appRouter.get('/me', wrap(userController.getMe))
appRouter.get('/me/delete/:token?', wrap(userController.deleteUser))

// export the data of the authenticated user
appRouter.get('/me/export', userController.exportMyData)
appRouter.post('/me/export', urlencodedParser, csurfMiddleware, userController.exportMyData)

appRouter.get('/user/:username/avatar.svg', userController.getMyAvatar)

Expand Down
7 changes: 5 additions & 2 deletions lib/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ exports.exportMyData = (req, res) => {
let filename
let suffix = 0
do {
const separator = suffix === 0 ? '' : '-'
filename = basename + separator + suffix + '.md'
if (suffix === 0) {
filename = basename + '.md'
} else {
filename = basename + '-' + suffix + '.md'
}
suffix++
} while (filenames[filename])
filenames[filename] = true
Expand Down
Loading