Fossil SCM
Get self-registration working again after adding javascript-activated forms.
Commit
54085d52c423f626b34d5fb2afddba4494ab8f20
Parent
89ab1185bfdba4b…
2 files changed
+1
-1
+19
-7
+1
-1
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -1292,11 +1292,11 @@ | ||
| 1292 | 1292 | @ <tr><td></td> |
| 1293 | 1293 | @ <td><input type="submit" name="new" value="Register" /></td></tr> |
| 1294 | 1294 | @ </table> |
| 1295 | 1295 | @ <div class="captcha"><table class="captcha"><tr><td><pre> |
| 1296 | 1296 | @ %h(zCaptcha) |
| 1297 | - @ </pre></td></tr></table> | |
| 1297 | + @ </pre></td></tr></table></div> | |
| 1298 | 1298 | @ </form> |
| 1299 | 1299 | style_footer(); |
| 1300 | 1300 | |
| 1301 | 1301 | free(zCaptcha); |
| 1302 | 1302 | } |
| 1303 | 1303 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -1292,11 +1292,11 @@ | |
| 1292 | @ <tr><td></td> |
| 1293 | @ <td><input type="submit" name="new" value="Register" /></td></tr> |
| 1294 | @ </table> |
| 1295 | @ <div class="captcha"><table class="captcha"><tr><td><pre> |
| 1296 | @ %h(zCaptcha) |
| 1297 | @ </pre></td></tr></table> |
| 1298 | @ </form> |
| 1299 | style_footer(); |
| 1300 | |
| 1301 | free(zCaptcha); |
| 1302 | } |
| 1303 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -1292,11 +1292,11 @@ | |
| 1292 | @ <tr><td></td> |
| 1293 | @ <td><input type="submit" name="new" value="Register" /></td></tr> |
| 1294 | @ </table> |
| 1295 | @ <div class="captcha"><table class="captcha"><tr><td><pre> |
| 1296 | @ %h(zCaptcha) |
| 1297 | @ </pre></td></tr></table></div> |
| 1298 | @ </form> |
| 1299 | style_footer(); |
| 1300 | |
| 1301 | free(zCaptcha); |
| 1302 | } |
| 1303 |
+19
-7
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -69,11 +69,17 @@ | ||
| 69 | 69 | ** If g.javascriptHyperlink is true then the |
| 70 | 70 | ** id="ID" form is used and javascript is generated in the footer to cause |
| 71 | 71 | ** href values to be inserted after the page has loaded. If |
| 72 | 72 | ** g.perm.History is false, then the <a id="ID"> form is still |
| 73 | 73 | ** generated but the javascript is not generated so the links never |
| 74 | -** activate. | |
| 74 | +** activate. | |
| 75 | +** | |
| 76 | +** If the user lacks the Hyperlink (h) property and the "auto-hyperlink" | |
| 77 | +** setting is true, then g.perm.Hyperlink is changed from 0 to 1 and | |
| 78 | +** g.javascriptHyperlink is set to 1. The g.javascriptHyperlink defaults | |
| 79 | +** to 0 and only changes to one if the user lacks the Hyperlink (h) property | |
| 80 | +** and the "auto-hyperlink" setting is enabled. | |
| 75 | 81 | ** |
| 76 | 82 | ** Filling in the href="URL" using javascript is a defense against bots. |
| 77 | 83 | ** |
| 78 | 84 | ** The name of this routine is deliberately kept short so that can be |
| 79 | 85 | ** easily used within @-lines. Example: |
| @@ -84,10 +90,15 @@ | ||
| 84 | 90 | ** obtained from fossil_malloc() so rendering it with %z will reclaim |
| 85 | 91 | ** that memory space. |
| 86 | 92 | ** |
| 87 | 93 | ** There are two versions of this routine: href() does a plain hyperlink |
| 88 | 94 | ** and xhref() adds extra attribute text. |
| 95 | +** | |
| 96 | +** g.perm.Hyperlink is true if the user has the Hyperlink (h) property. | |
| 97 | +** Most logged in users should have this property, since we can assume | |
| 98 | +** that a logged in user is not a bot. Only "nobody" lacks g.perm.Hyperlink, | |
| 99 | +** typically. | |
| 89 | 100 | */ |
| 90 | 101 | char *xhref(const char *zExtra, const char *zFormat, ...){ |
| 91 | 102 | char *zUrl; |
| 92 | 103 | va_list ap; |
| 93 | 104 | va_start(ap, zFormat); |
| @@ -101,11 +112,11 @@ | ||
| 101 | 112 | if( nHref>=nHrefAlloc ){ |
| 102 | 113 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 103 | 114 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 104 | 115 | } |
| 105 | 116 | aHref[nHref++] = zUrl; |
| 106 | - return mprintf("<a %s id=%d>", zExtra, nHref); | |
| 117 | + return mprintf("<a %s id='a%d'>", zExtra, nHref); | |
| 107 | 118 | } |
| 108 | 119 | char *href(const char *zFormat, ...){ |
| 109 | 120 | char *zUrl; |
| 110 | 121 | va_list ap; |
| 111 | 122 | va_start(ap, zFormat); |
| @@ -119,11 +130,11 @@ | ||
| 119 | 130 | if( nHref>=nHrefAlloc ){ |
| 120 | 131 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 121 | 132 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 122 | 133 | } |
| 123 | 134 | aHref[nHref++] = zUrl; |
| 124 | - return mprintf("<a id=%d>", nHref); | |
| 135 | + return mprintf("<a id='a%d'>", nHref); | |
| 125 | 136 | } |
| 126 | 137 | |
| 127 | 138 | /* |
| 128 | 139 | ** Generate <form method="post" action=ARG>. The ARG value is inserted |
| 129 | 140 | ** by javascript. |
| @@ -149,17 +160,18 @@ | ||
| 149 | 160 | /* |
| 150 | 161 | ** Generate javascript that will set the href= attribute on all anchors. |
| 151 | 162 | */ |
| 152 | 163 | void style_resolve_href(void){ |
| 153 | 164 | int i; |
| 154 | - if( !g.perm.Hyperlink || !g.javascriptHyperlink ) return; | |
| 165 | + if( !g.perm.Hyperlink ) return; | |
| 155 | 166 | if( nHref==0 && nFormAction==0 ) return; |
| 156 | 167 | @ <script type="text/JavaScript"> |
| 157 | 168 | @ /* <![CDATA[ */ |
| 158 | - @ function u(i,h){gebi(i).href=h;} | |
| 159 | - for(i=0; i<nHref; i++){ | |
| 160 | - @ u(%d(i+1),"%s(aHref[i])"); | |
| 169 | + if( g.javascriptHyperlink ){ | |
| 170 | + for(i=0; i<nHref; i++){ | |
| 171 | + @ gebi("a%d(i+1)").href="%s(aHref[i])"; | |
| 172 | + } | |
| 161 | 173 | } |
| 162 | 174 | for(i=0; i<nFormAction; i++){ |
| 163 | 175 | @ gebi("form%d(i+1)").action="%s(aFormAction[i])"; |
| 164 | 176 | } |
| 165 | 177 | @ /* ]]> */ |
| 166 | 178 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -69,11 +69,17 @@ | |
| 69 | ** If g.javascriptHyperlink is true then the |
| 70 | ** id="ID" form is used and javascript is generated in the footer to cause |
| 71 | ** href values to be inserted after the page has loaded. If |
| 72 | ** g.perm.History is false, then the <a id="ID"> form is still |
| 73 | ** generated but the javascript is not generated so the links never |
| 74 | ** activate. |
| 75 | ** |
| 76 | ** Filling in the href="URL" using javascript is a defense against bots. |
| 77 | ** |
| 78 | ** The name of this routine is deliberately kept short so that can be |
| 79 | ** easily used within @-lines. Example: |
| @@ -84,10 +90,15 @@ | |
| 84 | ** obtained from fossil_malloc() so rendering it with %z will reclaim |
| 85 | ** that memory space. |
| 86 | ** |
| 87 | ** There are two versions of this routine: href() does a plain hyperlink |
| 88 | ** and xhref() adds extra attribute text. |
| 89 | */ |
| 90 | char *xhref(const char *zExtra, const char *zFormat, ...){ |
| 91 | char *zUrl; |
| 92 | va_list ap; |
| 93 | va_start(ap, zFormat); |
| @@ -101,11 +112,11 @@ | |
| 101 | if( nHref>=nHrefAlloc ){ |
| 102 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 103 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 104 | } |
| 105 | aHref[nHref++] = zUrl; |
| 106 | return mprintf("<a %s id=%d>", zExtra, nHref); |
| 107 | } |
| 108 | char *href(const char *zFormat, ...){ |
| 109 | char *zUrl; |
| 110 | va_list ap; |
| 111 | va_start(ap, zFormat); |
| @@ -119,11 +130,11 @@ | |
| 119 | if( nHref>=nHrefAlloc ){ |
| 120 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 121 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 122 | } |
| 123 | aHref[nHref++] = zUrl; |
| 124 | return mprintf("<a id=%d>", nHref); |
| 125 | } |
| 126 | |
| 127 | /* |
| 128 | ** Generate <form method="post" action=ARG>. The ARG value is inserted |
| 129 | ** by javascript. |
| @@ -149,17 +160,18 @@ | |
| 149 | /* |
| 150 | ** Generate javascript that will set the href= attribute on all anchors. |
| 151 | */ |
| 152 | void style_resolve_href(void){ |
| 153 | int i; |
| 154 | if( !g.perm.Hyperlink || !g.javascriptHyperlink ) return; |
| 155 | if( nHref==0 && nFormAction==0 ) return; |
| 156 | @ <script type="text/JavaScript"> |
| 157 | @ /* <![CDATA[ */ |
| 158 | @ function u(i,h){gebi(i).href=h;} |
| 159 | for(i=0; i<nHref; i++){ |
| 160 | @ u(%d(i+1),"%s(aHref[i])"); |
| 161 | } |
| 162 | for(i=0; i<nFormAction; i++){ |
| 163 | @ gebi("form%d(i+1)").action="%s(aFormAction[i])"; |
| 164 | } |
| 165 | @ /* ]]> */ |
| 166 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -69,11 +69,17 @@ | |
| 69 | ** If g.javascriptHyperlink is true then the |
| 70 | ** id="ID" form is used and javascript is generated in the footer to cause |
| 71 | ** href values to be inserted after the page has loaded. If |
| 72 | ** g.perm.History is false, then the <a id="ID"> form is still |
| 73 | ** generated but the javascript is not generated so the links never |
| 74 | ** activate. |
| 75 | ** |
| 76 | ** If the user lacks the Hyperlink (h) property and the "auto-hyperlink" |
| 77 | ** setting is true, then g.perm.Hyperlink is changed from 0 to 1 and |
| 78 | ** g.javascriptHyperlink is set to 1. The g.javascriptHyperlink defaults |
| 79 | ** to 0 and only changes to one if the user lacks the Hyperlink (h) property |
| 80 | ** and the "auto-hyperlink" setting is enabled. |
| 81 | ** |
| 82 | ** Filling in the href="URL" using javascript is a defense against bots. |
| 83 | ** |
| 84 | ** The name of this routine is deliberately kept short so that can be |
| 85 | ** easily used within @-lines. Example: |
| @@ -84,10 +90,15 @@ | |
| 90 | ** obtained from fossil_malloc() so rendering it with %z will reclaim |
| 91 | ** that memory space. |
| 92 | ** |
| 93 | ** There are two versions of this routine: href() does a plain hyperlink |
| 94 | ** and xhref() adds extra attribute text. |
| 95 | ** |
| 96 | ** g.perm.Hyperlink is true if the user has the Hyperlink (h) property. |
| 97 | ** Most logged in users should have this property, since we can assume |
| 98 | ** that a logged in user is not a bot. Only "nobody" lacks g.perm.Hyperlink, |
| 99 | ** typically. |
| 100 | */ |
| 101 | char *xhref(const char *zExtra, const char *zFormat, ...){ |
| 102 | char *zUrl; |
| 103 | va_list ap; |
| 104 | va_start(ap, zFormat); |
| @@ -101,11 +112,11 @@ | |
| 112 | if( nHref>=nHrefAlloc ){ |
| 113 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 114 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 115 | } |
| 116 | aHref[nHref++] = zUrl; |
| 117 | return mprintf("<a %s id='a%d'>", zExtra, nHref); |
| 118 | } |
| 119 | char *href(const char *zFormat, ...){ |
| 120 | char *zUrl; |
| 121 | va_list ap; |
| 122 | va_start(ap, zFormat); |
| @@ -119,11 +130,11 @@ | |
| 130 | if( nHref>=nHrefAlloc ){ |
| 131 | nHrefAlloc = nHrefAlloc*2 + 10; |
| 132 | aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0])); |
| 133 | } |
| 134 | aHref[nHref++] = zUrl; |
| 135 | return mprintf("<a id='a%d'>", nHref); |
| 136 | } |
| 137 | |
| 138 | /* |
| 139 | ** Generate <form method="post" action=ARG>. The ARG value is inserted |
| 140 | ** by javascript. |
| @@ -149,17 +160,18 @@ | |
| 160 | /* |
| 161 | ** Generate javascript that will set the href= attribute on all anchors. |
| 162 | */ |
| 163 | void style_resolve_href(void){ |
| 164 | int i; |
| 165 | if( !g.perm.Hyperlink ) return; |
| 166 | if( nHref==0 && nFormAction==0 ) return; |
| 167 | @ <script type="text/JavaScript"> |
| 168 | @ /* <![CDATA[ */ |
| 169 | if( g.javascriptHyperlink ){ |
| 170 | for(i=0; i<nHref; i++){ |
| 171 | @ gebi("a%d(i+1)").href="%s(aHref[i])"; |
| 172 | } |
| 173 | } |
| 174 | for(i=0; i<nFormAction; i++){ |
| 175 | @ gebi("form%d(i+1)").action="%s(aFormAction[i])"; |
| 176 | } |
| 177 | @ /* ]]> */ |
| 178 |