php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
spoofchecker_create.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | This source file is subject to version 3.01 of the PHP license, |
4 | that is bundled with this package in the file LICENSE, and is |
5 | available through the world-wide-web at the following url: |
6 | https://www.php.net/license/3_01.txt |
7 | If you did not receive a copy of the PHP license and are unable to |
8 | obtain it through the world-wide-web, please send a note to |
9 | license@php.net so we can mail you a copy immediately. |
10 +----------------------------------------------------------------------+
11 | Authors: Scott MacVicar <scottmac@php.net> |
12 +----------------------------------------------------------------------+
13 */
14
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
19#include "php_intl.h"
20#include "spoofchecker_class.h"
21#include "intl_data.h"
22
23/* {{{ Spoofchecker object constructor. */
25{
26#if U_ICU_VERSION_MAJOR_NUM < 58
27 int checks;
28#endif
29 zend_error_handling error_handling;
31
33
35
37
38 co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
39 INTL_METHOD_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");
40
41#if U_ICU_VERSION_MAJOR_NUM >= 58
42 /* TODO save it into the object for further suspiction check comparison. */
43 /* ICU 58 removes WSC and MSC handling. However there are restriction
44 levels as defined in
45 http://www.unicode.org/reports/tr39/tr39-15.html#Restriction_Level_Detection
46 and the default is high restrictive. In further, we might want to utilize
47 uspoof_check2 APIs when it became stable, to use extended check result APIs.
48 Subsequent changes in the unicode security algos are to be watched.*/
49 uspoof_setRestrictionLevel(co->uspoof, SPOOFCHECKER_DEFAULT_RESTRICTION_LEVEL);
50 co->uspoofres = uspoof_openCheckResult(SPOOFCHECKER_ERROR_CODE_P(co));
51#else
52 /* Single-script enforcement is on by default. This fails for languages
53 like Japanese that legally use multiple scripts within a single word,
54 so we turn it off.
55 */
56 checks = uspoof_getChecks(co->uspoof, SPOOFCHECKER_ERROR_CODE_P(co));
57 uspoof_setChecks(co->uspoof, checks & ~USPOOF_SINGLE_SCRIPT, SPOOFCHECKER_ERROR_CODE_P(co));
58#endif
59 zend_restore_error_handling(&error_handling);
60}
61/* }}} */
zend_class_entry * IntlException_ce_ptr
Definition intl_error.c:30
#define INTL_METHOD_CHECK_STATUS(obj, msg)
Definition intl_data.h:66
#define PHP_METHOD
Definition php.h:365
#define SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK
#define SPOOFCHECKER_ERROR_CODE_P(co)
#define SPOOFCHECKER_METHOD_INIT_VARS
@ EH_THROW
Definition zend.h:433
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current)
Definition zend_API.c:5242
ZEND_API void zend_restore_error_handling(zend_error_handling *saved)
Definition zend_API.c:5253
#define ZEND_PARSE_PARAMETERS_NONE()
Definition zend_API.h:1623