diff options
author | Lilli <lilli@janrain.com> | 2010-02-10 11:17:00 -0800 |
---|---|---|
committer | Lilli <lilli@janrain.com> | 2010-02-10 11:17:00 -0800 |
commit | 7bc8f2a17c7ca36f0e4238d9b3c97c6006ee3092 (patch) | |
tree | 036eac52261e10072c118d77cc386f38c20c26eb | |
parent | 106832dd5c6d218e57e7ab8f42ed839f0eb432ae (diff) | |
download | php-openid-7bc8f2a17c7ca36f0e4238d9b3c97c6006ee3092.zip php-openid-7bc8f2a17c7ca36f0e4238d9b3c97c6006ee3092.tar.gz php-openid-7bc8f2a17c7ca36f0e4238d9b3c97c6006ee3092.tar.bz2 |
Added the following patch from the dev@openidenabled.com mailing list:
http://lists.openidenabled.com/pipermail/dev/attachments/20080117/5d35b90c/attachment.obj
Original Message:
artemy tregoubenko me at arty.name
Thu Jan 17 01:58:39 PST 2008
php: raw bytestrings vs. mb_string.func_overload and strlen
"Hello.
After all, patch for unicode support in 'html parser' is quite small.
It solves my problems for now.
On 1/16/08, artemy tregoubenko <me at arty.name> wrote:
> Hello again!
>
> Today I switched to php-openid 2.0.0 and some things began working.
> However, I experienced more problems with multibyte strings. Now they
> happen at stage of fetching and parsing html documents.
> ParanoidFetcher was easy to fix, patch for it attached. Currently I'm
> hacking into ParseHTML, and using regexes in php-unicode environment
> is a pain!
>
> --
> arty ( http://arty.name )
>
>
--
arty ( http://arty.name )"
It should be noted that hunks 1 and 4, out of the patch's 4, were applied successfully, I manually applied hunk 2, and hunk 3 could no longer be applied for the same reason as the previous patch: In both cases, the patches modified the same function, and the current function no longer contains the lines of code that the 3rd hunk is trying to modify. On that note, both patches are modifying the same lines of code in the same function. From what I can tell from the email messages, they are fixing different issues, but it should be confirmed that the fixes are both needed and will play nicely together.
-rw-r--r-- | Auth/OpenID/Parse.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Auth/OpenID/Parse.php b/Auth/OpenID/Parse.php index 0d2ebef..4e6c7dd 100644 --- a/Auth/OpenID/Parse.php +++ b/Auth/OpenID/Parse.php @@ -215,6 +215,21 @@ class Auth_OpenID_Parse { return $str; } } + + function match($regexp, $text, &$match) + { + if (!is_callable('mb_ereg_search_init')) { + return preg_match($regexp, $text, $match); + } else { + $regexp = substr($regexp, 1, strlen($regexp) - 2 - strlen($this->_re_flags)); + mb_ereg_search_init($text, $regexp); + if (!mb_ereg_search()) { + return false; + } + list($match) = mb_ereg_search_getregs(); + return true; + } + } /** * Find all link tags in a string representing a HTML document and @@ -254,8 +269,8 @@ class Auth_OpenID_Parse { // Try to find the <HEAD> tag. $head_re = $this->headFind(); - $head_matches = array(); - if (!preg_match($head_re, $stripped, $head_matches)) { + $html_match = ''; + if (!$this->match($html_re, $stripped, $html_match)) { ini_set( 'pcre.backtrack_limit', $old_btlimit ); return array(); } @@ -263,7 +278,7 @@ class Auth_OpenID_Parse { $link_data = array(); $link_matches = array(); - if (!preg_match_all($this->_link_find, $head_matches[0], + if (!preg_match_all($this->_link_find, $head_match, $link_matches)) { ini_set( 'pcre.backtrack_limit', $old_btlimit ); return array(); |