/** * Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation * * @param string $js * @return string */ PHP_METHOD(Phalcon_Escaper, escapeJs){ zval *js, *normalized, *sanitized; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &js) == FAILURE) { RETURN_MM_NULL(); } if (Z_TYPE_P(js) == IS_STRING) { if (zend_is_true(js)) { /** * Normalize encoding to UTF-32 */ PHALCON_INIT_VAR(normalized); PHALCON_CALL_METHOD_PARAMS_1(normalized, this_ptr, "normalizeencoding", js); /** * Escape the string */ PHALCON_INIT_VAR(sanitized); phalcon_escape_js(sanitized, normalized); RETURN_CTOR(sanitized); } } RETURN_MM_NULL(); }
/** * Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation * * @param string $js * @return string */ PHP_METHOD(Phalcon_Escaper, escapeJs){ zval *js, normalized = {}; phalcon_fetch_params(0, 1, 0, &js); if (Z_TYPE_P(js) == IS_STRING && zend_is_true(js)) { /** * Normalize encoding to UTF-32 */ PHALCON_CALL_METHODW(&normalized, getThis(), "normalizeencoding", js); /** * Escape the string */ phalcon_escape_js(return_value, &normalized); return; } RETURN_CTORW(js); }
/** * Escape javascript strings by replacing non-alphanumeric chars by their hexadecimal escaped representation * * @param string $js * @return string */ PHP_METHOD(Phalcon_Escaper, escapeJs){ zval *js, *normalized = NULL; phalcon_fetch_params(0, 1, 0, &js); if (Z_TYPE_P(js) == IS_STRING && zend_is_true(js)) { PHALCON_MM_GROW(); /** * Normalize encoding to UTF-32 */ PHALCON_CALL_METHOD(&normalized, this_ptr, "normalizeencoding", js); /** * Escape the string */ phalcon_escape_js(return_value, normalized); RETURN_MM(); } RETURN_ZVAL(js, 1, 0); }