WebIF Media Browser Oddity

Thanks for the tests.

Although it's entirely likely that I made a transcription error between my working copy and git, I can reproduce and fix this now that I notice there are no directories with name containing 1 or more [] in my test. The revised version will work better, I think.

Any interested tester can regenerate the patch, or just change the "&" on lines 106 (especially) and 112 of the patched /mod/webif/lib/utils to {&}.
 
Okay, that's sorted out the listing of folders, and the leading space is displayed, but now there are no sizes displayed against folders (only files).
 
I definitely have folder sizes. Maybe some serious cache flushing is needed for your browser to use the patched /mod/webif/html/browse/script.js]? Otherwise there should be some error messages in the browser log, if the browser makes that accessible.
 
It works for me after the changes in post 21 above. File sizes are now shown for both files and folders.
 
just change the "&" to {&}
This "" {} string confusion is what I loathe most about Jim. I still don't know what the difference is in this context and why it matters. Reading the manual never seems to help as it just doesn't seem to define the fundamentals clearly.
 
Inside {} there is no command or variable substitution (but see the subst command), similar to '' in POSIX/Bourne shell. Inside "" there is. In this case I stupidly used "".
 
& is a piece of regsub syntax (also used in traditional text editors with regex search/replace) and is replaced by the "entire matched string" each time it occurs in the replacement text (\0 is also used); to put an actual & in the replacement text, use \&.

In this case, the idea is to map the special characters by replacing each of them with a [] expression that will later be evaluated (by calling subst).

Example: the folder name set str {ab[cd} (even to set it I have to use {} or Jim will not be happy).

The expression [regsub -all -- {[^A-Za-z0-9@*_+-./]+} $str {[::js::_escape {&}]}] evaluates to ab[::js::_escape {[}]cd. Then the call to subst causes the embedded [] expression to be evaluated, passing [ to the ::js::_escape proc and yielding ab%5Bcd.

In the above, the [^...] bit is another regular expression element meaning "characters that are not in the listed alphanumeric ranges nor are any of the further listed allowed special characters; this again needs {} around it to avoid the [] being interpreted as command substitution. In this case I decided to handle sequences of such special characters in one call to the escaping routine, hence the + meaning "1 or more" special characters; I didn't do any performance tests of this approach against replacing special characters individually with a slightly simpler escaping routine.

Whereas, with [regsub -all -- {[^A-Za-z0-9@*_+-./]+} $str {[::js::_escape "&"]}], we get ab[::js::_escape "["]cd which causes the unmatched "[" diagnostic when subst causes it to be evaluated. I'm sure a Russian meerkat would have something to say about this.
 
For reference: the SUI does not permit creating folder names with leading spaces, but it has no objection to trailing spaces.
 
Back
Top