<commit_before>/**
 *  ReCaptcha
 *
 *  Module verify reCAPTCHA code
 **/


'use strict';


// 3rd-party
var _           = require('lodash');
var http        = require('http');
var queryString = require('querystring');


/**
 * ReCaptcha.verify = function (private_key, user_ip, challenge, response, callback) -> Void
 * - private_key (String): reCAPTCHA prvate key
 * - user_ip (String): user IP
 * - challenge (String): captcha id
 * - response (String): user captcha response
 * - callback (Function): callback function with params err, verification result
 *
 **/
module.exports.verify = function (private_key, user_ip, challenge, response, callback) {
  var request,
      options;

  var data = {
    'privatekey': private_key,
    'remoteip': user_ip,
    'challenge': challenge,
    'response': response
  };

  // Immideately reply empty challenge as wrong captcha
  if (_.isEmpty(challenge)) {
    callback(null, false);
    return;
  }
<commit_msg>recaptcha: return wrong captcha if the response is empty<commit_after>/**
 *  ReCaptcha
 *
 *  Module verify reCAPTCHA code
 **/


'use strict';


// 3rd-party
var _           = require('lodash');
var http        = require('http');
var queryString = require('querystring');


/**
 * ReCaptcha.verify = function (private_key, user_ip, challenge, response, callback) -> Void
 * - private_key (String): reCAPTCHA prvate key
 * - user_ip (String): user IP
 * - challenge (String): captcha id
 * - response (String): user captcha response
 * - callback (Function): callback function with params err, verification result
 *
 **/
module.exports.verify = function (private_key, user_ip, challenge, response, callback) {
  var request,
      options;

  var data = {
    'privatekey': private_key,
    'remoteip': user_ip,
    'challenge': challenge,
    'response': response
  };

  // Immediately reply 'wrong captcha'
  // - if empty challenge
  // - if user not filled captcha field
  if (_.isEmpty(challenge) || _.isEmpty(response)) {
    callback(null, false);
    return;
  }

{'fraction_non_alphanumeric': 0.12985735366453516, 'fraction_numerical': 0.000983767830791933, 'mean_word_length': 3.3648068669527897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1727053', 'n_tokens_mistral': 633, 'n_tokens_neox': 603, 'n_words': 183}