summaryrefslogtreecommitdiff
path: root/sys/src/cmd
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@rei2.9hal>2011-11-06 15:19:02 +0100
committercinap_lenrek <cinap_lenrek@rei2.9hal>2011-11-06 15:19:02 +0100
commit183a08bc9529b372e20600ad9898565ff3e55201 (patch)
treef8e106ccf794f89881b5a91a62b5b42dfc39792b /sys/src/cmd
parent409ed0d9661cd101cd3d9a342e862a46cd3b0c3a (diff)
mothra: support <video>, <object>, <input type=password> and <meta http-equiv=refresh>
Diffstat (limited to 'sys/src/cmd')
-rw-r--r--sys/src/cmd/mothra/forms.c59
-rw-r--r--sys/src/cmd/mothra/html.h2
-rw-r--r--sys/src/cmd/mothra/html.syntax.c2
-rw-r--r--sys/src/cmd/mothra/libpanel/entry.c17
-rw-r--r--sys/src/cmd/mothra/rdhtml.c46
5 files changed, 92 insertions, 34 deletions
diff --git a/sys/src/cmd/mothra/forms.c b/sys/src/cmd/mothra/forms.c
index 1ad04d2a0..cc246381c 100644
--- a/sys/src/cmd/mothra/forms.c
+++ b/sys/src/cmd/mothra/forms.c
@@ -150,29 +150,12 @@ void rdform(Hglob *g){
else
f->maxlength=atoi(s);
s=pl_getattr(g->attr, "type");
- if(g->tag == Tag_button && (s==0 || cistrcmp(s, "reset") || cistrcmp(s, "button")))
- s = "submit";
- if(s==0 || cistrcmp(s, "text")==0 ||
- cistrcmp(s, "password")==0 || cistrcmp(s, "int")==0 ||
- cistrcmp(s, "email")==0){
- s=pl_getattr(g->attr, "name");
- if(s!=0 && strcmp(s, "isindex")==0)
- f->type=INDEX;
- else
- f->type=TYPEIN;
- /*
- * If there's exactly one attribute, use its value as the name,
- * regardless of the attribute name. This makes
- * http://linus.att.com/ias/puborder.html work.
- */
- if(s==0){
- if(g->attr[0].name && g->attr[1].name==0)
- f->name=strdup(g->attr[0].value);
- else
- f->name=strdup("no-name");
- }
- }
- else if(cistrcmp(s, "checkbox")==0)
+ if((g->tag == Tag_button) &&
+ (s==0 || cistrcmp(s, "reset") || cistrcmp(s, "button")))
+ s="submit";
+ else if(s==0)
+ s="text";
+ if(cistrcmp(s, "checkbox")==0)
f->type=CHECK;
else if(cistrcmp(s, "radio")==0)
f->type=RADIO;
@@ -191,8 +174,25 @@ void rdform(Hglob *g){
f->type=RESET;
else if(cistrcmp(s, "hidden")==0)
f->type=HIDDEN;
- else
+ else{
f->type=TYPEIN;
+ if(cistrcmp(s, "password")==0)
+ f->type=PASSWD;
+ /*
+ * If there's exactly one attribute, use its value as the name,
+ * regardless of the attribute name. This makes
+ * http://linus.att.com/ias/puborder.html work.
+ */
+ s=f->name;
+ if(s && cistrcmp(s, "isindex")==0)
+ f->type=INDEX;
+ if(s==0){
+ if(g->attr[0].name && g->attr[1].name==0)
+ f->name=strdup(g->attr[0].value);
+ else
+ f->name=strdup("no-name");
+ }
+ }
if((f->type==CHECK || f->type==RADIO) && !pl_hasattr(g->attr, "value")){
free(f->value);
f->value=strdup("on");
@@ -341,6 +341,9 @@ void mkfieldpanel(Rtext *t){
case TYPEIN:
f->p=plentry(0, 0, f->size*chrwidth, f->value, h_submittype);
break;
+ case PASSWD:
+ f->p=plentry(0, 1, f->size*chrwidth, f->value, h_submittype);
+ break;
case CHECK:
f->p=plcheckbutton(0, 0, "", h_checkinput);
f->state=f->checked;
@@ -433,9 +436,11 @@ void h_resetinput(Panel *p, int){
Option *o;
for(f=((Field *)p->userp)->form->fields;f;f=f->next) switch(f->type){
case TYPEIN:
- case PASSWD:
plinitentry(f->p, 0, f->size*chrwidth, f->value, 0);
break;
+ case PASSWD:
+ plinitentry(f->p, 1, f->size*chrwidth, f->value, 0);
+ break;
case CHECK:
case RADIO:
f->state=f->checked;
@@ -530,7 +535,9 @@ void h_submittype(Panel *p, char *){
int ntype;
Field *f;
ntype=0;
- for(f=((Field *)p->userp)->form->fields;f;f=f->next) if(f->type==TYPEIN) ntype++;
+ for(f=((Field *)p->userp)->form->fields;f;f=f->next)
+ if(f->type==TYPEIN || f->type==PASSWD)
+ ntype++;
if(ntype==1) h_submitinput(p, 0);
}
void h_submitindex(Panel *p, char *){
diff --git a/sys/src/cmd/mothra/html.h b/sys/src/cmd/mothra/html.h
index f9d4926ad..ad287ef8b 100644
--- a/sys/src/cmd/mothra/html.h
+++ b/sys/src/cmd/mothra/html.h
@@ -178,6 +178,8 @@ enum{
Tag_table, /* rm 3.8.00 */
Tag_td,
Tag_tr,
+ Tag_video,
+ Tag_object,
Tag_script,
Tag_style,
Tag_end, /* also used to indicate unrecognized start tag */
diff --git a/sys/src/cmd/mothra/html.syntax.c b/sys/src/cmd/mothra/html.syntax.c
index 9677d60f7..5f1e459d2 100644
--- a/sys/src/cmd/mothra/html.syntax.c
+++ b/sys/src/cmd/mothra/html.syntax.c
@@ -53,6 +53,8 @@ Tag tag[]={
[Tag_plaintext] "plaintext", NOEND,
[Tag_pre] "pre", END,
[Tag_samp] "samp", END,
+[Tag_video] "video", NOEND,
+[Tag_object] "object", END,
[Tag_script] "script", END,
[Tag_style] "style", END,
[Tag_select] "select", END,
diff --git a/sys/src/cmd/mothra/libpanel/entry.c b/sys/src/cmd/mothra/libpanel/entry.c
index 984faa7d1..556181305 100644
--- a/sys/src/cmd/mothra/libpanel/entry.c
+++ b/sys/src/cmd/mothra/libpanel/entry.c
@@ -18,12 +18,23 @@ struct Entry{
void pl_drawentry(Panel *p){
Rectangle r;
Entry *ep;
+ char *s;
+
ep=p->data;
r=pl_box(p->b, p->r, p->state);
- if(stringwidth(font, ep->entry)<=r.max.x-r.min.x)
- pl_drawicon(p->b, r, PLACEW, 0, ep->entry);
+ s=ep->entry;
+ if(p->flags & 1){
+ char *p;
+ s=strdup(s);
+ for(p=s; *p; p++)
+ *p='*';
+ }
+ if(stringwidth(font, s)<=r.max.x-r.min.x)
+ pl_drawicon(p->b, r, PLACEW, 0, s);
else
- pl_drawicon(p->b, r, PLACEE, 0, ep->entry);
+ pl_drawicon(p->b, r, PLACEE, 0, s);
+ if(s != ep->entry)
+ free(s);
}
int pl_hitentry(Panel *p, Mouse *m){
int oldstate;
diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c
index 96407ac04..6cce1946d 100644
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -241,6 +241,24 @@ int pl_nextc(Hglob *g){
}
return c;
}
+char *unquot(char *dst, char *src, int len){
+ char *e;
+
+ e=0;
+ while(strchr("\n\r\t ", *src))
+ src++;
+ if(*src=='\'' || *src=='"'){
+ e=strrchr(src+1, *src);
+ src++;
+ }
+ if(e==0) e=strchr(src, 0);
+ len--;
+ if((e - src) < len)
+ len=e-src;
+ if(len>0) memmove(dst, src, len);
+ dst[len]=0;
+ return dst;
+}
int entchar(int c){
return c=='#' || 'a'<=c && c<='z' || 'A'<=c && c<='Z' || '0'<=c && c<='9';
}
@@ -643,8 +661,6 @@ void plrdhtml(char *name, int fd, Www *dst){
break;
case Tag_end: /* unrecognized start tag */
break;
- case Tag_meta:
- break;
case Tag_img:
if(str=pl_getattr(g.attr, "src"))
strncpy(g.state->image, str, sizeof(g.state->image));
@@ -696,19 +712,38 @@ void plrdhtml(char *name, int fd, Www *dst){
pl_htmloutput(&g, 0, "", 0);
}
break;
+ case Tag_meta:
+ if((str=pl_getattr(g.attr, "http-equiv"))==0)
+ break;
+ if(cistrcmp(str, "refresh"))
+ break;
+ if((str=pl_getattr(g.attr, "content"))==0)
+ break;
+ if((str=strchr(str, '='))==0)
+ break;
+ str++;
+ str=unquot(g.state->link, str, sizeof(g.state->link));
+ pl_htmloutput(&g, 0, "refresh: ", 0);
+ pl_htmloutput(&g, 0, str, 0);
+ g.state->link[0]=0;
+ g.linebrk=1;
+ g.spacc=0;
+ break;
+ case Tag_video:
case Tag_frame:
- pl_htmloutput(&g, 0, "FRAME: ", 0);
if(str=pl_getattr(g.attr, "src"))
strncpy(g.state->link, str, sizeof(g.state->link));
if(str=pl_getattr(g.attr, "name"))
strncpy(g.state->name, str, sizeof(g.state->name));
else
str = g.state->link;
+ pl_htmloutput(&g, 0, tag[g.tag].name, 0);
+ pl_htmloutput(&g, 0, ": ", 0);
pl_htmloutput(&g, 0, str, 0);
g.state->link[0]=0;
- g.state->name[0] =0;
- g.spacc=0;
+ g.state->name[0]=0;
g.linebrk=1;
+ g.spacc=0;
break;
case Tag_address:
g.spacc=0;
@@ -904,6 +939,7 @@ void plrdhtml(char *name, int fd, Www *dst){
rdform(&g);
break;
case Tag_script:
+ case Tag_object:
case Tag_style:
/*
* ignore the content of these tags, eat tokens until we