505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
rid = db_int(0, "SELECT rid FROM vcache"
" WHERE vid=%d AND fname=%Q", vid, zName);
if( rid && content_get(rid, pContent)==0 ){
rid = 0;
}
return rid;
}
/*
** Transfer content to the output. During the transfer, when text of
** the following form is seen:
**
** href="$ROOT/
** action="$ROOT/
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
rid = db_int(0, "SELECT rid FROM vcache"
" WHERE vid=%d AND fname=%Q", vid, zName);
if( rid && content_get(rid, pContent)==0 ){
rid = 0;
}
return rid;
}
/*
** Check to verify that z[i] is contained within HTML markup.
**
** This works by looking backwards in the string for the most recent
** '<' or '>' character. If a '<' is found first, then we assume that
** z[i] is within markup. If a '>' is seen or neither character is seen,
** then z[i] is not within markup.
*/
static int isWithinHtmlMarkup(const char *z, int i){
while( i>=0 && z[i]!='>' && z[i]!='<' ){ i--; }
return z[i]=='<';
}
/*
** Check to see if z[i] is contained within an href='...' of markup.
*/
static int isWithinHref(const char *z, int i){
while( i>5
&& !fossil_isspace(z[i])
&& z[i]!='\'' && z[i]!='"'
&& z[i]!='>'
){ i--; }
if( i<=6 ) return 0;
if( z[i]!='\'' && z[i]!='\"' ) return 0;
if( strncmp(&z[i-5],"href=",5)!=0 ) return 0;
if( !fossil_isspace(z[i-6]) ) return 0;
return 1;
}
/*
** Transfer content to the output. During the transfer, when text of
** the following form is seen:
**
** href="$ROOT/
** action="$ROOT/
|
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
for(base=0, i=7; i<n; i++){
if( z[i]=='$'
&& strncmp(&z[i],"$ROOT/", 6)==0
&& (z[i-1]=='\'' || z[i-1]=='"')
&& i-base>=9
&& ((fossil_strnicmp(&z[i-6],"href=",5)==0 && fossil_isspace(z[i-7])) ||
(fossil_strnicmp(&z[i-8],"action=",7)==0 && fossil_isspace(z[i-9])) )
){
blob_append(cgi_output_blob(), &z[base], i-base);
blob_appendf(cgi_output_blob(), "%R");
base = i+5;
}
}
blob_append(cgi_output_blob(), &z[base], i-base);
}
/*
** Render a document as the reply to the HTTP request. The body
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
for(base=0, i=7; i<n; i++){
if( z[i]=='$'
&& strncmp(&z[i],"$ROOT/", 6)==0
&& (z[i-1]=='\'' || z[i-1]=='"')
&& i-base>=9
&& ((fossil_strnicmp(&z[i-6],"href=",5)==0 && fossil_isspace(z[i-7])) ||
(fossil_strnicmp(&z[i-8],"action=",7)==0 && fossil_isspace(z[i-9])) )
&& isWithinHtmlMarkup(z, i-6)
){
blob_append(cgi_output_blob(), &z[base], i-base);
blob_appendf(cgi_output_blob(), "%R");
base = i+5;
}else
if( z[i]=='$'
&& strncmp(&z[i-5],"/doc/$SELF/", 11)==0
&& isWithinHref(z,i-5)
&& isWithinHtmlMarkup(z, i-5)
&& strncmp(g.zPath, "doc/",4)==0
){
int j;
for(j=4; g.zPath[j] && g.zPath[j]!='/'; j++){}
blob_append(cgi_output_blob(), &z[base], i-base);
blob_appendf(cgi_output_blob(), "%.*s", j-4, g.zPath+4);
base = i+5;
}
}
blob_append(cgi_output_blob(), &z[base], i-base);
}
/*
** Render a document as the reply to the HTTP request. The body
|