Fossil SCM

Get self-registration working again after adding javascript-activated forms.

drh 2012-12-07 12:50 trunk
Commit 54085d52c423f626b34d5fb2afddba4494ab8f20
2 files changed +1 -1 +19 -7
+1 -1
--- src/login.c
+++ src/login.c
@@ -1292,11 +1292,11 @@
12921292
@ <tr><td></td>
12931293
@ <td><input type="submit" name="new" value="Register" /></td></tr>
12941294
@ </table>
12951295
@ <div class="captcha"><table class="captcha"><tr><td><pre>
12961296
@ %h(zCaptcha)
1297
- @ </pre></td></tr></table>
1297
+ @ </pre></td></tr></table></div>
12981298
@ </form>
12991299
style_footer();
13001300
13011301
free(zCaptcha);
13021302
}
13031303
--- 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 @@
6969
** If g.javascriptHyperlink is true then the
7070
** id="ID" form is used and javascript is generated in the footer to cause
7171
** href values to be inserted after the page has loaded. If
7272
** g.perm.History is false, then the <a id="ID"> form is still
7373
** 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.
7581
**
7682
** Filling in the href="URL" using javascript is a defense against bots.
7783
**
7884
** The name of this routine is deliberately kept short so that can be
7985
** easily used within @-lines. Example:
@@ -84,10 +90,15 @@
8490
** obtained from fossil_malloc() so rendering it with %z will reclaim
8591
** that memory space.
8692
**
8793
** There are two versions of this routine: href() does a plain hyperlink
8894
** 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.
89100
*/
90101
char *xhref(const char *zExtra, const char *zFormat, ...){
91102
char *zUrl;
92103
va_list ap;
93104
va_start(ap, zFormat);
@@ -101,11 +112,11 @@
101112
if( nHref>=nHrefAlloc ){
102113
nHrefAlloc = nHrefAlloc*2 + 10;
103114
aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0]));
104115
}
105116
aHref[nHref++] = zUrl;
106
- return mprintf("<a %s id=%d>", zExtra, nHref);
117
+ return mprintf("<a %s id='a%d'>", zExtra, nHref);
107118
}
108119
char *href(const char *zFormat, ...){
109120
char *zUrl;
110121
va_list ap;
111122
va_start(ap, zFormat);
@@ -119,11 +130,11 @@
119130
if( nHref>=nHrefAlloc ){
120131
nHrefAlloc = nHrefAlloc*2 + 10;
121132
aHref = fossil_realloc(aHref, nHrefAlloc*sizeof(aHref[0]));
122133
}
123134
aHref[nHref++] = zUrl;
124
- return mprintf("<a id=%d>", nHref);
135
+ return mprintf("<a id='a%d'>", nHref);
125136
}
126137
127138
/*
128139
** Generate <form method="post" action=ARG>. The ARG value is inserted
129140
** by javascript.
@@ -149,17 +160,18 @@
149160
/*
150161
** Generate javascript that will set the href= attribute on all anchors.
151162
*/
152163
void style_resolve_href(void){
153164
int i;
154
- if( !g.perm.Hyperlink || !g.javascriptHyperlink ) return;
165
+ if( !g.perm.Hyperlink ) return;
155166
if( nHref==0 && nFormAction==0 ) return;
156167
@ <script type="text/JavaScript">
157168
@ /* <![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
+ }
161173
}
162174
for(i=0; i<nFormAction; i++){
163175
@ gebi("form%d(i+1)").action="%s(aFormAction[i])";
164176
}
165177
@ /* ]]> */
166178
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button