Wapp

Diff
Login

Differences From Artifact [ae1503e99b]:

To Artifact [8df152630f]:


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
#
# 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

  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]]
}

# 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]]
}

# 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.







>
|
>
>
|
>
>
|







|
|
>
>
|
>
>
|







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]
  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+} [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.