Commit 001ec3074acea0ed4f32d923b0cd88619bc872aa
Committed by
libras
1 parent
853cae82
Exists in
master
and in
1 other branch
Fix some validation bugs on texto and ios service
Showing
2 changed files
with
10 additions
and
9 deletions
Show diff stats
endpoints/ios.js
| ... | ... | @@ -10,13 +10,13 @@ function init(req, res) { |
| 10 | 10 | var id = uuid.v4(); |
| 11 | 11 | |
| 12 | 12 | /* Verifica se os paramêtros [transparencia, texto] possuem algum valor */ |
| 13 | - if ((req.body.transparencia !== '') && (req.body.texto !== '')) { | |
| 13 | + if ((req.body.transparencia === '') || (req.body.texto === '')) { | |
| 14 | 14 | res.send(500, parameters.errorMessage('O valor de algum parâmetro está vazio')); |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /* Verifica se o paramêtro [transparencia] possui os únicos valores possíveis [opaco, transparente] */ |
| 19 | - if (parameters.checkTransparency(req.body.transparencia)) { | |
| 19 | + if (parameters.checkTransparency(req.body.transparencia) === false) { | |
| 20 | 20 | res.send(500, parameters.errorMessage('Parâmetros insuficientes ou inválidos')); |
| 21 | 21 | return; |
| 22 | 22 | } |
| ... | ... | @@ -43,4 +43,4 @@ function init(req, res) { |
| 43 | 43 | }); |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | -module.exports.init = init; | |
| 47 | 46 | \ No newline at end of file |
| 47 | +module.exports.init = init; | ... | ... |
endpoints/texto.js
| ... | ... | @@ -10,21 +10,22 @@ function init(req, res) { |
| 10 | 10 | var id = uuid.v4(); |
| 11 | 11 | |
| 12 | 12 | /* Verifica se os paramêtros [transparencia, texto] possuem algum valor */ |
| 13 | - if ((req.body.transparencia !== '') && (req.body.texto !== '')) { | |
| 13 | + if ((req.body.transparencia === '') || (req.body.texto === '')) { | |
| 14 | 14 | res.send(500, parameters.errorMessage('O valor de algum parâmetro está vazio')); |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /* Verifica se o paramêtro [transparencia] possui os únicos valores possíveis [opaco, transparente] */ |
| 19 | - if (parameters.checkTransparency(req.body.transparencia)) { | |
| 19 | + if (parameters.checkTransparency(req.body.transparencia) === false) { | |
| 20 | 20 | res.send(500, parameters.errorMessage('Parâmetros insuficientes ou inválidos')); |
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /* Cria a linha de comando */ |
| 25 | - var command_line = 'echo ' + req.body.texto + ' >> ' + __dirname + '/text_files/' + id + ' && cd ../vlibras-core' + | |
| 26 | - ' && ./vlibras ' + parameters.getServiceType(req.body.servico) + ' ../vlibras-api/text_files/' + | |
| 27 | - id + ' ' + parameters.getTransparency(req.body.transparencia) + ' ' + id + ' WEB'; | |
| 25 | + var command_line = 'echo ' + req.body.texto + ' >> text_files/' + id + ' && mkdir uploads/' + id + ' && vlibras_user/vlibras-core/./vlibras ' + parameters.getServiceType(req.body.servico) + ' text_files/' + | |
| 26 | + id + ' ' + parameters.getTransparency(req.body.transparencia) + ' ' + id + ' WEB > /tmp/core_log 2>&1'; | |
| 27 | + | |
| 28 | + console.log(command_line) | |
| 28 | 29 | |
| 29 | 30 | /* Executa a linha de comando */ |
| 30 | 31 | child = exec(command_line, function(err, stdout, stderr) { |
| ... | ... | @@ -42,4 +43,4 @@ function init(req, res) { |
| 42 | 43 | }); |
| 43 | 44 | }; |
| 44 | 45 | |
| 45 | -module.exports.init = init; | |
| 46 | 46 | \ No newline at end of file |
| 47 | +module.exports.init = init; | ... | ... |