Quote:
Originally Posted by eschwartz
Well, the spaces I was using were definitely ASCII spaces, since I created the files in question to begin with.
I'd be more motivated to try to find out if there is a solution, if it were a practical problem to begin with. As it is, for the unusual event where you wish to launch an ebook via a static KUAL entry, you can just use a decent filename (spaces are eeeeevil!!)
|
You can tell from the data '<schema>://<path>', that the argument is a 'URI'
So you need to URI encode the filename.
For example, replacing spaces with "%20" worked for me on this file:
Quote:
lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.reader/mnt/us/documents/Hunted_%20The%20Iron%20Druid%20Chronicles,%20Book% 20Six_B00AUSCOIS.kfx
|
I didn't bother checking all the 'reserverd' characters to see if this app could read them but the list is here if you want to make files with them, and then check. But the reserved characters are differnt for each part of the URI - our filename is the 'path' part, and thats defines as:
path-absolute = "/" [ segment-nz *( "/" segment ) ]
and ... and
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved is whats listed on wikipedia
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
https://en.wikipedia.org/wiki/Percent-encoding
https://tools.ietf.org/html/rfc3986
After that, a simple script can do - In the regex, just put all the character that should be allowed - for example, we know that the backslashes are fine, and commas worked for me.:
Quote:
#!/bin/sh
echo "$@" | awk -v ORS="" '{ gsub(/./,"&\n") ; print }' | while read l;
do
case "$l" in
[\/-_.~a-zA-Z0-9\:\@\!\$\&\'\(\)\*\+\,\;\=] ) echo -n ${l} ;;
"" ) echo -n %20 ;;
* ) printf '%%%02X' "'$l"
esac
done
echo ""
|
[root@kindle us]# bash urlencode.sh /mnt/us/documents/Hunted_\ The\ Iron\ Druid\ Chronicles,\ Book\ Six_B00AUSCOIS.kfx
/mnt/us/documents/Hunted_%20The%20Iron%20Druid%20Chronicles,%20Book% 20Six_B00AUSCOIS.kfx
But if a file has that '/' character in it, this wont work, it will treat it as a new directory segment.