Permalink
Browse files

DEV: add CGI prefixes

  • Loading branch information...
Michael O'Brien
Michael O'Brien committed Jun 8, 2017
1 parent 4f83a6a commit 6f786c123196eb622625a920d54048629a7caa74
Showing with 50 additions and 17 deletions.
  1. +1 −1 doc/partials/menu.html.exp
  2. +1 −1 doc/partials/sidebar.html.exp
  3. +12 −8 main.me
  4. +11 −4 src/cgi.c
  5. +12 −2 src/goahead.h
  6. +13 −1 src/runtime.c
@@ -5,5 +5,5 @@
<a class="item" href="http://goo.gl/9bL9rM">GoAhead News</a>
<a class="item" href="https://github.com/embedthis/goahead">Repository</a>
<a class="item" href="https://embedthis.com/blog/">Blog</a>
<a class="item" href="https://twitter.com/mobstream">Twitter</a>
<a class="item" href="https://twitter.com/embedthat">Twitter</a>
</span>
@@ -81,7 +81,7 @@
<div class="menu">
<a class="item" href="https://embedthis.com/">Embedthis Web Site</a>
<a class="item" href="https://embedthis.com/blog/">Embedthis Blog</a>
<a class="item" href="http://twitter.com/mobstream">Twitter</a>
<a class="item" href="http://twitter.com/embedthat">Twitter</a>
</div>
</div>
</div>
View
20 main.me
@@ -2,7 +2,7 @@
main.me -- Main MakeMe file for GoAhead
This file contains the rules for targets to build and default settings for configuration.
The MakeMe utility (https://embedthis.com/me) may be used to build GoAhead instead of make.
The MakeMe utility (https://embedthis.com/me) may be used to build GoAhead instead of make.
MakeMe provides for configured builds and generates projects files.
Alternatively, build using the 'make' utility in which case this file is not used.
@@ -53,7 +53,7 @@ Me.load({
accessLog: false,
/*
User authentication
User authentication
*/
auth: true,
@@ -76,6 +76,11 @@ Me.load({
*/
cgi: true,
/*
Prefix for CGI environment variables
*/
cgiPrefix: "CGI_"
/*
Build with support for digest authentication
*/
@@ -235,9 +240,9 @@ Me.load({
},
customize: [
/*
/*
The optional custom.me file is loaded after main.me is fully processed. It can
thus override any setting. Feel free to create and customize.
thus override any setting. Feel free to create and customize.
*/
'custom.me',
],
@@ -261,7 +266,7 @@ Me.load({
prebuild: `
if (me.settings.compiler.hasPam && me.settings.goahead.pam) {
me.target.libraries.push('pam')
}
}
`
},
},
@@ -275,10 +280,10 @@ Me.load({
prebuild: `
if (me.settings.compiler.hasPam) {
me.target.libraries.push('pam')
}
}
cp(['${BIN}/self.key', '${BIN}/self.crt'], 'src')
cp(['${BIN}/self.key', '${BIN}/self.crt'], 'test')
`,
`,
},
},
@@ -353,4 +358,3 @@ Me.load({
}
},
})
View
@@ -160,10 +160,17 @@ PUBLIC bool cgiHandler(Webs *wp)
envpsize = 64;
envp = walloc(envpsize * sizeof(char*));
for (n = 0, s = hashFirst(wp->vars); s != NULL; s = hashNext(wp->vars, s)) {
if (s->content.valid && s->content.type == string &&
strcmp(s->name.value.string, "REMOTE_HOST") != 0 &&
strcmp(s->name.value.string, "HTTP_AUTHORIZATION") != 0) {
envp[n++] = sfmt("%s=%s", s->name.value.string, s->content.value.string);
if (s->content.valid && s->content.type == string) {
if (smatch(s->name.value.string, "REMOTE_HOST") ||
smatch(s->name.value.string, "HTTP_AUTHORIZATION") ||
smatch(s->name.value.string, "IFS") ||
smatch(s->name.value.string, "CDPATH") ||
smatch(s->name.value.string, "PATH") ||
sstarts(s->name.value.string, "LD_")) {
continue;
}
envp[n++] = sfmt("%s%s=%s", ME_GOAHEAD_CGI_PREFIX,
s->name.value.string, s->content.value.string);
trace(5, "Env[%d] %s", n, envp[n-1]);
if (n >= envpsize) {
envpsize *= 2;
View
@@ -1391,7 +1391,7 @@ PUBLIC WebsSocket *socketPtr(int sid);
help prevent buffer overflows and other potential security traps.
@defgroup WebsRuntime WebsRuntime
@see fmt wallocHandle wallocObject wfreeHandle hextoi itosbuf scaselesscmp scaselessmatch
sclone scmp scopy sfmt sfmtv slen slower smatch sncaselesscmp sncmp sncopy stok strim supper
sclone scmp scopy sfmt sfmtv slen slower smatch sstarts sncaselesscmp sncmp sncopy stok strim supper
@stability Stable
*/
@@ -1575,7 +1575,7 @@ PUBLIC char *sfmtv(char *format, va_list args);
@ingroup WebsRuntime
@stability Stable
*/
PUBLIC ssize slen(char *str);
PUBLIC ssize slen(cchar *str);
/**
Convert a string to lower case.
@@ -1667,6 +1667,16 @@ PUBLIC bool snumber(cchar *s);
*/
PUBLIC char *ssplit(char *str, cchar *delim, char **last);
/**
Test if the string starts with a given pattern.
@param str String to examine
@param prefix Pattern to search for
@return Returns TRUE if the pattern was found. Otherwise returns zero.
@ingroup MprString
@stability Stable
*/
PUBLIC bool sstarts(cchar *str, cchar *prefix);
/**
Tokenize a string
@description Split a string into tokens.
View
@@ -2495,6 +2495,18 @@ PUBLIC bool smatch(char *s1, char *s2)
}
PUBLIC bool sstarts(cchar *str, cchar *prefix)
{
if (str == 0 || prefix == 0) {
return 0;
}
if (strncmp(str, prefix, slen(prefix)) == 0) {
return 1;
}
return 0;
}
PUBLIC int scmp(char *s1, char *s2)
{
if (s1 == s2) {
@@ -2508,7 +2520,7 @@ PUBLIC int scmp(char *s1, char *s2)
}
PUBLIC ssize slen(char *s)
PUBLIC ssize slen(cchar *s)
{
return s ? strlen(s) : 0;
}

0 comments on commit 6f786c1

Please sign in to comment.