Wapp

Changes On Branch new-subst-algorithm
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch new-subst-algorithm Excluding Merge-Ins

This is equivalent to a diff from af9968656c to 627a5a8bbc

2019-03-06
19:43
Update the documentation on wapp-subst to acknowledge that command substitution does occur outside of quoted regions. (check-in: 72cf27176a user: drh tags: trunk)
19:32
Alternative implementation of wapp-subst that does not allow command substitution within unquoted sections. (Leaf check-in: 627a5a8bbc user: drh tags: new-subst-algorithm)
17:44
Update the fileupload.tcl example so that uploaded images are shown in-line. This demonstrates how to use the TCL "binary encode" command to generate base64 from the raw image content and how to modify content-security-policy to allow "data:" sources for images. (check-in: af9968656c user: drh tags: trunk)
2019-03-04
19:18
Fix the multipart/form-data parser so that it can accept none-file uploads. Add the "fileupload.tcl" example. (check-in: cfa2467c17 user: drh tags: trunk)

Changes to Makefile.
1
2
3
4

5
6
7
8
9
10
11
1
2
3

4
5
6
7
8
9
10
11



-
+







#!/usr/bin/make

CC = gcc -Os -static
TCLLIB = /home/drh/tcl/lib/libtcl8.6.a -lm -lz -lpthread -ldl
TCLLIB = /home/drh/tcl/lib/libtcl8.7.a -lm -lz -lpthread -ldl
TCLINC = /home/drh/tcl/include
TCLSH = tclsh

all: wapptclsh

wapptclsh: wapptclsh.c
	$(CC) -I. -I$(TCLINC) -o $@ wapptclsh.c $(TCLLIB)
Changes to wapp.tcl.
71
72
73
74
75
76
77

78
79
80







81
82
83
84
85
86
87
88
89
90
91








92
93
94
95
96
97
98
71
72
73
74
75
76
77
78



79
80
81
82
83
84
85
86
87
88
89
90
91
92




93
94
95
96
97
98
99
100
101
102
103
104
105
106
107







+
-
-
-
+
+
+
+
+
+
+







-
-
-
-
+
+
+
+
+
+
+
+







#
# The %unsafe substitution should be avoided whenever possible, obviously.
# In addition to the substitutions above, the text also does backslash
# escapes.
#
proc wapp-subst {txt} {
  global wapp
  set txt [subst -novar -nocom $txt]
  regsub -all {%(html|url|qp|string|unsafe){1,1}?(|%)\((.+)\)\2} $txt \
         {[wappInt-enc-\1 "\3"]} txt
  dict append wapp .reply [uplevel 1 [list subst -novariables $txt]]
  while {[regexp {^(.*?)%(html|url|qp|string|unsafe)(|%)\((.+?)\)\3(.*)$} \
          $txt all before verb m1 arg after]} {
    set arg [uplevel 1 [list subst $arg]]
    dict append wapp .reply $before[wappInt-enc-$verb $arg]
    set txt $after
  }
  dict append wapp .reply $txt
}

# Works like wapp-subst, but also removes whitespace from the beginning
# of lines.
#
proc wapp-trim {txt} {
  global wapp
  regsub -all {\n\s+} [string trim $txt] \n txt
  regsub -all {%(html|url|qp|string|unsafe){1,1}?(|%)\((.+)\)\2} $txt \
         {[wappInt-enc-\1 "\3"]} txt
  dict append wapp .reply [uplevel 1 [list subst -novariables $txt]]
  regsub -all {\n\s+} [subst -nocom -novar [string trim $txt]] \n txt
  while {[regexp {^(.*?)%(html|url|qp|string|unsafe)(|%)\((.+?)\)\3(.*)$} \
          $txt all before verb m1 arg after]} {
    set arg [uplevel 1 [list subst $arg]]
    dict append wapp .reply $before[wappInt-enc-$verb $arg]
    set txt $after
  }
  dict append wapp .reply $txt
}

# There must be a wappInt-enc-NAME routine for each possible substitution
# in wapp-subst.  Thus there are routines for "html", "url", "qp", and "unsafe".
#
#    wappInt-enc-html           Escape text so that it is safe to use in the
#                               body of an HTML document.