• see: https://www.ads-software.com/support/topic/262117?replies=9

    once i have looked new code about this fix, now there is other code…
    now i have enabled super cache and see that this still or again (i have not tested versions between these) do not work in the new version.

    function get_current_url_supercache_dir is in wp-cache-phase1.php now.

    i think now may be you donncha have not corrected this because may be this fix (adding urldecode) produces filenames with unicode letters? and such filenames are not supported on many hosts? what happen if not supported… i think just one-byte view of unicode appear… and it anyway do not work… so, why you have not included this fix in official/repository code?

    in new version i think fix is may be same, but surround “$uri” with urldecode:
    $uri = preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', str_replace( '/index.php', '/', str_replace( '..', '', preg_replace("/(\?.*)?$/", '', urldecode($uri) ) ) ) );

Viewing 9 replies - 46 through 54 (of 54 total)
  • Good point, I’ll change the option visibility later. Thanks!

    Thread Starter Dinar Qurbanov

    (@qdinar)

    donncha, please make optional using unescaped filenames, so that it is not possible to turn on on windows, because there is probably ntfs with many special characters. but in ext3 and ext4 there is not many, only that i know are / , . and .. . which are probably already excluded from slugs. if unescaped filenames are used then no need to change rewrite rules, non-latin slugs will work without php. i think, maybe, it does not work if ext2(?)/3/4 partition is mounted with incorrect options so that utf-8 on it does not work. also you can make test that tries to write and read file with non-latin letters. other pros of unescaped filenames: they will become shorter and human-readable.

    I’d rather not just because of all the unknowns. Have you tried the latest dev version? The PHP powered pages should be fast enough.

    Thread Starter Dinar Qurbanov

    (@qdinar)

    you can leave escaped all characters above some value, for example something like all characters above 32767 ie that are bigger than most big 2 byte ucs.
    also you can make even more safe: allow for first time only all additional latin and cyrillic and other alphabet character ranges, that look clear for you, to be unescaped, then make allowed characters wider and wider with new versions. escaped slugs still will be served by php.

    do you have other unknowns?

    and you should make it optional and warn : use it at your own risk.

    and if problems will appear they will be probably os’s utf-8 encoding bug, not supercache’s. why you should bother and don’t use unicode?

    and i think also wordpress could move to use unescaped strings in post_name field and treat urlencoding like just a way of encoding that should be used only in http headers. even in html they are not needed, unicode in href attribute works, only it is needed there rarely to encode “#”, “?”, “””, “‘”, space probably works unescaped while it is in quotes.

    maybe i will try to make that again myself, if you do not.

    no, i have not tried latest dev version. i do not think it has become much faster. rewrite rules were 10 times faster, as i said.

    Thread Starter Dinar Qurbanov

    (@qdinar)

    i have found configuration for htaccess to serve files with urlencoded paths with rewrite rules, not running wordpress php files (for wp-super-cache), but it needs custom function as executable file to rewrite, that should be run from rewrite rules, so server admin should make that executable file for wordpress installations, and turn that executable on in apache configuration.
    custom function:

    #!/usr/bin/php
    <?php
    set_time_limit(0);
    $fdin=fopen("php://stdin","r");
    $fdout=fopen("php://stdout","w");
    set_file_buffer($fdout,0);
    while($i=fgets($fdin)){
    	$i2=explode('/',rtrim($i));
    	$i2o=count($i2);
    	for($j=0;$j<$i2o;$j++){
    		$i2[$j]=str_replace('%','%25',strtolower(urlencode($i2[$j])));
    	}
    	$o=implode('/',$i2)."\n";
    	fputs($fdout,$o);
    }
    ?>

    owned by www-data, runnable(executable), /var/www/localhost/test/localhost/aylandirow3.php .
    this file is connected to apache this way:
    RewriteMap aylandirow3 prg:/var/www/localhost/test/localhost/aylandirow3.php
    this rule cannot be in htaccess. after creating new such file or modifying it, restarting apache is needed, as i know.
    custom function probably can be made with c, if made, then indeed no php will be used ) . and i have seen code for perl, how to do this.

    i have modified htaccess this way:
    replace

    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz" [L]

    with

    RewriteCond %{REQUEST_URI} !^/wp-content/cache/supercache/[^/]+/[^/]+/index\.html\.gz$
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/${aylandirow3:$1}/index.html.gz" [L]

    and replace

    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html" [L]

    with

    RewriteCond %{REQUEST_URI} !^/wp-content/cache/supercache/[^/]+/[^/]+/index\.html\.gz$
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/${aylandirow3:$1}/index.html" [L]

    end of modification.

    i have tested this with ab, and it is little slower than old configuration.
    old configuration:

    Time taken for tests:   0.353 seconds
    Requests per second:    141.45 [#/sec] (mean)
    Time per request:       35.348 [ms] (mean)
    Time per request:       7.070 [ms] (mean, across all concurrent requests)
    Transfer rate:          1843.00 [Kbytes/sec] received
    Percentage of the requests served within a certain time (ms)
      50%     27
    ...
     100%    101 (longest request)

    this configuration:

    Time taken for tests:   0.377 seconds
    Requests per second:    132.59 [#/sec] (mean)
    Time per request:       37.710 [ms] (mean)
    Time per request:       7.542 [ms] (mean, across all concurrent requests)
    Transfer rate:          1727.58 [Kbytes/sec] received
    Percentage of the requests served within a certain time (ms)
      50%     36
    ...
     100%     75 (longest request)

    Thread Starter Dinar Qurbanov

    (@qdinar)

    while i have configured this way real site, main pages have reported that ….index.html.gz is not found, 1-3 hours my main pages has been not working ( .
    i have not found why it happened so, i have thoroughly compared real(production) and test sites.

    but now i have found other configuration that does not cause such problem:
    add:
    RewriteMap aylandirow2 prg:/var/www/localhost/test/localhost/aylandirow2.php
    (near previous RewriteMap)
    aylandirow2.php’s content is:

    #!/usr/bin/php
    <?php
    set_time_limit(0);
    $fdin=fopen("php://stdin","r");
    $fdout=fopen("php://stdout","w");
    set_file_buffer($fdout,0);
    while($i=fgets($fdin)){
    	$i2=explode('/',rtrim($i));
    	$i2o=count($i2);
    	for($j=0;$j<$i2o;$j++){
    		$i2[$j]=strtolower(urlencode($i2[$j]));
    	}
    	$o=implode('/',$i2)."\n";
    	fputs($fdout,$o);
    }
    ?>

    and change rules this way:

    ...
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/${aylandirow2:$1}/index.html.gz -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/${aylandirow3:$1}/index.html.gz" [L]
    ...
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/${aylandirow2:$1}/index.html -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/${aylandirow3:$1}/index.html" [L]

    that’s all.

    i said that aylandirow2.php and aylandirow3.php owner’s are www-data, this is not correct, it does not depend strictly on that, i wanted to say it should be accessible by www-data, and maybe, even if not, apache can use it because it can run and access files temporarily as root.

    Thread Starter Dinar Qurbanov

    (@qdinar)

    this way also does not work … it shows main page on all pages

    after nearly 15 minutes:

    no, it works.

    i have found bug: rewriteengine on was needed before rewritemap directives…

    If you have to call a PHP script like that from a mod_rewrite rule then you might as well use PHP caching. It’s executing PHP code after all and the PHP caching code loads very early on.

    Also, there’s no way I’m going to include a script that depends on finding a locally installed php binary. It would be a nightmare to auto-configure.

    Thread Starter Dinar Qurbanov

    (@qdinar)

    you can set 2 php scripts in super cache folder and as you have made instruction to paste code into htaccess, same way you can make instruction also: to configure vhost with “allowoverride none”, and also this way to serve unicode addresses faster, but only server admin (root) can install this scripts into apache configuration. this way has advantage over the way of saving caching pages with unicode filenames, that here is no problem with special characters ie on non-unicode filesystem and windows.

Viewing 9 replies - 46 through 54 (of 54 total)
  • The topic ‘[Plugin: WP Super Cache] still not corrected… bug about unicode-range letters in permalink’ is closed to new replies.