--- /sys/src/cmd/aux/htmlsanitize.c +++ /sys/src/cmd/aux/htmlsanitize.c @@ -0,0 +1,56 @@ +/* + * Because sed can't handle really long lines. + */ +#include +#include +#include + +Biobuf bout; + +void +cat(Biobuf *b) +{ + int c; + + while((c = Bgetrune(b)) >= 0){ + switch(c){ + case '<': + Bprint(&bout, "<"); + break; + case '>': + Bprint(&bout, ">"); + break; + case '&': + Bprint(&bout, "&"); + break; + default: + Bputrune(&bout, c); + break; + } + } +} + +void +main(int argc, char *argv[]) +{ + int i; + Biobuf *b, bin; + + argv0 = "htmlsanitize"; + Binit(&bout, 1, OWRITE); + if(argc == 1){ + Binit(&bin, 0, OREAD); + cat(&bin); + } + else for(i=1; i