소스 검색

Improve RFC 2445 compliance

iCalendar export has now improved compliance with RFC 2445.
Now all occurrences in data fields of the double quotes are replaced
by two single quotes, and any fields containing comma, colon, or
semicolon are quoted by surrounding them with double quotes.
Carsten Dominik 16 년 전
부모
커밋
a33679ee5d
2개의 변경된 파일17개의 추가작업 그리고 17개의 파일을 삭제
  1. 3 0
      lisp/ChangeLog
  2. 14 17
      lisp/org-exp.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-11-13  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-exp.el (org-icalendar-cleanup-string): Improve RFC2455
+	compliance as far as quoting is concerned.
+
 	* org.el (org-link-expand-abbrev): Implement %h as an escape for a
 	hexified version of the tag.
 

+ 14 - 17
lisp/org-exp.el

@@ -4521,24 +4521,21 @@ whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
 characters."
   (if (not s)
       nil
-    (when is-body
-      (let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
-	    (re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
-	(while (string-match re s) (setq s (replace-match "" t t s)))
-	(while (string-match re2 s) (setq s (replace-match "" t t s)))))
-    (let ((start 0))
-      (while (string-match "\\([,;]\\)" s start)
-	(setq start (+ (match-beginning 0) 2)
-	      s (replace-match "\\\\\\1" nil nil s))))
-    (when is-body
-      (while (string-match "[ \t]*\n[ \t]*" s)
-	(setq s (replace-match "\\n" t t s))))
-    (setq s (org-trim s))
     (if is-body
-	(if maxlength
-	    (if (and (numberp maxlength)
-		     (> (length s) maxlength))
-		(setq s (substring s 0 maxlength)))))
+	(let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
+	      (re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
+	  (while (string-match re s) (setq s (replace-match "" t t s)))
+	  (while (string-match re2 s) (setq s (replace-match "" t t s)))
+	  (setq s (org-trim s))
+	  (while (string-match "[ \t]*\n[ \t]*" s)
+	    (setq s (replace-match "\\n" t t s)))
+	  (if maxlength
+	      (if (and (numberp maxlength)
+		       (> (length s) maxlength))
+		  (setq s (substring s 0 maxlength)))))
+      (setq s (org-trim s)))
+    (while (string-match "\"" s) (setq s (replace-match "''" t t s)))
+    (when (string-match "[;,:]" s) (setq s (concat "\"" s "\"")))
     s))
 
 (defun org-get-entry ()