[Squeak-ja: 2469] [N7]HttpUrlの不具合

Hideo Kawamura kawa90 @ m2.pbc.ne.jp
2005年 6月 11日 (土) 00:30:46 JST


川村です。お世話になっています。

日本語7でHttpUrlクラスのBasic認証チェックでrealmフィールドがうまくとれ
ないバグがあります。このためBasic認証がうまくいかず無限ループになってし
まいます。確認は下記コードで'debug it'すればできます。
例)
| h |
h := HttpUrl absoluteFromText: 'http://hogehoge.jp'.
h checkAuthorization:
'HTTP/1.1 401 Authorization Required
Date: Mon, 10 Jun 2002 17:12:23 GMT
Server: Apache/1.3.24 (Unix)
WWW-Authenticate: Basic realm="member only"
Connection: close
Content-Type: text/html; charset=iso-8859-1' retry: [].
h realm
--> ''

やっつけで直したい場合は
HttpUrl>>checkAuthorization:retry:
を下記のように直せばOKです。

| oldRealm i end encoded |
((webDocument isString)
and: [(webDocument beginsWith: 'HTTP/1.0 401')
or: [webDocument beginsWith: 'HTTP/1.1 401']])
ifFalse: [^self].

oldRealm _ realm.
i _ webDocument findString: 'realm="'.
i = 0 ifTrue: [^self].
end _ webDocument indexOf: $" startingAt: i+7."hkawa"
realm _ webDocument copyFrom: i+7 to: end-1."hkawa"
"realm _ (webDocument findTokens: '""') at: 2."

Passwords ifNil: [Passwords _ Dictionary new].
encoded _ Passwords at: realm ifAbsent: [nil].
(oldRealm = realm) & (encoded~~ nil) "hkawa"
ifTrue: [^self].
(oldRealm ~= realm) & (encoded ~~ nil)
ifTrue: [^ retryBlock value]
ifFalse: ["ask the user"
self askNamePassword ifTrue: [^ retryBlock value]]

それでは。

-- 
--------------
Hideo Kawamura(川村 秀男)
http://squeak.qp.land.to/
http://blog.goo.ne.jp/hkawa90/ (blog)



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 2005/06/08

__________________________________
Save the earth
http://pr.mail.yahoo.co.jp/ondanka/




Squeak-ja メーリングリストの案内