Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter Utils return incorrect status length. #346

Closed
WesleyJohnson opened this issue Jun 1, 2016 · 5 comments
Closed

Twitter Utils return incorrect status length. #346

WesleyJohnson opened this issue Jun 1, 2016 · 5 comments
Milestone

Comments

@WesleyJohnson
Copy link

WesleyJohnson commented Jun 1, 2016

The calc_expected_status_length def in twitter_utils.py is returning an incorrect status length when feeding it decimals.

import twitter
print twitter.twitter_utils.calc_expected_status_length('72.00')

This returns 23 instead of 5. Something is screwy with the Regex.

def calc_expected_status_length(status, short_url_length=23):

@jeremylow
Copy link
Collaborator

Technically that's a valid IP address, but yeah, I can see how that gets annoying. From man inet:

a.b     Part a specifies the first byte of the binary address.   Part
        b is interpreted as a 24-bit value that defines the rightmost
        three bytes of the binary address.  This notation is suitable
        for specifying (outmoded) Class A network addresses.

Since Twitter isn't recognizing it as an IP address, we should mirror their behavior and say it isn't.

@WesleyJohnson
Copy link
Author

Interesting, I didn't know that was considered a valid IP. Twitter's determination of what is and isn't an address seems pretty extensive when looking at their twitter-text lib: https://github.com/twitter/twitter-text/blob/master/js/twitter-text.js It seems like a non-trivial task to port that over to python.

@jeremylow
Copy link
Collaborator

Yeah we take a slightly more liberal approach in a few cases, but our lib is based off of that. 

Jeremy Low

    _____________________________

From: Wes Johnson notifications@github.com
Sent: Wednesday, June 1, 2016 10:07 AM
Subject: Re: [bear/python-twitter] Twitter Utils return incorrect status length. (#346)
To: bear/python-twitter python-twitter@noreply.github.com
Cc: Jeremy Low jeremylow@gmail.com, Comment comment@noreply.github.com

Interesting, I didn't know that was considered a valid IP. Twitter's determination of what is and isn't an address seems pretty extensive when looking at their twitter-text lib: https://github.com/twitter/twitter-text/blob/master/js/twitter-text.js It seems like a non-trivial task to port that over to python.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@WesleyJohnson
Copy link
Author

I discovered the option to disable tweet length verification in the PostUpdate using the verify_status_length arg. I'm using that to get around this which works well enough for my needs. Thanks!

@jeremylow jeremylow added this to the 3.2 milestone Oct 4, 2016
@jeremylow
Copy link
Collaborator

Lands in development with 3.2dev0 ( PR #394 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants