I have just upgraded to Drupal 6.17 and now for the first time got the following warning after saving a modified article:

warning: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 10 in /srv/www/vhosts/winhlp.com/httpdocs/modules/user/user.module on line 393.

System status report:

Drupal: 6.17
Access to update.php: Protected
CAPTCHA: Already 5304 blocked form submissions
Configuration file: Protected
Cron maintenance tasks: Last run 33 min 40 sec ago
You can run cron manually.
Database updates: Up to date
Drupal core update status: Up to date
File system: Writable (public download method)
GD library: bundled (2.0.28 compatible)
Module and theme update status: Up to date
MySQL database: 5.0.18
PHP: 5.1.2
PHP memory limit: 256M
PHP register globals: Disabled
Unicode library: PHP Mbstring Extension
Update notifications: Enabled
Web server: Apache/2.2.0 (Linux/SUSE)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idcm’s picture

Got the same error when removing a role from a user. Just updated to 6.17. I don't see anything in the server logs. Site logs say:

Type php
Date Wednesday, June 9, 2010 - 07:25
User admin1
Location http://sitename.com/user/14/edit?destination=admin%2Fuser%2Fuser
Referrer http://sitename.com/user/14/edit?destination=admin%2Fuser%2Fuser
Message preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 10 in /home/idcmi/sitename.com/html/modules/user/user.module on line 393.
Severity error

hoisoftware’s picture

Brand new install on site.

The only item of note is that I extract to 'drupal-6.17' and then sym-link using 'drupal' then run the install/setup from {site}/drupal/

Site is currently switching from and installed TikiWiki over to Drupal, but I don't see how the 2 could be related. Different folders and different DB's.

------------------------

Drupal installation complete
warning: Compilation failed: range out of order in character class at offset 10 in /var/www/vhosts/{domain}/httpdocs/drupal-6.17/modules/user/user.module on line 393.

Congratulations, Drupal has been successfully installed.

Please review the messages above before continuing on to your new site.

------------------------

Details
Type php
Date Wednesday, June 9, 2010 - 10:11
User Anonymous
Location http://www.{domain}/drupal/install.php?locale=en&profile=default
Referrer http://www.{domain}/drupal/install.php?locale=en&profile=default
Message Compilation failed: range out of order in character class at offset 10 in /var/www/vhosts/{domain}/httpdocs/drupal-6.17/modules/user/user.module on line 393.
Severity error
Hostname {IP}
Operations

-------------------------

Drupal 6.17
Access to update.php Protected
Configuration file Protected
Cron maintenance tasks Last run 3 min 40 sec ago
You can run cron manually.
Database updates Up to date
Drupal core update status Up to date
File system Writable (public download method)
GD library bundled (2.0.28 compatible)
MySQL database 4.1.20
PHP 4.3.9
PHP memory limit 32M
PHP register globals Disabled
Unicode library PHP Mbstring Extension
Update notifications Enabled
Web server Apache/2.0.52 (CentOS)

Heine’s picture

This is due to a change in user validation in #266488: Cleanup for user_validate_name() + tests.

Treatment of the \x{} syntax might not be entirely consistent among PHP versions.

Can you replace

