松尾です。
こちらではcurl(SSL)を使っていないのですが、問題なく
投稿できるようです。今井さんはcurlをお使いでしょうか。
twittering-percent-encodeで「[」や「]」が%5bや%5dにencode
されないのと関係あるのかもしれません。
Emacs 22.1のurl-util.elにある、url-hexify-stringを基にした
関数で置き換えるパッチを作ってみました。
http://github.com/hayamiz/twittering-mode/tree/master
に対する差分です。
twittering-mode.elのあるディレクトリで
patch -p1 < replace-percent-encode.path
を実行すれば適用できます。
これを適用するとエラーは収まるでしょうか。
---
松尾 直志 <[email protected]>
diff -r ce86c2bd92fe twittering-mode.el
--- a/twittering-mode.el Sat Jan 02 03:55:16 2010 +0100
+++ b/twittering-mode.el Wed Jan 06 03:18:08 2010 +0900
@@ -63,6 +63,16 @@
(defconst twittering-max-number-of-tweets-on-retrieval 200
"The maximum number of `twittering-number-of-tweets-on-retrieval'.")
+;;; derived from url-util.el of Emacs 22.1
+(defconst twittering-url-unreserved-chars
+ '(?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y
?z
+ ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X
?Y ?Z
+ ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
+ ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\))
+ "A list of characters that are _NOT_ reserved in the URL spec.
+This is taken from RFC 2396.")
+
+
(defvar twittering-number-of-tweets-on-retrieval 20
"*The number of tweets which will be retrieved in one request.
The upper limit is `twittering-max-number-of-tweets-on-retrieval'.")
@@ -1209,19 +1219,35 @@
(setq statuses (cdr statuses)))
ret)))
-(defun twittering-percent-encode (str &optional coding-system)
- (if (or (null coding-system)
- (not (coding-system-p coding-system)))
- (setq coding-system 'utf-8))
- (mapconcat
- (lambda (c)
- (cond
- ((twittering-url-reserved-p c)
- (char-to-string c))
- ((eq c ? ) "+")
- (t (format "%%%x" c))))
- (encode-coding-string str coding-system)
- ""))
+;; derived from url-util.el of Emacs 22.1
+(defun twittering-url-hexify-string (string)
+ "Return a new string that is STRING URI-encoded.
+First, STRING is converted to utf-8, if necessary. Then, for each
+character in the utf-8 string, those found in `url-unreserved-chars'
+are left as-is, all others are represented as a three-character
+string: \"%\" followed by two lowercase hex digits."
+ ;; To go faster and avoid a lot of consing, we could do:
+ ;;
+ ;; (defconst url-hexify-table
+ ;; (let ((map (make-vector 256 nil)))
+ ;; (dotimes (byte 256) (aset map byte
+ ;; (if (memq byte url-unreserved-chars)
+ ;; (char-to-string byte)
+ ;; (format "%%%02x" byte))))
+ ;; map))
+ ;;
+ ;; (mapconcat (curry 'aref url-hexify-table) ...)
+ (mapconcat (lambda (byte)
+ (if (memq byte twittering-url-unreserved-chars)
+ (char-to-string byte)
+ (format "%%%02x" byte)))
+ (if (multibyte-string-p string)
+ (encode-coding-string string 'utf-8)
+ string)
+ ""))
+
+(defun twittering-percent-encode (str)
+ (twittering-url-hexify-string str))
(defun twittering-url-reserved-p (ch)
(or (and (<= ?A ch) (<= ch ?z))
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
twmode-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/twmode-users