Recent Topics

1 Jun 21, 2017 12:41    

Only happens in disp=single/post

regular expression /https?:\/\/(www\.)?twitter\.com\/(#!\/)?@?([^\/\?]*)/ breaks by including " target="_blank" rel="nofollow">

		// Get author's Twitter username
		if( $creator_User = & $Item->get_creator_User() )
		{
			if( $twitter_links = $creator_User->userfield_values_by_code( 'twitter' ) )
			{
				preg_match( '/https?:\/\/(www\.)?twitter\.com\/(#!\/)?@?([^\/\?]*)/', $twitter_links[0], $matches );
				if( isset( $matches[3] ) )
				{
					echo '<meta property="twitter:creator" content="@'.$matches[3].'" />'."\n";
				}
			}
		}

Replace with: /https?:\/\/(www\.)?twitter\.com((?:\/\#!)?\/(\w+))/

		// Get author's Twitter username
		if( $creator_User = & $Item->get_creator_User() )
		{
			if( $twitter_links = $creator_User->userfield_values_by_code( 'twitter' ) )
			{
				preg_match( '/https?:\/\/(www\.)?twitter\.com((?:\/\#!)?\/(\w+))/', $twitter_links[0], $matches );
				if( isset( $matches[3] ) )
				{
					echo '<meta property="twitter:creator" content="@'.$matches[3].'" />'."\n";
				}
			}
		}

3 Jul 14, 2017 03:07

@achillis

breaks by including " target="_blank" rel="nofollow">

Can you please specify where you are including " target="_blank" rel="nofollow">?

4 Jul 14, 2017 08:35

I realize my explination is unclear.

The regular expression used does not seem to extract the username correctly. It returns other parts of the string that it shouldn't

5 Jul 16, 2017 17:43

@achillis Ok, thanks for clarifying. Nonetheless I feel we need to check this for security reasons: where is the part " target="_blank" rel="nofollow"> coming from in the first place?

Thanks.


Form is loading...