summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-02-20 13:41:49 +0100
committerRemi Collet <fedora@famillecollet.com>2014-02-20 13:41:49 +0100
commit3050cbb15af888193cc6aa1e738ad60c37e7e7d1 (patch)
treef05d06a75de803f963aeee8b911916531bd9e449
parent7dc050afaa391789db3e39eb5da6e232eb66d318 (diff)
php-PHP-CSS-Parser: add upstream patch (required by Horde_Css_Parser)
-rw-r--r--php-PHP-CSS-Parser-git.patch84
-rw-r--r--php-PHP-CSS-Parser.spec14
2 files changed, 95 insertions, 3 deletions
diff --git a/php-PHP-CSS-Parser-git.patch b/php-PHP-CSS-Parser-git.patch
new file mode 100644
index 0000000..ae6b02c
--- /dev/null
+++ b/php-PHP-CSS-Parser-git.patch
@@ -0,0 +1,84 @@
+From 21ac4d9fb408f803aac180503c41f3e4648f575f Mon Sep 17 00:00:00 2001
+From: Paul Annekov <paul.annekov@gmail.com>
+Date: Tue, 29 Oct 2013 23:44:25 +0200
+Subject: [PATCH] Fixed comments parsing and test added
+
+---
+ lib/Sabberworm/CSS/Parser.php | 9 +++++----
+ tests/Sabberworm/CSS/ParserTest.php | 8 ++++++++
+ tests/files/comments.css | 16 ++++++++++++++++
+ 3 files changed, 29 insertions(+), 4 deletions(-)
+ create mode 100644 tests/files/comments.css
+
+diff --git a/lib/Sabberworm/CSS/Parser.php b/lib/Sabberworm/CSS/Parser.php
+index 7a64074..4445322 100644
+--- a/lib/Sabberworm/CSS/Parser.php
++++ b/lib/Sabberworm/CSS/Parser.php
+@@ -546,10 +546,10 @@ private function consumeWhiteSpace() {
+
+ private function consumeComment() {
+ if ($this->comes('/*')) {
+- $this->consume(2);
+- while ($this->consumeUntil('*', false, true)) {
+- if ($this->comes('/')) {
+- $this->consume(1);
++ $this->consume(1);
++ while ($this->consume(1) !== '') {
++ if ($this->comes('*/')) {
++ $this->consume(2);
+ return true;
+ }
+ }
+@@ -567,6 +567,7 @@ private function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false)
+ $start = $this->iCurrentPosition;
+
+ while (($char = $this->consume(1)) !== '') {
++ $this->consumeComment();
+ if (in_array($char, $aEnd)) {
+ if ($bIncludeEnd) {
+ $out .= $char;
+diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php
+index 3b38770..aaf11a6 100644
+--- a/tests/Sabberworm/CSS/ParserTest.php
++++ b/tests/Sabberworm/CSS/ParserTest.php
+@@ -343,6 +343,14 @@ function testListValueRemoval() {
+ }#unrelated {other: yes;}' . "\n", $oDoc->__toString());
+ }
+
++ function testComments() {
++ $oDoc = $this->parsedStructureForFile('comments');
++ $sExpected = '@import url("some/url.css") screen;.foo, #bar {background-color: #000;}
++@media screen {#foo.bar {position: absolute;}
++}';
++ $this->assertSame($sExpected, $oDoc->__toString());
++ }
++
+ function parsedStructureForFile($sFileName) {
+ $sFile = dirname(__FILE__) . '/../../files' . DIRECTORY_SEPARATOR . "$sFileName.css";
+ $oParser = new Parser(file_get_contents($sFile));
+diff --git a/tests/files/comments.css b/tests/files/comments.css
+new file mode 100644
+index 0000000..d30bc53
+--- /dev/null
++++ b/tests/files/comments.css
+@@ -0,0 +1,16 @@
++/**
++ * Comments Hell.
++ */
++@import /* Number 1 */"some/url.css"/* Number 2 */ screen/* Number 3 */;
++
++.foo, /* Number 4 */ #bar/* Number 5 */ {
++ background-color/* Number 6 */: #000/* Number 7 */;
++}
++
++@media /* Number 8 */screen /* Number 9 */{
++ /** Number 10 **/
++ #foo.bar {
++ position: absolute;/**/
++ }
++}
++/** Number 11 **/
+\ No newline at end of file
+--
+1.8.5.1
+
diff --git a/php-PHP-CSS-Parser.spec b/php-PHP-CSS-Parser.spec
index 53b041b..5bd0cca 100644
--- a/php-PHP-CSS-Parser.spec
+++ b/php-PHP-CSS-Parser.spec
@@ -14,12 +14,15 @@
Name: php-%{gh_project}
Summary: A Parser for CSS Files
Version: 5.1.1
-Release: 1%{?dist}
+Release: 2%{?dist}
+License: MIT
+Group: Development/Libraries
URL: https://github.com/%{gh_owner}/%{gh_project}
Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}.tar.gz
-License: MIT
-Group: Development/Libraries
+
+# Upstream patches
+Patch0: %{name}-git.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
@@ -41,6 +44,8 @@ of said structure and output as (optimized) CSS.
%prep
%setup -q -n %{gh_project}-%{gh_commit}
+%patch0 -p1
+
%build
# nothing to build
@@ -64,6 +69,9 @@ phpunit --bootstrap bootstrap.php .
%changelog
+* Thu Feb 20 2014 Remi Collet <remi@fedoraproject.org> - 5.1.1-2
+- add upstream patch (required by Horde_Css_Parser)
+
* Mon Oct 28 2013 Remi Collet <remi@fedoraproject.org> - 5.1.1-1
- update to 5.1.1 (no change, only documentation)