mailauth 4.9.1 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/tools.js +23 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.9.2](https://github.com/postalsys/mailauth/compare/v4.9.1...v4.9.2) (2025-08-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* ZMS-262 remove control chars from record add support for mappers in validateTagValueRecord ([#95](https://github.com/postalsys/mailauth/issues/95)) ([42828a6](https://github.com/postalsys/mailauth/commit/42828a6cb38add3aed35881f102488f8143407cb))
|
|
9
|
+
|
|
3
10
|
## [4.9.1](https://github.com/postalsys/mailauth/compare/v4.9.0...v4.9.1) (2025-08-27)
|
|
4
11
|
|
|
5
12
|
|
package/lib/tools.js
CHANGED
|
@@ -580,9 +580,11 @@ function parseTagValueRecord(record, options = {}) {
|
|
|
580
580
|
} = options;
|
|
581
581
|
|
|
582
582
|
let sanitized = (record || '')
|
|
583
|
-
.replace(
|
|
584
|
-
.replace(/\\n/g, '')
|
|
585
|
-
.replace(
|
|
583
|
+
.replace(/[\x00-\x1F]+/g, ' ') // control chars
|
|
584
|
+
.replace(/\\r\\n/g, '')
|
|
585
|
+
.replace(/\\n/g, '')
|
|
586
|
+
.replace(/\r?\n/g, '')
|
|
587
|
+
.replace(/\s+/g, ' ')
|
|
586
588
|
.trim();
|
|
587
589
|
|
|
588
590
|
// Split on semicolons
|
|
@@ -663,6 +665,10 @@ function parseTagValueRecord(record, options = {}) {
|
|
|
663
665
|
};
|
|
664
666
|
}
|
|
665
667
|
|
|
668
|
+
function convertToASCII(value) {
|
|
669
|
+
return (value || '').replace(/[^\x20-\x7E]/g, '');
|
|
670
|
+
}
|
|
671
|
+
|
|
666
672
|
function validateTagValueRecord(record, recordType) {
|
|
667
673
|
const configs = {
|
|
668
674
|
BIMI: {
|
|
@@ -691,6 +697,9 @@ function validateTagValueRecord(record, recordType) {
|
|
|
691
697
|
return `Invalid authority URL: ${value}`;
|
|
692
698
|
}
|
|
693
699
|
}
|
|
700
|
+
},
|
|
701
|
+
mappers: {
|
|
702
|
+
v: value => convertToASCII(value)
|
|
694
703
|
}
|
|
695
704
|
}
|
|
696
705
|
};
|
|
@@ -702,6 +711,15 @@ function validateTagValueRecord(record, recordType) {
|
|
|
702
711
|
|
|
703
712
|
const parsed = parseTagValueRecord(record, config);
|
|
704
713
|
|
|
714
|
+
// Mappers run regardless whether the resulting parsed object is valid
|
|
715
|
+
if (config.mappers) {
|
|
716
|
+
for (const [tag, mapper] of Object.entries(config.mappers)) {
|
|
717
|
+
if (parsed.tags && tag in parsed.tags) {
|
|
718
|
+
parsed.tags[tag] = mapper(parsed.tags[tag]);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
705
723
|
if (config.validators && parsed.isValid) {
|
|
706
724
|
for (const [tag, validator] of Object.entries(config.validators)) {
|
|
707
725
|
if (parsed.tags && tag in parsed.tags) {
|
|
@@ -748,5 +766,6 @@ module.exports = {
|
|
|
748
766
|
TLDTS_OPTS,
|
|
749
767
|
|
|
750
768
|
validateTagValueRecord,
|
|
751
|
-
parseTagValueRecord
|
|
769
|
+
parseTagValueRecord,
|
|
770
|
+
convertToASCII
|
|
752
771
|
};
|