Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
fix(devtool): encode upload message
Browse files Browse the repository at this point in the history
  • Loading branch information
NewFuture committed Sep 6, 2019
1 parent 8038f2a commit fea8da5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/tasks/devtool.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const successIcon = colors.green.bold('√');


function logSuccess(msg) {
logger.info(
logger(
TITLE,
successIcon,
colors.green(msg)
Expand Down Expand Up @@ -125,6 +125,14 @@ function getSize(path) {
return colors.dim.yellowBright('[unknown size]');
}
}
/**
* 特殊字符转义
* @param {string} s
*/
function encode(s) {
return s.replace(/&|<|>/g, escape);
}

/**
* 上传
*/
Expand All @@ -139,7 +147,7 @@ exports.upload = function () {
.then(function (message) {
message = (message || process.env.npm_package_description || '').trim().substr(0, 2048)
logger.info(TITLE, colors.gray.bold(version + ':'), colors.dim.gray.underline(message.split('\n', 1)[0]))
return devtool.cli('--upload', uploadProject, '--upload-info-output', logPath, '--upload-desc', encodeURI(message))
return devtool.cli('--upload', uploadProject, '--upload-info-output', logPath, '--upload-desc', encode(message))
})
.then(function (res) {
if (res.stderr) {
Expand Down

0 comments on commit fea8da5

Please # to comment.