gustafn
committed
on 09 Mar 21
Use built-in "ns_parsequery" instead of manual parsing of query parameters.
Note, that this change might alter query processing, since previ… Show more
Use built-in "ns_parsequery" instead of manual parsing of query parameters.

Note, that this change might alter query processing, since previously

query parameter without explicit values were treated as boolean values

(like in HTML), now these are treated like "x=" before.  The new version is

about 10x faster.

Furthermore, new tests of the regression tests were added for query parameter

processing.

Show less

openacs-4/.../xowiki/tcl/package-procs.tcl (+7 -8)
1267 1267     # To avoid recursions, remove the current package from the list of
1268 1268     # packages if was accidentally included. Get the package objects
1269 1269     # from the remaining URLs.
1270 1270     #
1271 1271     foreach package_instance_url $package_path {
1272 1272       #:msg "compare $package_instance_url eq $package_url"
1273 1273       if {$package_instance_url eq $package_url} continue
1274 1274       lappend packages ::[::xowiki::Package initialize \
1275 1275                               -url $package_instance_url/${:object} \
1276 1276                               -keep_cc true -init_url false]
1277 1277     }
1278 1278     # final sanity check, in case package->initialize is broken
1279 1279     set p [lsearch $packages ::${:id}]
1280 1280     if {$p > -1} {set packages [lreplace $packages $p $p]}
1281 1281
1282 1282     #:msg "${:id} packages=$packages, p=$p"
1283 1283     return $packages
1284 1284   }
1285 1285
1286 1286   Package instproc normalize_path {name} {
  1287     #
  1288     # Don't allow any adressing outside of the jail.
  1289     #
  1290     # ns_normalizepath always adds a leading "/", so remove this.
  1291     #
1287 1292     set nn [ns_normalizepath $name]
1288       if {[string range $name 0 0] ne "/" && [string range $nn 0 0] eq "/"} {
1289         set name [string range $nn 1 end]
1290       } else {
1291         set name $nn
  1293     return [string range $nn 1 end]
1292 1294   }
1293       ns_log notice "=== normalized <$name>"
1294       return $name
1295     }
1296 1295
1297 1296   #view-default/../../../etc/hosts
1298 1297
1299 1298   Package instproc get_adp_template {name} {
1300 1299     #
1301 1300     # Obtain the template from a name. In earlier versions, the
1302 1301     # templates that xowiki used were in the www directory. This had
1303 1302     # the disadvantage, that for e.g. the template "edit.adp" a call
1304 1303     # of "/xowiki/edit" returned an error, since the index.vuh file
1305 1304     # was bypassed and xowiki/www/edit.adp was called. Therefore the
1306 1305     # recommended place was changed to
1307 1306     # xowiki/resources/templates/. However, this method hides the
1308 1307     # location change and maintains backward compatibility. In some
1309 1308     # later versions, the www location will be deprecated.
1310 1309     #
1311 1310     set name [:normalize_path $name]
1312 1311     foreach package_key [list [:package_key] xowiki] {
1313 1312
1314 1313       #
1315 1314       # backward compatibility check