There's about an 8k limit on variable size in rc. This leads to about
a 5-7k limit on post size when posting via dirdir's or blagh's web
interface, because of http form encoding. I tried to set up werc for a
person who's blog posts are often much longer than 8k. :)
The fix to rc has only partially been discovered [1] and has not been
submitted to Plan 9's maintainers, never mind p9p or 9base.
[1] http://9fans.net/archive/2009/03/410
I tried instead to work around rc's limit. I've had some success, but
it was rather beyond my limit and I'm throwing in the towel now. What
I came up with is a function which reads form-encoded data from stdin
splitting it on url-encoded newline characters so that each post_arg_*
variable becomes a list of url-encoded lines. They remain url-encoded
because, for large submissions, it's more efficient to run one
instance of awk to urldecode the contents of the entire list as it is
sent to a file rather than run awk once for each line. This part is
easy enough. For example, in dirdir/app.rc, function save_page, A
below changes to B.
A: echo $post_arg_edit_text > $dirdir_file
B: for(line in $post_arg_edit_text) echo $line | urldecode >
$dirdir_file
Basically, any instance of:
echo $post_arg_edit_text
changes to:
for(line in $post_arg_edit_text) echo $line | urldecode
What I haven't done is found where to put the reading-and-splitting
function. I've had enough of the whole problem right now. Posting the
function below, with test code, in case anyone wants to take a look.
If you want raw form-encoded data to test it on, feel free to use and
abuse [2]
[2] http://analytical-reengineering.dre.am/form-test
fn post_args_long {
# Do not replace this awk with sed. sed truncates very long lines.
# Also, there's no way this script should work as well as it does,
# so don't change the order of the gsubs or remove the bit in parens
# unless you're prepared to find a saner way to replace only the first
# %0a of a sequence of them.
tmplist = `{awk '
{
gsub(/%0[aA](%0[aA])*/, "\n\1")
gsub(/%0[dD]/, "")
print
}
'}
post_arg_names = ()
var = post_arg_unexpected
ifs='
' for(tmp in $tmplist) {
switch($tmp) {
case *['=&']*
ifs='&' for(pair in $tmp) {
ifs='=' {pair = `{echo -n $pair | tr -d '&'}}
switch($#pair) {
case 1
$var = ($$var $pair)
case 2
var = post_arg_ ^ $pair(1)
$var = $pair(2)
post_arg_names = ($post_arg_names $var)
}
}
case *
$var = ($$var $tmp)
}
}
tmplist = ()
}
# test:
post_args_long
#env | grep '^post_arg'
for(var in $post_arg_names) {
echo '[[[ ' $var ' ]]]'
for(line in $$var) echo $line
} | awk -f bin/contrib/urldecode.awk
--
You received this message because you are subscribed to the Google Groups
"werc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/werc9?hl=en.