improve armor header validation + tests | #598

This commit is contained in:
Tom James Holub
2017-11-25 10:57:41 +08:00
parent bee9928e54
commit 4495df0f42
2 changed files with 23 additions and 7 deletions

View File

@@ -224,7 +224,7 @@ function splitHeaders(text) {
*/
function verifyHeaders(headers) {
for (var i = 0; i < headers.length; i++) {
if (!/^[^:\s]+: .+$/.test(headers[i])) {
if (!/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(headers[i])) {
throw new Error('Improperly formatted armor header: ' + headers[i]);
}
if (config.debug && !/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(headers[i])) {