Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nojimage committed Feb 28, 2014
2 parents f050096 + b90a55d commit 2cf4d68
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 34 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ php:

before_script:
- composer install --dev
- patch vendor/twitter/twitter-text-conformance/validate.yml < validate.yml.patch

script:
- phpunit
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"type": "package",
"package": {
"name": "twitter/twitter-text-conformance",
"version": "v1.6.1",
"version": "v1.8.0",
"source": {
"url": "https://github.com/twitter/twitter-text-conformance.git",
"type": "git",
"reference": "v1.6.1"
"reference": "v1.8.0"
}
}
}
Expand All @@ -46,7 +46,7 @@
"require-dev": {
"php": ">=5.3.3",
"symfony/yaml": "*",
"twitter/twitter-text-conformance": "v1.6.1"
"twitter/twitter-text-conformance": "1.8.0"
},
"autoload": {
"psr-0": {
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/Twitter/Autolink.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@ public function addLinks($loose = false) {

// loose mode
$original = $this->tweet;
$this->tweet = $this->addLinksToURLs();
$this->tweet = $this->addLinksToHashtags();
$this->tweet = $this->addLinksToCashtags();
$this->tweet = $this->addLinksToUsernamesAndLists();
$this->tweet = $this->addLinksToURLs($loose);
$this->tweet = $this->addLinksToHashtags($loose);
$this->tweet = $this->addLinksToCashtags($loose);
$this->tweet = $this->addLinksToUsernamesAndLists($loose);
$modified = $this->tweet;
$this->tweet = $original;
return $modified;
Expand Down
19 changes: 15 additions & 4 deletions lib/Twitter/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ public static function __static() {
$tmp['valid_domain_name'] = '(?:(?:'.$tmp['domain_valid_chars'].'(?:[-]|'.$tmp['domain_valid_chars'].')*)?'.$tmp['domain_valid_chars'].'\.)';
$tmp['domain_valid_unicode_chars'] = '[^[:punct:][:space:][:blank:][:cntrl:]'.$tmp['invalid_characters'].$tmp['spaces'].']';

$tmp['valid_gTLD'] = '(?:(?:aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|xxx)(?=[^0-9a-z]|$))';
$tmp['valid_ccTLD'] = '(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?=[^0-9a-z]|$))';
$tmp['valid_gTLD'] = '(?:(?:aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|xxx)(?=[^0-9a-z@]|$))';
$tmp['valid_ccTLD'] = '(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?=[^0-9a-z@]|$))';
$tmp['valid_punycode'] = '(?:xn--[0-9a-z]+)';

$tmp['valid_domain'] = '(?:' // subdomains + domain + TLD
Expand Down Expand Up @@ -269,10 +269,21 @@ public static function __static() {
$tmp['valid_port_number'] = '[0-9]+';

$tmp['valid_general_url_path_chars'] = '[a-z0-9!\*;:=\+\,\.\$\/%#\[\]\-_~&|@'.$tmp['latin_accents'].']';
# Allow URL paths to contain balanced parentheses:
# Allow URL paths to contain up to two nested levels of balanced parentheses:
# 1. Used in Wikipedia URLs, e.g. /Primer_(film)
# 2. Used in IIS sessions, e.g. /S(dfd346)/
$tmp['valid_url_balanced_parens'] = '(?:\('.$tmp['valid_general_url_path_chars'].'+\))';
# 3. Used in Rdio URLs like /track/We_Up_(Album_Version_(Edited))/
$tmp['valid_url_balanced_parens'] = '(?:\('
. '(?:' . $tmp['valid_general_url_path_chars'] . '+'
. '|'
// allow one nested level of balanced parentheses
. '(?:'
. $tmp['valid_general_url_path_chars'] . '*'
. '\(' . $tmp['valid_general_url_path_chars'] . '+' . '\)'
. $tmp['valid_general_url_path_chars'] . '*'
. ')'
. ')'
. '\))';
# Valid end-of-path characters (so /foo. does not gobble the period).
# 1. Allow =&# for empty URL parameters and other URL-join artifacts.
$tmp['valid_url_path_ending_chars'] = '(?:[a-z0-9=_#\/\+\-'.$tmp['latin_accents'].']|(?:'.$tmp['valid_url_balanced_parens'].'))';
Expand Down
22 changes: 22 additions & 0 deletions tests/Twitter/AutolinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,28 @@ public function autoLinkWithJSONProvider() {
return $this->providerHelper('json');
}

/**
* Check the addLinks method pass to legacy methods on loose mode
*
* @covers Twitter_Autolink::addLinks
*/
public function testAddLinksWithLooseOption() {
$this->linker = $this->getMock('Twitter_Autolink', array(
'autoLinkURLs',
'autoLinkHashtags',
'autoLinkCashtags',
'autoLinkUsernamesAndLists',
), array(
'some tweet #hashtag http://example.com'
));

$this->linker->expects($this->never())->method('autoLinkURLs');
$this->linker->expects($this->never())->method('autoLinkHashtags');
$this->linker->expects($this->never())->method('autoLinkCashtags');
$this->linker->expects($this->never())->method('autoLinkUsernamesAndLists');
$this->linker->addLinks(true);
}

}

################################################################################
Expand Down
13 changes: 0 additions & 13 deletions validate.yml.patch

This file was deleted.

0 comments on commit 2cf4d68

Please sign in to comment.