xcapclient 1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = XCAPClient (version 1.2)
1
+ = XCAPClient (version 1.2.1)
2
2
 
3
3
  * http://dev.sipdoc.net/projects/ruby-xcapclient/wiki/
4
4
  * http://rubyforge.org/projects/xcapclient/
data/lib/xcapclient.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module XCAPClient
2
2
 
3
- VERSION = "1.2"
3
+ VERSION = "1.2.1"
4
4
 
5
5
  RUBY_VERSION_CORE = case RUBY_VERSION
6
6
  when /^1\.9\./
@@ -128,7 +128,7 @@ module XCAPClient
128
128
 
129
129
  @identity_header = conf[:identity_header].freeze
130
130
  @identity_user = ( conf[:identity_user].freeze || @user ) if @identity_header
131
- COMMON_HEADERS[@identity_header] = @identity_user if @identity_header
131
+ COMMON_HEADERS[@identity_header] = '"' + @identity_user + '"' if @identity_header
132
132
 
133
133
  # Initialize the HTTP client.
134
134
  @http_client = HTTPClient.new
@@ -429,7 +429,8 @@ module XCAPClient
429
429
  # the document stored in the server. This methods allows the client
430
430
  # to fetch these namespaces and prefixes.
431
431
  #
432
- # Related documentation: {RFC 4825 section 7.10}[http://tools.ietf.org/html/rfc4825#section-7.10], {RFC 4825 section 10}[http://tools.ietf.org/html/rfc4825#section-10]
432
+ # Related documentation: {RFC 4825 section 7.10}[http://tools.ietf.org/html/rfc4825#section-7.10],
433
+ # {RFC 4825 section 10}[http://tools.ietf.org/html/rfc4825#section-10]
433
434
  #
434
435
  # Example:
435
436
  #
@@ -471,15 +472,16 @@ module XCAPClient
471
472
  #
472
473
  # Related documentation: {RFC 4825 section 12}[http://tools.ietf.org/html/rfc4825#section-12]
473
474
  #
474
- # If Nokogiri[http://wiki.github.com/tenderlove/nokogiri] is available the method returns an Array containing the auids. If not, the response body is returned as a String.
475
+ # If Nokogiri[http://wiki.github.com/tenderlove/nokogiri] is available the method returns an
476
+ # Array containing the auids. If not, the response body is returned as a String.
475
477
  #
476
478
  def get_xcap_auids
477
479
 
478
- body = get_node("xcap-caps", nil, '/xcap-caps/auids')
480
+ body = get_node("xcap-caps", nil, 'xcap-caps/auids')
479
481
 
480
482
  return case NOKOGIRI_INSTALLED
481
483
  when true
482
- parse(body).xpath("/auids/auid", {"xmlns" => XCAP_CAPS_XMLNS}).map {|auid| auid.content}
484
+ parse(body).xpath("auids/auid", {"xmlns" => XCAP_CAPS_XMLNS}).map {|auid| auid.content}
483
485
  when false
484
486
  body
485
487
  end
@@ -493,11 +495,11 @@ module XCAPClient
493
495
  #
494
496
  def get_xcap_extensions
495
497
 
496
- body = get_node("xcap-caps", nil, '/xcap-caps/extensions')
498
+ body = get_node("xcap-caps", nil, 'xcap-caps/extensions')
497
499
 
498
500
  return case NOKOGIRI_INSTALLED
499
501
  when true
500
- parse(body).xpath("/extensions/extension", {"xmlns" => XCAP_CAPS_XMLNS}).map {|extension| extension.content}
502
+ parse(body).xpath("extensions/extension", {"xmlns" => XCAP_CAPS_XMLNS}).map {|extension| extension.content}
501
503
  when false
502
504
  body
503
505
  end
@@ -511,11 +513,11 @@ module XCAPClient
511
513
  #
512
514
  def get_xcap_namespaces
513
515
 
514
- body = get_node("xcap-caps", nil, '/xcap-caps/namespaces')
516
+ body = get_node("xcap-caps", nil, 'xcap-caps/namespaces')
515
517
 
516
518
  return case NOKOGIRI_INSTALLED
517
519
  when true
518
- parse(body).xpath("/namespaces/namespace", {"xmlns" => XCAP_CAPS_XMLNS}).map {|namespace| namespace.content}
520
+ parse(body).xpath("namespaces/namespace", {"xmlns" => XCAP_CAPS_XMLNS}).map {|namespace| namespace.content}
519
521
  when false
520
522
  body
521
523
  end
@@ -651,12 +653,18 @@ module XCAPClient
651
653
  end # def send_request
652
654
 
653
655
 
656
+ # http://tools.ietf.org/html/rfc3986#section-3.3
657
+ # I add "/" and "@" as they must not be escaped.
658
+ # I remove "&", "?" so they must be escaped now.
659
+ ESCAPE_CHARS = "[^a-zA-Z0-9\\-._~!$&'()*+,=:;/@]"
660
+
654
661
  def percent_encode(str)
662
+ ### NOTE: I've removed "&", "?" so they must be escaped now.
655
663
  return case RUBY_VERSION_CORE
656
664
  when :RUBY_1_9
657
- str.dup.force_encoding('ASCII-8BIT').gsub(/[^a-zA-Z0-9\.,:;\-_?!@$&=+*\/~'()]/) { '%%%02x' % $&.ord }
665
+ str.dup.force_encoding('ASCII-8BIT').gsub(/#{ESCAPE_CHARS}/) { '%%%02x' % $&.ord }
658
666
  when :RUBY_1_8
659
- str.gsub(/[^a-zA-Z0-9\.,:;\-_?!@$&=+*\/~'()]/n) {|s| sprintf('%%%02x', s[0]) }
667
+ str.gsub(/#{ESCAPE_CHARS}/n) {|s| sprintf('%%%02x', s[0]) }
660
668
  end
661
669
  end
662
670
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcapclient
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "I\xC3\xB1aki Baz Castillo"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-23 00:00:00 +01:00
12
+ date: 2009-11-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency