Commit bbafff40 authored by Jan Idzikowski's avatar Jan Idzikowski
Browse files

Fix rfc2045-q-encode-string for ascii character strings

 - when string longer 74 characters, make newline on next space in string
parent b67708b8
Version 20191031.1
Fix rfc2045-q-encode-string for ascii character strings
and longer than 74 characters, make newline on next space in string
add new test
Change cl-smtp.asd, cl-smtp.lisp. tests.lisp CHANGELOG
Version 20190523.1
2019.05.23
Fix error rfc2045-q-encode-string, when string contains non ascii character,
......
......@@ -21,7 +21,7 @@
:licence "LLGPL"
:author "Jan Idzikowski <jidzikowski@common-lisp.net>"
:maintainer "Jan Idzikowski <jidzikowski@common-lisp.net>"
:version "20190523.1"
:version "20191031.1"
:perform (load-op :after (op webpage)
(pushnew :cl-smtp cl:*features*))
:depends-on (:usocket
......
......@@ -82,13 +82,12 @@
for n from 0 to len
for column = (- n last-line-break)
do
(when (>= column 74)
(when line-has-non-ascii
(write-sequence "?=" s))
(when (and (>= column 74)
line-has-non-ascii)
(write-sequence "?=" s)
(write-blank-line s)
(write-char #\Space s)
(when line-has-non-ascii
(write-sequence estart s))
(write-sequence estart s)
(setf last-line-break n))
(cond
(line-has-non-ascii
......@@ -96,7 +95,9 @@
(make-string 1 :initial-element c)
:external-format exformat)
do (format s "~:@(=~2,'0X~)" byte)))
((char= c #\NewLine)
((or (char= c #\NewLine)
(and (char= c #\Space)
(>= column 74)))
(setf last-line-break n)
(write-blank-line s)
(write-char #\Space s))
......
......@@ -136,7 +136,7 @@ n !"
(define-cl-smtp-test "rfc2045-q-encode-string-newline-1" ()
(assert (equal (rfc2045-q-encode-string
"123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A")
(format nil"123456789A123456789A123456789A123456789A123456789A123456789A123456789A1234~C~C 56789A123456789A123456789A123456789A123456789A123456789A123456789A12345678~C~C 9A123456789A" #\Return #\Newline #\Return #\Newline))))
"123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A")))
(define-cl-smtp-test "rfc2045-q-encode-string-newline-2" ()
(assert (equal (rfc2045-q-encode-string
......@@ -152,6 +152,12 @@ n !"
(format nil "123456789A123456789A~C~C .~C~C END"
#\Return #\Newline #\Return #\Newline))))
(define-cl-smtp-test "rfc2045-q-encode-string-newline-4" ()
(assert (equal (rfc2045-q-encode-string
"123456789A 123456789A 123456789A 123456789A 123456789A 123456789A 123456789A END")
(format nil "123456789A 123456789A 123456789A 123456789A 123456789A 123456789A 123456789A~C~C END"
#\Return #\Newline))))
(define-cl-smtp-test "escape-rfc822-quoted-string" ()
(assert (equal (escape-rfc822-quoted-string "test end") "test end"))
(assert (equal (escape-rfc822-quoted-string "test\\end")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment