|
13 | 13 | $time = $time_end - $time_start;
|
14 | 14 | echo( "\nbuild time: ". $time." seconds.\n");
|
15 | 15 |
|
| 16 | +// https://stackoverflow.com/a/6059053 |
| 17 | +function encodeURI($url) { |
| 18 | + // http://php.net/manual/en/function.rawurlencode.php |
| 19 | + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURI |
| 20 | + $unescaped = array( |
| 21 | + '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~', |
| 22 | + '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')' |
| 23 | + ); |
| 24 | + $reserved = array( |
| 25 | + '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':', |
| 26 | + '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$' |
| 27 | + ); |
| 28 | + $score = array( |
| 29 | + '%23'=>'#' |
| 30 | + ); |
| 31 | + return strtr(rawurlencode($url), array_merge($reserved,$unescaped,$score)); |
| 32 | + |
| 33 | +} |
| 34 | + |
| 35 | +function fixedEncodeURI($url) { |
| 36 | + return strtr(encodeURI($url),array('%5B'=>'[', '%5D'=>']')); |
| 37 | +} |
| 38 | + |
16 | 39 | function buildChm( $cpp = true )
|
17 | 40 | {
|
18 | 41 | $scriptDir = dirname( __FILE__ );
|
@@ -161,7 +184,7 @@ function buildChm( $cpp = true )
|
161 | 184 | $new_value = str_replace( " " , "_", $new_value);
|
162 | 185 | if (! strstr($new_value, "http")) {
|
163 | 186 | // escape relative %
|
164 |
| - $new_value = str_replace( "%" , "_", urlencode($new_value)); |
| 187 | + $new_value = str_replace( "%" , "_", fixedEncodeURI($new_value)); |
165 | 188 | }
|
166 | 189 |
|
167 | 190 | if ($hash) { // fix hashes
|
|
0 commit comments