mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-26 09:05:13 +01:00
added ua comment validator
This commit is contained in:
@@ -8,6 +8,8 @@ const path = require("path");
|
||||
const featureChoices = require(path.join(__dirname, "features.json"));
|
||||
const coinstring = require('coinstring');
|
||||
|
||||
const uaCommentRegexp = /^[a-zA-Z0-9 \.,:_\?@]+$/
|
||||
|
||||
let prompters = [];
|
||||
const normalizedPath = path.join(__dirname, "prompters");
|
||||
fs.readdirSync(normalizedPath).forEach(function(file) {
|
||||
@@ -128,6 +130,13 @@ module.exports = class extends Generator {
|
||||
return true;
|
||||
}
|
||||
|
||||
_UACommentValidator( comment ) {
|
||||
if( !uaCommentRegexp.test( comment ) ) {
|
||||
throw new Error('Unsafe characters in UA comment. Please use only a-z, A-Z, 0-9, SPACE and .,:_?@');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
_trimFilter( input ) {
|
||||
return (input+"").trim();
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ module.exports = {
|
||||
name: 'bitcoin_uacomment',
|
||||
default: utils._getDefault( 'bitcoin_uacomment' ),
|
||||
message: prefix()+'Any UA comment?'+'\n',
|
||||
validate: utils._UACommentValidator
|
||||
}];
|
||||
},
|
||||
env: function( props ) {
|
||||
|
||||
Reference in New Issue
Block a user