incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Fixed PEM key format in Keys
Date Tue, 19 Oct 2010 12:37:47 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 .../lib/deltacloud/helpers/application_helper.rb   |    7 +++++--
 server/server.rb                                   |    2 +-
 server/views/keys/show.xml.haml                    |    5 ++---
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/server/lib/deltacloud/helpers/application_helper.rb b/server/lib/deltacloud/helpers/application_helper.rb
index cb1878d..c7fa481 100644
--- a/server/lib/deltacloud/helpers/application_helper.rb
+++ b/server/lib/deltacloud/helpers/application_helper.rb
@@ -115,8 +115,11 @@ module ApplicationHelper
 
   def cdata(&block)
     text = capture_haml(&block)
-    text.gsub!("\n", "\n ")
-    "<![CDATA[\n #{text}\n]]>"
+    "<![CDATA[#{text.strip}]]>"
+  end
+
+  def render_cdata(text)
+    "<pem><![CDATA[#{text.strip}]]></pem>"
   end
 
 end
diff --git a/server/server.rb b/server/server.rb
index bf476f6..af8bc09 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -346,7 +346,7 @@ collection :keys do
       @key = driver.create_key(credentials, { :key_name => params[:name] })
       respond_to do |format|
         format.html { haml :"keys/show" }
-        format.xml { haml :"keys/show" }
+        format.xml { haml :"keys/show", :ugly => true }
       end
     end
   end
diff --git a/server/views/keys/show.xml.haml b/server/views/keys/show.xml.haml
index 58a494d..b3659b0 100644
--- a/server/views/keys/show.xml.haml
+++ b/server/views/keys/show.xml.haml
@@ -8,9 +8,8 @@
     %fingerprint<
       =@key.fingerprint
     - unless @key.pem_rsa_key.nil?
-      %pem<
-        =cdata do
-          =@key.pem_rsa_key
+      %pem
+        ~render_cdata(@key.pem_rsa_key)
   - if @key.is_password?
     %username<
       =cdata do
-- 
1.7.2.3


Mime
View raw message