Skip to content

Commit

Permalink
v3.0.9 release
Browse files Browse the repository at this point in the history
1. fix bug: plugin will use wrong encrypted tag in some cases.
2. fix #127. removing password from hexo g log to avoid leaking password to CI log.
  • Loading branch information
D0n9X1n committed Jan 7, 2020
1 parent c1def51 commit 2758841
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const keySalt = textToArray('hexo-blog-encrypt的作者们都是大帅比!');
const ivSalt = textToArray('hexo-blog-encrypt是地表最强Hexo加密插件!');

hexo.extend.filter.register('after_post_render', (data) => {
const tagEncryptName = [];
const tagEncryptPass = [];
const tagEncryptPairs = [];

let password = data.password;
let tagUsed = false;
Expand All @@ -31,16 +30,15 @@ hexo.extend.filter.register('after_post_render', (data) => {

if(('encrypt' in hexo.config) && ('tags' in hexo.config.encrypt)){
hexo.config.encrypt.tags.forEach((tagObj) => {
tagEncryptName.push(tagObj.name);
tagEncryptPass.push(tagObj.password);
tagEncryptPairs[tagObj.name] = tagObj.password;
});
}

if (data.tags) {
data.tags.forEach((cTag, index) => {
if(tagEncryptName.includes(cTag.name)){
password = password || tagEncryptPass[index];
tagUsed = cTag.name;
data.tags.forEach((cTag) => {
if (tagEncryptPairs.hasOwnProperty(cTag.name)) {
tagUsed = password ? tagUsed : cTag.name;
password = password || tagEncryptPairs[cTag.name];
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint --ext .js ./"
},
"version": "3.0.6",
"version": "3.0.9",
"devDependencies": {
"eslint": "^6.2.2"
}
Expand Down

0 comments on commit 2758841

Please sign in to comment.