Fork me on GitHub
#clojure
<
2020-05-16
>
gleisonsilva00:05:01

Hello, guys! May you can help me... I'm trying to use Selmer to generate some XML files where I need to replace some variables... I have a XML template file and it working, except for this: Selmer is changing all tag names to lower-case... but I need to preserve the case. Do you know if thats is possible? How can I do?

seancorfield02:05:58

@gleisonsilva Selmer doesn't change any of the template. It just substitutes the variables.

seancorfield02:05:15

So if the tag names really are getting converted to lower case, it's something else...

gleisonsilva10:05:05

Hello, @U04V70XH6! In fact, I'm not using Selmer directly, but via Bootleg... so maybe it's the point. I'll investigate more. Tks a lot for replying!

pbaille06:05:37

I don't understand this behavior, and you?

(= (update-in {:a 1} [] assoc :b 1)
   {:a 1, nil {:b 1}})

pbaille06:05:25

could update-in be implemented this way?

(defn update-in
  [m ks f & args]
  (letfn [(up [m ks]
            (if-not (seq ks)
              (apply f m args)
              (let [[k & ks] ks]
                (assoc m k (up (get m k) ks)))))]
    (up m ks)))

pbaille07:05:59

thank you for the links @leonel.gayard

vlaaad18:05:06

(into [] (halt-when #{4}) (range 10))
=> Execution error (ClassCastException)
=> class java.lang.Long cannot be cast to class clojure.lang.ITransientCollection

vlaaad18:05:42

I guess halt-when is not supposed to be used in into context as is (it has additional arity that can return an acc so far)

vlaaad18:05:49

it works fine in transduce though:

(transduce (halt-when #{4}) conj [] (range 10)) => 4

MatthewLisp19:05:04

Clojurists, If you had this fn:

(fn [x] (map #(Integer. (str %)) (str (clojure.edn/read-string x))))
can you think of any 'malicious' input? besides making it raise a fixed set of exceptions of your choice

dpsutton20:05:59

Why not just chop the string on spaces and parseint?

hiredman21:05:39

It is bizarre

hiredman21:05:37

Hard to even tell what the intent is, but I think it is trying to parse a string of digits as integers

hiredman21:05:56

read-string returning a number, the number turned into a string, then mapping a function which turns each character into a string, then parses each character as an integer

hiredman21:05:29

Calling str on the result of read string being entirely redundant.

MatthewLisp21:05:01

Yes, it’s a redundant function, I noticed that, I was trying to figure out if the function could receive something dangerous combining edn/read-string + Integer.

MatthewLisp21:05:37

But there’s nothing to worry I think

MatthewLisp21:05:58

The only real danger would be if there’s a Clojure.core/read-string or eval on a wrapper function or somewhere else