Hey, look, it's another one... This prevents the wiki formatter from adding the base URL to URLs starting with //.
// is a rather obscure but incredibly handy feature of URLs that a lot of people don't know about. It's an *absolute* URL using the same schema as the currently loaded page. For example: //cowlark.com/binary.png This is primarily useful when dealing with pages that use https. Most modern browsers will refuse to load content via http on an https page, so if I were to link to http://cowlark.com/binary.com from https://cowlark.com/calculon, all I'd get is a broken link. Using a // URL ensures that it's loaded by either http: or https: depending on what's appropriate for the page. Patch enclosed. (How does one go about submitting a contributor agreement?) -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "Of course, on a sufficiently small planet, 40 km/hr is, in fact, │ sufficient to punt the elastic spherical cow into low orbit." --- │ Brooks Moses on r.a.sf.c
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -824,11 +824,12 @@
blob_appendf(pOut, "<%s", aMarkup[p->iCode].zName);
for(i=0; i<p->nAttr; i++){
blob_appendf(pOut, " %s", aAttribute[p->aAttr[i].iACode].zName);
if( p->aAttr[i].zValue ){
const char *zVal = p->aAttr[i].zValue;
- if( p->aAttr[i].iACode==ATTR_SRC && zVal[0]=='/' ){
+ if( p->aAttr[i].iACode==ATTR_SRC && zVal[0]=='/'
+ && (zVal[0]==0 || zVal[1]!='/') ){
blob_appendf(pOut, "=\"%s%s\"", g.zTop, zVal);
}else{
blob_appendf(pOut, "=\"%s\"", zVal);
}
}
@@ -1171,10 +1172,11 @@
assert( nClose>=20 );
if( strncmp(zTarget, "http:", 5)==0
|| strncmp(zTarget, "https:", 6)==0
|| strncmp(zTarget, "ftp:", 4)==0
|| strncmp(zTarget, "mailto:", 7)==0
+ || strncmp(zTarget, "//", 2)==0
){
blob_appendf(p->pOut, "<a href=\"%s\">", zTarget);
}else if( zTarget[0]=='/' ){
blob_appendf(p->pOut, "<a href=\"%s%h\">", g.zTop, zTarget);
}else if( zTarget[0]=='.'
signature.asc
Description: OpenPGP digital signature
_______________________________________________ fossil-users mailing list [email protected] http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

