Commit ae6a760b authored by Max Rottenkolber's avatar Max Rottenkolber
Browse files

Escape newline/return, added ERRORP, export Q-ENCODE-P.

parent f731ec89
......@@ -17,6 +17,12 @@
(defparameter *ascii-space* 32
"ASCII space character code.")
(defparameter *ascii-newline* 10
"ASCII newline character code.")
(defparameter *ascii-return* 13
"ASCII return character code.")
(defparameter *ascii-equals* 61
"ASCII equals sign character code.")
......@@ -103,7 +103,11 @@
do (write-string (decode string :start from :end to) out)
while (and from to))))
(defun decode* (string &key (start 0) end)
(defun decode* (string &key (start 0) end (errorp t))
"Decode mixed STRING (possibly containing encoded as well as unencoded
words) from START to END."
(decode-word* (subseq string start end)))
words) from START to END, if ERRORP is non nil DECODE* will return the
string unmodified if an error occurs."
(handler-case (decode-word* (subseq string start end))
(error (error) (if errorp
(error error)
+ Add {BLACKLISTED-CHARS} parameter to {ENCODE}.
......@@ -63,6 +63,8 @@ destructively."
"Predicate to test if CHARACTER needs to be q-encoded."
(let ((code (aref (char-utf-8 character) 0)))
(or (> code *ascii-boundary*)
(= code *ascii-newline*)
(= code *ascii-return*)
(= code *ascii-space*)
(= code *ascii-equals*)
(= code *ascii-question-mark*)
......@@ -5,6 +5,7 @@
(:use :cl
(:export :encode
(:export :q-encode-p
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