The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 06:06:22 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Any ideas why this is happening?  (Read 4707 times)
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« on: September 26, 2007, 07:55:13 PM »

So I have something that looks like this:

Code:
<img width="200" alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA" height="70">

And this regex is not working. I thought I was pretty decent with regex. Anyone see any obvious clues as to why it's not working?
Code:
preg_match("/alt=\" Visual verification \" src=\"(.*?)\"/",$page,$out);

I recently changed it from this:
Code:
preg_match_all('/\"(.+?aptcha\?ctoken=.+?)\"/',$page,$out);

to see if it would make a difference.
Logged

hai
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #1 on: September 27, 2007, 03:09:52 AM »

Code:
<?php

$target 
= <<< EOF
<img width="200" alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA" height="70">
EOF;

$regex "/alt=\" Visual verification \" src=\"(.*?)\"/";

preg_match_all$regex$target$matches );

print_r$matches );

?>



outputs;

Code:
Array
(
    [0] => Array
        (
            [0] => alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA"
        )

    [1] => Array
        (
            [0] => https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA
        )

)


Not sure what the problem is here dude.....

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #2 on: September 27, 2007, 05:33:11 AM »

You're telling me. I check the variable that contains the page with that string ($page), and it all looks perfectly fine. For whatever reason, the regex is just not parsing that stuff out though.
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: September 27, 2007, 08:43:57 AM »

So you're saying that the exact same code, which can process it out of page like TD's example here, does not work when it's on-page (in $page)?

If that's so, can you paste the entire buffer of a page here and the exact chunk of code that went to get it and let's give'r a whirl... unless there's a multiline thing or some other regex-behavior issue it's hard to see from this little bit of info what is going on...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #4 on: September 27, 2007, 10:52:47 AM »

my guess was going to be multiline issues as well. not sure how regex in PHP handles multilines, but it was in issue in ASP. (i think)(
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: September 27, 2007, 11:16:49 AM »

in PHP the default is PERL regex behavior, meaning that if you want to do cross-line-boundary patterns you need to add the m modifier ie., preg_match('/apattern/m', $inStr);
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #6 on: September 27, 2007, 03:31:31 PM »

It's a LONG page with a lot of javscript (if you can't tell by the short sample, it's gmail). Here's a sample:

Code:
<tr> <td valign="top"> <span class="gaia cud cl">  Word Verification:  </span> </td> <td> <table>                            <input type="hidden" id="newaccounttoken" value="Q7mdu2BAPFi8ymw3xiqM52gWU1k_YII7KFYMOUHVJPh68EZG7R9tRHYTOp6VTmtl:WD1BvkO-1W6VqBm3zZb9hg" name="newaccounttoken"> <input type="hidden" id="newaccounturl" value="https://www.google.com/accounts/Captcha?ctoken=Q7mdu2BAPFi8ymw3xiqM52gWU1k_YII7KFYMOUHVJPh68EZG7R9tRHYTOp6VTmtl%3AWD1BvkO-1W6VqBm3zZb9hg" name="newaccounturl"> <tr> <td valign="top"></td> <td valign="top"> <span class="gaia captchahtml desc"> Type the characters you see in the picture below. </span> <div> <img width="200" alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=Q7mdu2BAPFi8ymw3xiqM52gWU1k_YII7KFYMOUHVJPh68EZG7R9tRHYTOp6VTmtl%3AWD1BvkO-1W6VqBm3zZb9hg" height="70">   </div>  <input type="hidden" id="newaccounttoken_audio" value="-OQel7eOrsxFfpMEnYhvAIVmofWUhISS89bP5y1T1c97ZdAxWSqCv5rGVhbX4k0SZ3-OjKbxz5tKN_CCqgnQ-A:tjZk1zOqexxSk3SykcIfHw" name="newaccounttoken_audio"> <input type="hidden" id="newaccounturl_audio" value="https://www.google.com/accounts/Captcha?ctoken=-OQel7eOrsxFfpMEnYhvAIVmofWUhISS89bP5y1T1c97ZdAxWSqCv5rGVhbX4k0SZ3-OjKbxz5tKN_CCqgnQ-A%3AtjZk1zOqexxSk3SykcIfHw" name="newaccounturl_audio"> <div id="snd1"></div><div id="noEm"></div> <div id="playAudio"></div>  </td> </tr>
Logged

hai
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #7 on: September 28, 2007, 01:12:58 AM »

I've seen the gmail code, it's a massive one-liner pretty much. Wonder if preg_match is barfing on the fact that there are no line breaks (which would be a bug that should be documented). Just a thought.

Cheers,
td

BTW, that sample works fine in my test rig as well.
« Last Edit: September 28, 2007, 01:22:21 AM by thedarkness » Logged

"I want to be the guy my dog thinks I am."
 - Unknown
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #8 on: September 28, 2007, 04:22:18 AM »

Well if any of you feel so inclined, it would give you a chance to see the actual problem if you grabbed the gmail page at https://mail.google.com/mail/signup and checked the code against that.
Logged

hai
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #9 on: September 28, 2007, 05:16:26 PM »

I'm on it VS, hang tough my brother from another mother.

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #10 on: September 29, 2007, 03:19:45 AM »

Hate to tell you this VS but I followed your link to the Gmail signup page in FF, viewed source, pasted into the above code and ran it and it performed flawlessly AFAICS. Extracted this one link;

https://www.google.com/accounts/Captcha?ctoken=VoJLcsVl0CJZ8u7Roflt9nmU_WOgSi-Mf_rUsd9OYEd4ZfQtAhJzdNFqpaM456J9%3ASExuqDKDeMvyy_e58Afj_Q

There is obviously something going on here that we're missing........ Huh???

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #11 on: September 30, 2007, 02:56:42 PM »

It could very well be my friend's hosting that he's running it on. I will have to test it on mine when I get a spare second.

Thanks homes.

-V
Logged

hai
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!