diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2012-05-01 15:37:40 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2012-05-01 15:37:40 +0000 |
commit | 8cd02da424dc7238c1ee39339699cc8a7f98ef22 (patch) | |
tree | ecbf475cdc88d506a34800ba87c04e41e4166a07 /src/htsparse.c | |
parent | 655182a52d4ccb65952e3ee6f8409d9a6ed9ba90 (diff) |
Added a "K5" feature to handle transparent proxies (Brent Palmer)
Diffstat (limited to 'src/htsparse.c')
-rw-r--r-- | src/htsparse.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/htsparse.c b/src/htsparse.c index d5784bd..7e6bbc4 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -2494,7 +2494,7 @@ int htsparse(htsmoduleStruct* str, htsmoduleStructExtended* stre) { } lastsaved=eadr-1; // dernier écrit+1 (enfin euh apres on fait un ++ alors hein) /* */ - } else if (opt->urlmode >= 4) { // ne rien faire dans tous les cas! + } else if (opt->urlmode == 4) { // ne rien faire! /* */ /* leave the link 'as is' */ /* Sinon, dépend de interne/externe */ @@ -2745,6 +2745,54 @@ int htsparse(htsmoduleStruct* str, htsmoduleStructExtended* stre) { } lastsaved=eadr-1; // dernier écrit+1 (enfin euh apres on fait un ++ alors hein) } + else if (opt->urlmode==5) { // transparent proxy URL + char BIGSTK tempo[HTS_URLMAXSIZE*2]; + const char *uri; + int i; + char *pos; + + if ((opt->getmode & 1) && (ptr>0)) { // ecrire les html + if (!link_has_authority(adr)) { + HT_ADD("http://"); + } else { + char* aut = strstr(adr, "//"); + if (aut) { + char tmp[256]; + tmp[0]='\0'; + strncatbuff(tmp, adr, (int) (aut - adr)); // scheme + HT_ADD(tmp); // Protocol + HT_ADD("//"); + } + } + + // filename is taken as URI (ex: "C:\My Website\www.example.com\foo4242.html) + uri = save; + + // .. after stripping the path prefix (ex: "www.example.com\foo4242.html) + if (strnotempty(StringBuff(opt->path_html))) { + uri += StringLength(opt->path_html); + for( ; uri[0] == '/' || uri[0] == '\\' ; uri++) ; + } + + // and replacing all \ by / (ex: "www.example.com/foo4242.html) + strcpybuff(tempo, uri); + for(i = 0 ; tempo[i] != '\0' ; i++) { + if (tempo[i] == '\\') { + tempo[i] = '/'; + } + } + + // put original query string if any (ex: "www.example.com/foo4242.html?q=45) + pos = strchr(fil, '?'); + if (pos != NULL) { + strcatbuff(tempo, pos); + } + + // write it + HT_ADD_HTMLESCAPED(tempo); + } + lastsaved=eadr-1; // dernier écrit+1 (enfin euh apres on fait un ++ alors hein) + } else if (opt->urlmode==2) { // RELATIF char BIGSTK tempo[HTS_URLMAXSIZE*2]; tempo[0]='\0'; |