Skip to content

Commit 26a9140

Browse files
author
Florian Schaal
committed
changed regex for private-key
1 parent 752ab3d commit 26a9140

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

interface/lib/classes/validate_dkim.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function check_template($field_name, $field_value, $validator) {
7373
* @return boolean - true if $POST contains a real key-file
7474
*/
7575
function validate_post($key, $value, $dkim_strength) {
76-
$value=str_replace("\n", "", $value);
76+
$value=str_replace(array("\n", "-----BEGIN RSA PRIVATE KEY-----", "-----END RSA PRIVATE KEY-----", " "), "", $value);
7777
switch ($key) {
7878
case 'public':
7979
if (preg_match("/(^-----BEGIN PUBLIC KEY-----)[a-zA-Z0-9\r\n\/\+=]{1,221}(-----END PUBLIC KEY-----(\n|\r)?$)/", $value) === 1) { return true; } else { return false; }
@@ -82,7 +82,7 @@ function validate_post($key, $value, $dkim_strength) {
8282
if ( $dkim_strength == 1024 ) $range = "{812,816}";
8383
if ( $dkim_strength == 2048 ) $range = "{1588,1592}";
8484
if ( $dkim_strength == 4096 ) $range = "{3132,3136}";
85-
if (preg_match("/^-----BEGIN RSA PRIVATE KEY-----[a-zA-Z0-9\/\+=]".$range."-----END RSA PRIVATE KEY-----$/", $value) === 1) return true; else return false;
85+
if ( preg_match("/^[a-zA-Z0-9\/\+=]".$range."$/", $value ) === 1) return true; else return false;
8686
break;
8787
}
8888
}

0 commit comments

Comments
 (0)