Skip to content
Browse files

Escape XML characters in output and make default handling of values f…

…or RF to be strings
  • Loading branch information...
1 parent 6e1bcaf commit 333ee6c92d6940545ca798de4407a28f83706489 @semperos committed
Showing with 15 additions and 7 deletions.
  1. +11 −4 src/robot_remote_server/core.clj
  2. +4 −3 src/robot_remote_server/util.clj
View
15 src/robot_remote_server/core.clj
@@ -20,7 +20,8 @@
(ns robot-remote-server.core
(:require [necessary-evil.core :as xml-rpc]
[clojure.string :as str])
- (:import org.mortbay.jetty.Server)
+ (:import org.mortbay.jetty.Server
+ org.apache.commons.lang.StringEscapeUtils)
(:use robot-remote-server.util
ring.adapter.jetty))
@@ -90,12 +91,18 @@
a-fn (find-kw-fn a-ns clj-kw-name)
output (with-out-str (try
(swap! result assoc :return
- (handle-return-val (apply a-fn args)))
+ (->> (apply a-fn args)
+ handle-return-val
+ StringEscapeUtils/escapeXml))
(catch Exception e
(swap! result assoc
:status "FAIL"
- :error (with-out-str (prn e))
- :traceback (with-out-str (.printStackTrace e)))
+ :error (->> (prn e)
+ with-out-str
+ StringEscapeUtils/escapeXml)
+ :traceback (->> (.printStackTrace e)
+ with-out-str
+ StringEscapeUtils/escapeXml))
@result)))]
(swap! result assoc :output output)
@result)))
View
7 src/robot_remote_server/util.clj
@@ -1,4 +1,5 @@
-(ns robot-remote-server.util)
+(ns robot-remote-server.util
+ (:require [clojure.string :as str]))
(defn handle-return-val
"Convert everything to RobotFramework-acceptable types. See implementations in other languages for examples"
@@ -8,7 +9,7 @@
(number? ret) ret
(map? ret) (into {}
(for [[k v] ret]
- [(.toString k) (handle-return-val v)]))
+ [(str k) (handle-return-val v)]))
(coll? ret) (map handle-return-val ret)
(nil? ret) ""
- :else ret))
+ :else (str ret)))

0 comments on commit 333ee6c

Please sign in to comment.
Something went wrong with that request. Please try again.