if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) {

with

if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/iu', $name)) {

or

if (preg_match('/[^\x80-\xF7 a-z0-9@_.\'-]/i', $name)) {

and post the results here?

Heine’s picture

Priority: Minor » Normal
hoisoftware’s picture

Problem was apparent when updating the user details. Made change to 1st option (adding the u) and that seems to have cured it. I will update here if it seems to rear it's head again.

Thanks.

Damien Tournoud’s picture

PHP 4.3.9

@hoisoftware: this PHP version is way outdated, and I think Drupal 6 only support PHP 4.4.0 and higher. You should really consider upgrading before doing anything.

Irous’s picture

Hi, I'm getting the same error message when I update any user profiles on the site.

I've updated half of my Drupal sites to v6.17 (from v6.16), and noticed in one of them that when I updated my user profile, I received this error:

warning: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 10 in /var/www/vhosts/mysite.com/httpdocs/modules/user/user.module on line 393.

I've checked on all my recently updated v6.17 sites, and it occurs on all of them. You don't need to change any of your details either, just go edit user and click save and the error above occurs. I did a quick check on all my v6.16 sites, and the error does not occur.

I'm on PHP 5.2.9

IntoTheWoods’s picture

Same error on fresh install of 6.17 with PHP 5.05.

Heine’s picture

Version: 6.17 » 7.x-dev
Status: Active » Needs review
FileSize
600 bytes
600 bytes

What version of PCRE are you using?

Status: Needs review » Needs work

The last submitted patch, do820336-utf8-preg-D7.patch, failed testing.

Lancezh’s picture

Exact Same Problem here, fresh clean install of Drupal 6.17 5 days ago:

Drupal 6.17
Access to update.php Protected
Configuration file Protected
Cron maintenance tasks Last run 41 min 56 sec ago
You can run cron manually.
Database updates Up to date
Drupal core update status No update data available
No information is available about potential new releases for currently installed modules and themes. To check for updates, you may need to run cron or you can check manually. Please note that checking for available updates can take a long time, so please be patient.
File system Writable (public download method)
MySQL database 4.1.10a
PHP 4.3.10
PHP memory limit 80M
PHP register globals Disabled
Unicode library PHP Mbstring Extension
Update notifications Enabled
Web server Apache

Mark Nielsen’s picture

I am also getting this warning message when I edit a user account. I don't even have to change anything—just clicking "Edit" on a user, and then "Save" with no changes will cause the warning. In spite of the warning, Drupal appears to be making any changes to user accounts as normal—so data seems safe.

The bug appeared for me after upgrading a site to Drupal 6.17. Should this issue have it's version changed to 6.17?

The relatvant details of my installation are as follows:

  • Drupal: 6.17
  • Database updates: Up to date
  • Drupal core update status: Up to date
  • File system: Writable (public download method)
  • GD library: bundled (2.0.34 compatible)
  • Module and theme update status: Up to date
  • MySQL database: 5.0.58
  • PHP: 5.2.9
  • PHP register globals: Disabled
  • Unicode library: PHP Mbstring Extension
  • Update notifications: Enabled
  • Web server: Apache/2.0.52 (CentOS)
idcm’s picture

Heine, I just inserted the second patch option you provided and so far it works. I can save my user and don't get an error. I will let you know if it stops working for some reason. I am running PHP 5.2.5 if that helps anyone. thanks Heine.

idcm’s picture

Myabe I am repeating #11 but I just installed Acquia's Drupal profile and when I submitted the last step of the install process, I got the error when the first user was created. So this is not limited to editing users.

idcm’s picture

okay, patched the acquia drupal profile with

if (preg_match('/[^\x80-\xF7 a-z0-9@_.\'-]/i', $name)) {

And ran another install and no error when user1 was created in install.

tstasiojr’s picture

Heine, I had exactly the same problem and your suggestion fixed it (the first suggestion of the two).

In module/user/user.module I added the u just after /i and my problem has gone away.

hoisoftware and damien: I'm running PHP v5.0.5. I tried upgrading PHP before I found this thread and had major problems with PHP 5.3. I discovered in another forum that Drupal isn't ready for 5.3 yet...

Thanks everyone.

Heine’s picture

Status: Needs work » Needs review
FileSize
1.25 KB

Running ^\x{80}-\x{F7} in UTF-8 mode doesn't make sense; after all, there is no valid single byte 'character' with the value 0x80.

After "\x", up to two hexadecimal digits are read (letters can be in upper or lower case). In UTF-8 mode, "\x{...}" is allowed, where the contents of the braces is a string of hexadecimal digits. It is interpreted as a UTF-8 character whose code number is the given hexadecimal number. The original hexadecimal escape sequence, \xhh, matches a two-byte UTF-8 character if the value is greater than 127.

The original expression in D6 seems to be intended to filter out illegal byte sequences; At best, it should be \x80-\xF7, but I've adapted the rather broad range to also balk on overlong encoding (C0-C2). The modification keeps the original support for 4 byte codepoints above 10FFFF.

Heine’s picture

Drupal 6 patch.

dddave’s picture

slead’s picture

Version: 7.x-dev » 6.17

Hi Heine,

I'm a total Drupal newbie (I just tried installing Drupal 6.17 with Apache2Triad 1.5.4) and I'm getting this error message after installation.

Can you please point me to instructions on how to install/apply the patch you just posted?

Thanks,
Steve

dddave’s picture

Version: 6.17 » 7.x-dev
slead’s picture

Version: 7.x-dev » 6.17

Hi ddave,

Thanks for the tip. I'm trying the patchwin.bat method listed at http://drupal.org/node/75790#comment-2615716 but this hasn't worked for me.

I downloaded the file from #18 above and placed it at C:\Temp\drupal\do820336-utf8-pregmatch-D6.patch then attempted to run this file, specifying the patch.bat as the program to run. The error message I get in the command prompt appears below. Is this something you can help with?

Is this bug specific to version 6.1.7? I'm only experimenting with Drupal so I could easily install another version if so.

Thanks,
Steve

C:\Temp\drupal>"C:\Program Files\GnuWin32\bin\unix2dos" -v "C:\Temp\drupal\do820336-utf8-pregmatch-D6.patch"
unix2dos: Converting C:\Temp\drupal\do820336-utf8-pregmatch-D6.patch

C:\Temp\drupal>"C:\Program Files\GnuWin32\bin\patch" --verbose 0<"C:\Temp\drupal\do820336-utf8-pregmatch-D6.patch"
Hmm... Looks like a unified diff to me...
can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git modules/user/user.module modules/user/user.module
|index e8b1fe2..48dc5dc 100644
|--- modules/user/user.module
|+++ modules/user/user.module
--------------------------
File to patch:

timbraeckman’s picture

I've added the "u" like in post #3 and no errors anymore! Thanks!!

robsonhell@gmail.com’s picture

O patch para D6 funcionou comigo.

dddave’s picture

@#25

Please post in English!

@all

#25 confirmes that the patch in #18 is working fine. (Thanks to google translate.)

madth3’s picture

Patch #18 worked for me too in Drupal 6.17

rnyberg’s picture

Confirm adding the /u option to the regexp successfull.

Heine’s picture

The /u option is not a viable addition. Please test the patch.

hgmichna’s picture

Did the patch make it into Drupal 6.19?

Heine’s picture

Version: 6.17 » 6.x-dev

@#30: no, the patch is still marked "needs review"

Heine’s picture

Version: 6.x-dev » 7.x-dev

Restoring metadata.

bkoopmans’s picture

Version: 7.x-dev » 6.19

Has anyone tried any of these patches/solutions on 6.19?

Heine’s picture

Version: 6.19 » 7.x-dev

Please stop changing versions.

This bug should be fixed on D7 first (we have tests there), then backported (done so preemptively) to D6.

bkoopmans’s picture

I apologize for changing the version. I applied the patch suggested in post # 18 and it resolved the problems, however, I was then no longer able to get any but the front page to show for users signing on using IE8 on a Windows 7 machine. IE8 worked fine on XP and the problem did not show up running FireFox 3.6.7 on Centos.

kleinetony’s picture

same problem, started with update to 6.19

idcm’s picture

I just ran install for D6.19 without the patch and got the error. Ran install again with the patch and did not get the error. So far, I am assuming it works.

c

guignonv’s picture

Version: 7.x-dev » 6.19

I updated from Drupal 6.16 to 6.19 and I had that error.
I tested the path #17 on my Drupal 6.19 PHP 5.1.6. I don't have the error anymore.
By the way, I have another problem that might not be related but which is still there: I'm unable to log in! :-S I'll see if that issue has already been reported.

[update:] I saw other people had the same issue and the "fix" was to (...RTFM ;-) ) create a $cookie_domain entry in the settings.php.

Heine’s picture

davistv’s picture

Status: Needs review » Reviewed & tested by the community

Just applied this to an install of 6.19 after already configuring several modules, then hitting the error when adding roles to modules. Patch appears to have worked as intended, though. Doesn't look like I'll need to do a clean install or anything like that.

Heine’s picture

Version: 6.19 » 7.x-dev

Needs to be fixed in 7 first, then in 6.

Heine’s picture

Status: Reviewed & tested by the community » Needs review
Heine’s picture

Confirming whether a patch "works" (or seems to work) is only one step in the review process before a patch can attain the status "reviewed and tested by the community".

See http://drupal.org/patch/review for more.

Also, please keep the focus on 7.x-dev as it needs to be fixed there first.

hepabolu’s picture

FYI: I've downloaded and installed Drupal 7.0 3 days ago.
On my local machine (OSX PHP 5.3.2) everything works fine, no error.
On my website (copy of the local installation, shared linux hosting, PHP 5.2.17) I get the above error, but everything works.

dozymoe’s picture

I found http://www.phpwact.org/php/i18n/utf-8#i_pcre_caseless_pattern_modifier to be informative.

It said unless /u is specified the server's locale is used. Which is probably ASCII and not UNICODE.

Heine’s picture

This is intentional as we are checking bytes, not characters. Another approach is to use preg_match with the /u modifier to check for UTF-8 validity of the provided string vs. the original code that checks for certain invalid bytes.

TechNikh’s picture

I am getting same error
My System status report:
PHP 5.1.6
Drupal 6.20

does the patch in #18 work for Drupal 6.20 ?

dozymoe’s picture

@47 I think the problem lies with the server (linux system??) not correctly setup to support UNICODE or UTF-8, please see 2 (two) comments before you.

I run to this problem while helping in #drupal-support IRC channel.

If you are curious whether your system support UTF-8, you could try these commands on console (probably via ssh).

  1. Get the list of available locale.

    locale -a

    Positive result if you see a line with the word "utf8". If not you need to generate UTF-8 locale, see your server documentation on how to (hint: probably via locale-gen).

  2. Are we using the correct locale (UTF-8)?

    locale

    Positive result if LC_CTYPE value is set to "UTF-8", otherwise, again, see your server documentation.

fireh.

TechNikh’s picture

@#48 This is what I see on locale

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"

dozymoe’s picture

I put this link about PHP's regexp escape sequences for future reference, because it is damn hard to google for something like "preg_match \x". >:(

Also this specific comment that I'm not sure if it means anything. :(

Okay, one more time for the record. What's the output of this:

pcretest -C

TechNikh’s picture

@dozymoe

$ pcretest -C
PCRE version 4.5 01-December-2003
Compiled with
UTF-8 support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Match recursion uses stack

FYI This error doesn't show up in my staging server which is drupal 6.22 and also with PCRE version 8.12 2011-01-15

dozymoe’s picture

Now, we could scratch server support of UTF-8 out of the equation.

Being clueless as it is, I can only offer these steps:

  1. Upgrade pcre.

    Since this is what php use to perform preg_match, imho.

  2. Try available options at comment #18 and #3, from heine.

    Keep a note for when doing upgrades.

  3. Upgrade php.

In that order of necessity. I think. Maybe other would chime in on this.

beakalteshome’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, do820336-utf8-pregmatch-D6.patch, failed testing.

roelie’s picture

Status: Needs review » Needs work

In drupal7 (fresh install), had the same problem.

#3 (http://drupal.org/node/820366#comment-3069886) got rid of the error for me.