summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-03-10 11:18:01 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-03-10 11:18:01 -0400
commita8f3cc9e254122906318531ef39b5cae89829ef4 (patch)
tree99e4bdad36025df9b3bd37c782f9dd36f052307a /src
parent5646b9630eb86f0d4f393dce6b7fc76cea87421f (diff)
React demo
Diffstat (limited to 'src')
-rw-r--r--src/c/urweb.c6
-rw-r--r--src/cjr_print.sml5
-rw-r--r--src/scriptcheck.sml8
3 files changed, 11 insertions, 8 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 823e8824..d42cfaa6 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -382,11 +382,9 @@ void uw_write_script(uw_context ctx, uw_Basis_string s) {
ctx->script_front += len;
}
-char *uw_Basis_get_script(uw_context ctx, uw_unit u) {
+const char *uw_Basis_get_script(uw_context ctx, uw_unit u) {
if (ctx->script_front == ctx->script) {
- char *r = uw_malloc(ctx, 1);
- r[0] = 0;
- return r;
+ return ctx->script_header;
} else {
char *r = uw_malloc(ctx, 41 + (ctx->script_front - ctx->script) + strlen(ctx->script_header));
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index ab808426..4b6a56db 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -2349,7 +2349,10 @@ fun p_file env (ds, ps) =
newline,
string "uw_set_script_header(ctx, \"",
string (case side of
- ServerAndClient => "<script src=\\\"/app.js\\\"></script>\\n"
+ ServerAndClient => "<script src=\\\""
+ ^ OS.Path.joinDirFile {dir = !Monoize.urlPrefix,
+ file = "app.js"}
+ ^ "\\\"></script>\\n"
| ServerOnly => ""),
string "\");",
newline]),
diff --git a/src/scriptcheck.sml b/src/scriptcheck.sml
index bfe87766..fd4f4cd9 100644
--- a/src/scriptcheck.sml
+++ b/src/scriptcheck.sml
@@ -38,8 +38,10 @@ structure IS = IntBinarySet
val csBasis = SS.addList (SS.empty,
["new_client_source",
"get_client_source",
- "set_client_source",
- "alert"])
+ "set_client_source"])
+
+val scriptWords = ["<script",
+ " onclick="]
fun classify (ds, ps) =
let
@@ -54,7 +56,7 @@ fun classify (ds, ps) =
let
fun hasClient e =
case #1 e of
- EPrim (Prim.String s) => inString {needle = "<script", haystack = s}
+ EPrim (Prim.String s) => List.exists (fn n => inString {needle = n, haystack = s}) scriptWords
| EPrim _ => false
| ERel _ => false
| ENamed n => IS.member (csids, n)