FixURL-Talk
This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.
Don't use this when you use Attach: . It turns a space in the uploaded filename to "20".
Here is a better solution, rather than having your page code all mucked up with a bunch of crazy
percent encodings wrap things in [~ ... ~] and it will be done automatically by markup.
This page code
http://localhost/z/uploads/[~Slaughterbots - if human kill~].mp4#x320;class=videoframegraysilver
renders into this URL
http://localhost/z/uploads/Slaughterbots%20-%20if%20human%20kill.mp4#x320;class=videoframegraysilver
I think this should be a core candidate.
Put this code into your config.php or your farmconfig.php:
########################################################################################################
function PercentEncodeWrapped($m) {
$text = trim($m[1]);
$encoded = strtr($text, array(
' ' => '%20', '<' => '%3C', '>' => '%3E', '"' => '%22', '{' => '%7B', '}' => '%7D',
'|' => '%7C', '\\' => '%5C', '^' => '%5E', '`' => '%60', '(' => '%28', ')' => '%29',
'[' => '%5B', ']' => '%5D', "'" => '%27'
));
return PHSC($encoded);
}
Markup('percentencodewrapped', '<{$var}', '/\\[~(.*?)~\\]/s', 'PercentEncodeWrapped');
########################################################################################################
--gnuzoo
It is sometimes confusing to differentiate what is and when to use escape vs quotes
vs percent encoding vs formatting vs markup vs directives vs hash fragments vs percent styles
and perhaps other methods. I think this encoding markup makes things a little easier for authors.
Petko, can you please comment towards this? Does any of this make sense?
--gnuzoo
The standard is to percent-encode the special characters in URLs, see RFC:3986 and RFC:3987. It may be simpler to just upload a file without spaces, or copy the URL from your browser. If you upload files without spaces, or if you place percent-encoded URLs, no escaping is needed. I doubt that adding yet another escape sequence will make you less confused than uploading a file without spaces, but PmWiki does allow for local customizations so if you believe it makes sense, feel free to do so. --Petko
Don't use this when you use Attach: . It turns a space in the uploaded filename to "20".
I made this thinking it would work for media filenames. I did not see this affecting
upload filenames. I was able to adjust the media.php (with help from Petko) to use escape
markup [= ... =] so there is no to reason to use this now.
I really thought at the time this would be helpful. Maybe it might be for something else.
--gnuzoo
The GUI button for this has a caption of "%2". Why is it named that?
Was there ever a "%1"? Clicking it will encode selected text.
I too often see encoded stuff and ask, "what the heck is that?"
Can you change it from "encode" to "toggle encode/decode"?
--gnuzoo
It shows %2 because the space and many special characters, when percent-encoded, start with percent-two, like "'( )'" => %22%27%28%20%29%27%22. Feature request added as PITS:01548. Petko
I use the EditToolbar recipe, and needed to copy the fixurl.png file into pmwiki/pub/edittoolbar/ instead of pmwiki/pub/guiedit/.
- MG, 23 Oct 13