Signed-off-by: Nathan Pixodeo <nathan@pixodeo.net>
This commit is contained in:
parent
282e7dac6a
commit
a2dd70fe3e
2 changed files with 46 additions and 20 deletions
|
|
@ -1004,26 +1004,15 @@ class EmailCollector extends CommonObject
|
|||
|
||||
if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) {
|
||||
// Overwrite param $tmpproperty
|
||||
$valueextracted = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null;
|
||||
if (strtolower($sourcefield) == 'header') { // extract from HEADER
|
||||
if (preg_match('/^options_/', $tmpproperty)) {
|
||||
$object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted);
|
||||
$valueextracted = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : '';
|
||||
$valuetoset = (strtolower($sourcefield) == 'body') ? $valueextracted : $this->decodeSMTPSubject($valueextracted);
|
||||
if (preg_match('/^options_/', $tmpproperty)) {
|
||||
$object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetoset;
|
||||
} else {
|
||||
if (property_exists($object, $tmpproperty)) {
|
||||
$object->$tmpproperty = $valuetoset;
|
||||
} else {
|
||||
if (property_exists($object, $tmpproperty)) {
|
||||
$object->$tmpproperty = $this->decodeSMTPSubject($valueextracted);
|
||||
} else {
|
||||
$tmp[$tmpproperty] = $this->decodeSMTPSubject($valueextracted);
|
||||
}
|
||||
}
|
||||
} else { // extract from BODY
|
||||
if (preg_match('/^options_/', $tmpproperty)) {
|
||||
$object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted);
|
||||
} else {
|
||||
if (property_exists($object, $tmpproperty)) {
|
||||
$object->$tmpproperty = $this->decodeSMTPSubject($valueextracted);
|
||||
} else {
|
||||
$tmp[$tmpproperty] = $this->decodeSMTPSubject($valueextracted);
|
||||
}
|
||||
$tmp[$tmpproperty] = $valuetoset;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4304,7 +4293,7 @@ class EmailCollector extends CommonObject
|
|||
/**
|
||||
* Decode a subject string according to RFC2047
|
||||
* Example: '=?Windows-1252?Q?RE=A0:_ABC?=' => 'RE : ABC...'
|
||||
* Example: '=?UTF-8?Q?A=C3=A9B?=' => 'AéB'
|
||||
* Example: '=?UTF-8?Q?A=C3=A9B?=' => 'A[e acute]B'
|
||||
* Example: '=?UTF-8?B?2KLYstmF2KfbjNi0?=' =>
|
||||
* Example: '=?utf-8?B?UkU6IG1vZHVsZSBkb2xpYmFyciBnZXN0aW9ubmFpcmUgZGUgZmljaGllcnMg?= =?utf-8?B?UsOpZsOpcmVuY2UgZGUgbGEgY29tbWFuZGUgVFVHRURJSklSIOKAkyBwYXNz?= =?utf-8?B?w6llIGxlIDIyLzA0LzIwMjA=?='
|
||||
*
|
||||
|
|
|
|||
|
|
@ -48,6 +48,15 @@ $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
|||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
* @phan-file-suppress PhanDeprecatedFunctionInternal
|
||||
* @phan-file-suppress PhanPluginUnknownObjectMethodCall
|
||||
* @phan-file-suppress PhanTypeMismatchReturn
|
||||
* @phan-file-suppress PhanTypeMismatchReturnProbablyReal
|
||||
* @phan-file-suppress PhanUndeclaredClass
|
||||
* @phan-file-suppress PhanUndeclaredExtendedClass
|
||||
* @phan-file-suppress PhanUndeclaredMethod
|
||||
* @phan-file-suppress PhanUndeclaredProperty
|
||||
* @phan-file-suppress PhanUndeclaredStaticMethod
|
||||
*/
|
||||
class EmailCollectorTest extends CommonClassTest
|
||||
{
|
||||
|
|
@ -131,6 +140,34 @@ class EmailCollectorTest extends CommonClassTest
|
|||
return $localobject->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* testEmailCollectorExtractBodyKeepsUtf8
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testEmailCollectorExtractBodyKeepsUtf8()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf = $this->savconf;
|
||||
$user = $this->savuser;
|
||||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
$localobject = new EmailCollector($db);
|
||||
$object = new stdClass();
|
||||
$object->element = 'societe';
|
||||
$object->name = '';
|
||||
$object->array_options = array();
|
||||
|
||||
$messagetext = "ThirdpartyName: Günni GmbH\nContactName: Günni Pfannenstiel\n";
|
||||
$operationslog = '';
|
||||
$args = array(&$object, 'name=EXTRACT:BODY:^ThirdpartyName:\s*([^\r\n]+)', $messagetext, '', '', &$operationslog);
|
||||
$result = self::callMethod($localobject, 'overwritePropertiesOfObject', $args);
|
||||
|
||||
$this->assertSame(0, $result);
|
||||
$this->assertSame('Günni GmbH', $object->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* testEmailCollectorDelete
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue