Commit 3eaefd44 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

uri chars fix

parent 4b8baef1
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foam.mongoose"
android:versionCode="19"
android:versionName="1.4">
android:versionCode="20"
android:versionName="1.5">
<application android:label="@string/app_name"
android:icon="@drawable/logo"
android:theme="@style/StarwispTheme"
......
......@@ -46,14 +46,14 @@
(define (fold-entity fn db table entity-id)
(let* ((entity-type (get-entity-type db table entity-id)))
(cond
((null? entity-type) (msg "entity" entity-id "not found!") '())
(else
(foldl
(lambda (kt r)
(let ((vd (get-value db table entity-id kt)))
(fn kt vd r)))
'()
(reverse (get-attribute-ids/types db table entity-type)))))))
((null? entity-type) (msg "entity" entity-id "not found!") '())
(else
(foldl
(lambda (kt r)
(let ((vd (get-value db table entity-id kt)))
(fn kt vd r)))
'()
(reverse (get-attribute-ids/types db table entity-type)))))))
;; get an entire entity, as a list of key/value pairs
......@@ -115,7 +115,7 @@
(let ((s (db-select
db (string-append "select e.entity_id from " table "_entity as e "
"join " table "_value_varchar "
" as n on n.entity_id = e.entity_id and n.attribute_id = ?"
" as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? "
......@@ -134,9 +134,9 @@
(let ((s (db-select
db (string-append "select e.entity_id from " table "_entity as e "
"join " table "_value_varchar "
" as n on n.entity_id = e.entity_id and n.attribute_id = ?"
" as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"join " table "_value_varchar "
" as p on p.entity_id = e.entity_id and p.attribute_id = ?"
" as p on p.entity_id = e.entity_id and p.attribute_id = ? "
"left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? and "
......
......@@ -99,7 +99,7 @@
(let ((s (db-select
db (string-append
"select * from " table "_attribute where entity_type = ?")
entity-type)))
entity-type)))
(if (null? s) '()
(map
(lambda (row)
......
......@@ -25,6 +25,10 @@
(ktv-value (car ktv-list)))
(else (ktv-get (cdr ktv-list) key))))
;; todo: why are the fast versions switched off?
;; presumably not on raspberry pi - bugger.
;; do something with racket-fix.scm...
;(define (ktv-get ktv-list key)
; (let ((k (assoc-string-fast key ktv-list)))
; (if k (ktv-value k) #f)))
......
......@@ -68,15 +68,50 @@
(number->string (ktv-value ktv))
(ktv-value ktv)))))
;; filter uri chars
(define (filter-uri-chars s)
(list->string
(filter
(lambda (v)
(not (or
(eqv? v #\newline)
(eqv? v #\!)
(eqv? v #\*)
(eqv? v #\')
(eqv? v #\()
(eqv? v #\))
(eqv? v #\;)
;; (eqv? v #\:)
(eqv? v #\@)
(eqv? v #\&)
(eqv? v #\=)
(eqv? v #\+)
(eqv? v #\$)
;; (eqv? v #\,)
(eqv? v #\/)
(eqv? v #\?)
(eqv? v #\#)
(eqv? v #\[)
(eqv? v #\]))))
(string->list s))))
(msg "TESTING FILTER URI CHARS")
(msg (filter-uri-chars "1234"))
(msg (filter-uri-chars "12&34"))
(msg (filter-uri-chars "1\
234"))
(msg (filter-uri-chars "12[[]]34"))
;; stringify based on type (for url)
(define (stringify-value-url ktv)
(cond
((null? (ktv-value ktv)) "NULL")
((equal? (ktv-type ktv) "varchar") (ktv-value ktv))
(else
(if (not (string? (ktv-value ktv)))
(number->string (ktv-value ktv))
(ktv-value ktv)))))
(filter-uri-chars
(cond
((null? (ktv-value ktv)) "NULL")
((equal? (ktv-type ktv) "varchar") (ktv-value ktv))
(else
(if (not (string? (ktv-value ktv)))
(number->string (ktv-value ktv))
(ktv-value ktv))))))
;; tests...
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment