2011-08-04 5 views
2

Zendに問題が発生したため、エラーが発生します。私はZendがURLに対していくつかの検証を行うので、ホスト名の下線が原因であると考えています。Zend_XmlRpc_Clientはホスト名にアンダースコアを付けます

私は、同じ基本機能を実行するPythonクライアントを持っており、期待通りに動作します。

Fatal error: Uncaught exception 'Zend_Uri_Exception' with message 'Invalid URI supplied' in /usr/share/php/libzend-framework-php/Zend/Uri/Http.php:156 
Stack trace: 
#0 /usr/share/php/libzend-framework-php/Zend/Uri.php(143): Zend_Uri_Http->__construct('http', '//local_server_f...') 
#1 /usr/share/php/libzend-framework-php/Zend/Http/Client.php(270): Zend_Uri::factory('http://local_ser...') 
#2 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(266): Zend_Http_Client->setUri('http://local_ser...') 
#3 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php(361): Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request)) 
#4 /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client/ServerProxy.php(93): Zend_XmlRpc_Client->call('system.multical...', Array) 
#5 [internal function]: Zend_XmlRpc_Client_ServerProxy->__call('multicall', Array) 
#6 /path/to/xmlrpc.client.php(21): Zend_XmlRpc_Client_ServerProxy->multicall(Array) 
#7 {main} 
    thrown in /usr/share/php/libzend-framework-php/Zend/Uri/Http.php on line 156 

PHP:

ini_set("include_path", "/usr/share/php/libzend-framework-php"); 
require_once('Zend/XmlRpc/Client.php'); 

$server = new Zend_XmlRpc_Client('http://local_server_foo/xmlrpc.server.php'); 

// Get the HTTP Client used by the XMLRPC client and Increase the HTTP timeout 
$server->getHttpClient()->setConfig(array('timeout'=>30)); 

$client = $server->getProxy(); 

$request = array(
    array(
     'methodName' => 'system.listMethods', 
     'params'  => array() 
    ) 
); 

try { 
    $response = $client->system->multicall($request); 
    echo print_r($response,true); 
} catch (Zend_XmlRpc_Client_HttpException $e) { 
    echo 'HTTP Exception: '."\n"; 
    echo $e->getCode(); 
    echo $e->getMessage(); 
} catch (Zend_XmlRpc_Client_FaultException $e) { 
    echo 'Fault Exception: '."\n"; 
    echo $e->getCode(); 
    echo $e->getMessage(); 
} 

パイソン(この作品):

#!/usr/bin/python 

import xmlrpclib 

servAddr = "http://local_server_foo/xmlrpc.server.php" 

client = xmlrpclib.ServerProxy(servAddr) 

print 

methods = client.system.listMethods() 
for m in methods: 
    print m + "\tHelp Documentation: " + client.system.methodHelp(m) 
    print 

答えて

1

(関連RFCへのリンク):ホスト名にアンダースコアを持つ

The Internet standards (Request for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted.

While a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore.[3] Systems such as DomainKeys and service records use the underscore as a means to assure that their special character is not confused with hostnames. For example, _http._sctp.www.example.com specifies a service pointer for an SCTP capable webserver host (www) in the domain example.com.

が無効であり、Zend Frameworkのバリデータが正常に機能しています。

+0

そこに議論がなく、なぜ私はまだ問題を提起していません。私が見る唯一のポイントは、バリデータが上記の広範なバリデーションを持っていて、最後に "ローカルネットワーク名スキーマに対する入力をチェックする;最後に検証を渡すチャンス"というラベルのついた最後の正規表現です。なぜなら、ローカルネーミングスキーマのアンダースコアを追加しないのはなぜですか? –

+0

ローカルホスト名は、RFCによれば、下線を持つことはできません。ビジネス要件に応じてビジネス要件がある場合は、それを受け入れるカスタムバリデータを作成します。正規表現のgrokkingスキルは常に最高のわけではありませんが、 '最後のチャンス'のバリデータは、 'test.local'や 'mydevdomain'など有効なホスト名であるがtldではないドメインを確認することです。 –

+0

ありがとうございました。検証に特殊文字を許可する方法はありますか?多分オーバーライド機能? –

1

I

はPHP

エラーを回避する方法があれば知りたいと思いましたバージョン1.11.9でチェックインしました誰もまだ訴えていない。おそらく私は最終的にバグレポートを提出するべきです。 Zend_Validate_Hostnameクラスを以下の行のように修正してください。 isValid()メソッドのバージョン621(1.11.2)〜655(1.11.9)のバージョンによって異なります。

古いライン:

$regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/'; 
$status = @preg_match($regexLocal, $value); 

新しい行:

@Just Hは彼の答えで指摘するように:UDPATEだが、これを洗練してみましょうx5f

$regexLocal = '/^(([a-zA-Z0-9\x2d\x5f]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/'; 
$status = @preg_match($regexLocal, $value); 

の変化に注意してください。アンダースコアは許可されていませんが、まだあまり使用されていません。これがIBM上であり、後でNetBIOSでMicrosoftがローカルホスト名で「使用」されている理由は、許可されていないにもかかわらずです。

以前のサーバーエンジニアとして、私は大手企業で多くのイントラネットを見てきましたが、すべてホスト名にアンダースコアを使用していました。 OS/2とWindowsの管理者は、意識せずにDNS命名規則でそれらを使用しました。そのため、すべてのブラウザでサポートされており、すべてのWebサーバでサポートされています。 http://en.wikipedia.org/wiki/Hostnameから

+0

このインスタンスでZend_Validate_Hostnameの動作が正しい理由については、私の公表された回答を参照してください。パターン式を変更する代わりに –

+0

には、検証で特殊文字を使用できる方法がありますか?多分オーバーライド機能? –

+0

@Phil Zend_Validate_Hostnameまで拡張する独自のバリデータを記述します。最初に親を呼び出すisValid()メソッドを追加し、上記のような追加の検証を好みに追加します。 –

関連する問題