@@ -13,26 +13,32 @@ private static function getDefaulSensitiveXmlTags(){
1313// );
1414 return array ( //format for each element: array(tag name, regex-pattern, regex-replacement)
1515 new SensitiveTag ("cardCode " ),
16- new SensitiveTag ("cardNumber " ,"([^0-9]*)( \d+)(\d{4})(.* ) " ,"$1xxxx-$3$4 " ,false ),
16+ new SensitiveTag ("cardNumber " ,"(\d+)(\d{4}) " ,"$1xxxx-$3$4 " ,false ),
1717 new SensitiveTag ("expirationDate " )
1818 );
1919 }
2020 public static function getSensitiveXmlTags (){
2121 $ sensitiveTags = array ();
2222 $ configFilePath = dirname (__FILE__ ) . "/ " . ANET_SENSITIVE_XMLTAGS_JSON_FILE ;
23- $ userConfigFilePath = ANET_SENSITIVE_XMLTAGS_JSON_FILE ;
24- if (file_exists ($ userConfigFilePath )) { //client config for tags
23+ $ userConfigFile = ANET_SENSITIVE_XMLTAGS_JSON_FILE ;
24+ $ presentUserConfigFile = file_exists ($ userConfigFile );
25+ if ($ presentUserConfigFile ) { //client config for tags
2526 //read list of tags(and associate regex-patterns and replacements) from .json file
26- $ sensitiveTags = json_decode (file_get_contents ($ configFilePath ));
27+ $ jsonFileObejct = json_decode (file_get_contents ($ userConfigFile ));
28+ $ sensitiveTags = $ jsonFileObejct ["sensitiveTags " ];
2729 if (json_last_error () === JSON_ERROR_NONE ) {// JSON is valid
2830 }
2931 else {
30- echo "ERROR: Invalid json in: " . $ userConfigFilePath . " json_last_error_msg : " . json_last_error_msg ();
31- return self :: getDefaulSensitiveXmlTags () ;
32+ echo "ERROR: Invalid json in: " . $ userConfigFile . " json_last_error_msg : " . json_last_error_msg ();
33+ $ presentUserConfigFile = false ;
3234 }
3335 }
34- else if (file_exists ($ configFilePath )) { //default sdk config for tags
35- $ sensitiveTags = json_decode (file_get_contents ($ configFilePath ));
36+ if (!$ presentUserConfigFile ) { //default sdk config for tags
37+ if (!file_exists ($ configFilePath )){
38+ exit ("ERROR: No config file: " . $ configFilePath );
39+ }
40+ $ jsonFileObejct = json_decode (file_get_contents ($ configFilePath ));
41+ $ sensitiveTags = $ jsonFileObejct ->sensitiveTags ;
3642 if (json_last_error () === JSON_ERROR_NONE ) {
3743 }
3844 else {
0 commit comments