WordPress plugin can not edit htaccess file

jkeegan

Active Member
#1
We are seeing a problem on several WordPress installs ... using the latest version of Litespeed, WordPress, and the Litespeed Cache WordPress plugin...

The issue is that the contents of the htaccess file can not be read nor edited. When we go to the /wp-admin/admin.php?page=lscache-settings page and enter the following valid syntax for Rewrite into the "List of Mobile View User Agents" field, we get an error displayed on the field "Htaccess did not match configuration option. Please re-enter the mobile view setting. List in WordPress database:". We also see "Invalid Rewrite List. Empty or invalid rule. Rule:" at the top of the WordPress page. The entry we are using is this:

(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|mobile.+firefox|netfront|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ ce|xda|xiino

which is from http://detectmobilebrowsers.com/. I think it is the parens which are causing the issue... If we manually edit the .htaccess file we get the same issue...

Is this a bug on the Litespeed Cache WordPress plugin parsing function?
 

KevinFwu

Administrator
Staff member
#2
Hi jkeegan,

You are correct, the plugin parsing function did not account for some of the characters used.

In litespeed-cache/admin/class-litespeed-cache-admin-rules.php, around line 1008 please edit:

Code:
     return (preg_match('/(^\|)|(\|$)|([^\\\\]\s|[^\w-\\\|\s\/]|\|\|)/',
should become
Code:
        return (preg_match('/(^\|)|(\|$)|([^\\\\]\s|[^\w-\\\|\s\/.+*?\(\)]|\|\|)/',
Let me know how it goes,
Kevin
 

KevinFwu

Administrator
Staff member
#4
Hi @jkeegan,

Please replace the check_rewrite function (same file same function) with the following:

Code:
    private static function check_rewrite($rule)
    {
        $escaped = str_replace('@', '\@', $rule);
        return (@preg_match('@' . $escaped . '@', null) !== false);
    }
Cheers,
Kevin
 
Top