Cssutils

Latest version: v2.11.1

Safety actively analyzes 682404 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 13 of 21

0.9.6b3

+ **FEATURE**: Added parsing support and new profile for details defined in module Fonts http://www.w3.org/TR/css3-fonts/
+ new properties: ``font-stretch``, ``font-size-adjust``
+ font-face rules use a different profile for validation now which uses the defined properties only:
- ``font-family font-style font-weight`` properties redefined
- added ``src`` and ``unicode-range`` properties
+ Added ``CSSFontFaceRule.valid``. A font-face rule is valid if all font descriptions properties are valid and properties ``font-family`` and ``src`` are set.

+ **FEATURE**: Added ``cssutils.parseStyle(cssText, encoding='utf-8')`` convienience function which assumes that the given `cssText` is the content of an HTML style attribute. It returns a :class:`~cssutils.css.CSSStyleDeclaration`.

+ **FEATURE** (experimental, request from Bitbucket 27): Added ``css.CSSStyleDeclaration.children()`` which is a generator yielding any known children of a declaration including *all* properties, comments or CSSUnknownRules.

+ FEATURE: ``CSSStyleDeclaration.insertRule`` also accepts a ``CSSRuleList`` now (same as ``CSSStyleSheet`` which does this for some time now).

+ FEATURE: Added ``CSSStyleDeclaration.keys()`` method which analoguous to standard dict returns property names which are set in the declaration.

- **API CHANGE**: Replaced attribute ``css.Property.parentStyle`` with ``css.Property.parent`` (``parentStyle`` is DEPRECATED now).

- API CHANGE: Added attribute ``parent`` to all CSSRules. It contains the Parent Node of this CSSRule (currently if a CSSStyleDeclaration only!) or None.

- API CHANGE (minor): Removed parameter ``profiles`` from ``cssutils.css.Property.validate()``. During validation each property checks which profiles to use which normally are all registered profiles in cssutils.profile. Exceptions are font-face (TODO: and page) rules which use their specific profile only. To add custom properties or values for the validation of these rules you need to add these to ``properties[Profiles.CSS3_FONT_FACE]`` in module ``cssutils.profiles`` and reregister that profile.

+ **BUGFIX**: Improved child and parent node referencing.
- setting ``CSSStyleSheet.cssRules`` and ``CSSMediaRule.cssRules`` correctly update ``parentStyleSheet`` (and ``parentRule``) of contained rules now. Also settings ``cssRules`` should now work as expected.
- setting ``css.CSSStyleRule.selectorList`` with a ``css.SelectorList`` object uses this new object directly
- setting ``css.CSSStyleRule.style`` with a ``css.CSSStyleDeclaration`` object uses this new object directly
- ``CSSStyleDeclaration.parentRule`` was not properly set for CSSStyleRule, CSSPageRule and CSSFontFaceRule.

+ **BUGFIX**: Parsing of CSSValues with unknown function names with a specific length of 4 or 7 chars were resulting in a SyntaxErr. Also parsing of comma separated list of CSS FUNCTION values works now.

+ BUGFIX: Fixed validation problems:
- ``font-family: a b`` (values with spaces in names without being quoted) are parsed now without emitting an ERROR. These are indeed valid but discouraged and you should use quotes (more than one space is compacted to a single space anyway so rather complicated without quotes)
- negative lengths for the ``font-size`` property are now properly reported as ERRORs

- IMPROVEMENT (minor): cssutils sets the HTTP header ``User-Agent`` now when fetching sheets over HTTP (with e.g. ``cssutils.parseUrl``).

+ CHANGES:
- Refactored predefined ``Prod`` objects used for parsing of ``CSSValue``. Also added ``Predef.unicode_range`` and renamed ``CHAR`` to ``char``.
- Removed css3productions which were only used for tests only anyway and which were not up to date at all

- *FEATURE* (experimental): Added support to at least parse sheets with Microsoft only property values for ``filter`` which start with ``progid:DXImageTransform.Microsoft.[...](``. To enable these you need to set::

>>> from cssutils import settings
>>> settings.set('DXImageTransform.Microsoft', True)
>>> cssutils.ser.prefs.useMinified()
>>> text = 'a {filter: progid:DXImageTransform.Microsoft.BasicImage( rotation = 90 )}'
>>> print cssutils.parseString(text).cssText
a{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=90)}
>>>

This currently is a **major hack** but if you like to minimize sheets in the wild which use this kind of CSS cssutils at least can parse and reserialize them.
Also you cannot reset this change until you restart your program.

These custom CSS FUNCTION names are not normalized at all. Also stuff like ``expression(...)`` which was normalized until now is not anymore.

0.9.6b2

NO RELEASE

0.9.6b1

+ BUGFIX: Fixed ``CSSPageRule.selectorText = ''`` which does reset the selector now

+ BUGFIX (minor): Removed false references in a few modules' ``__all__`` list

- IMPROVEMENT: Jython 2.5 (from RC4) runs all tests now but a few changes had to be done:
- exception messages sometimes do have a different format in Jython and Python (but also between Python versions >= 2.5 and < 2.4 ...)
- Jython's ``xml.dom.Exception`` misses attribute ``args`` it seems

0.9.6a4

- **API CHANGE**: Reverted handling of exceptions (Bitbucket 24) as this did not work with PyXML installed. You may again use ``str(e)`` on any raised xml.dom.Exception ``e``. Since 0.9.6a0 exceptions raised did raise a tuple of message, line and col information. Now the message alone is raised (again). Line and col information is still available as ``e.line, e.col``.

+ BUGFIX: Fixed Bitbucket 22 parsing or actually reserializing of values like ``content: "\\"``

+ BUGFIX: All examples at http://www.w3.org/TR/2009/CR-CSS2-20090423/syndata.html#illegalvalues should work now as expected:
- Unknown ATKEYWORD tokens in selectors make these invalid now, see example : ``p here {color: red}``
- completion of incomplete media rule like ``media screen { p:before { content: 'Hello`` does work now when parsing with a non raising parser

- **FEATURE**: Updated some parts to http://www.w3.org/TR/2009/CR-CSS2-20090423/changes.html#new (most changes decribed there were already done in cssutils)
+ updated tokenizer macro ``escape``
+ replaced media ``aural`` with ``speech``
+ property ``content`` has allowed value ``none`` now
+ property ``background-position`` allows mixed values like ``left 10%`` now

- **FEATURE**: New preference option ``keepUnkownAtRules = False`` which defines if unknown atrules like e.g. ``three-dee {...}`` are kept or not. Setting this pref to ``False`` in result removes unknown rules from the serialized sheet which is the default for the minified settings.

- **IMPROVEMENT**: Fixed Bitbucket 23. The examples/style.py example renderer was reusing ``Property`` objects for each HTML element so they effectively overwrote each other.

+ DOCUMENTATION: Using Sphinx 0.6.1 now

0.9.6a3

- **IMPROVEMENT**: Fixed ``CSSStyleDeclaration.length`` for Python 2.6.2 (due to a backport from Python 2.7 to 2.6.2 the reversed() iterator has no __length__ anymore which cssutils was using)

+ **BUGFIX**: New version of encutils (0.9) with these fixes:
- invalid HTML (like ``< />``) does not stop the encoding detection anymore
- fixed ``tryEncodings`` if chardet is not installed
- mismatch is ``False`` now if mime-type is ``text/xml`` (or similar) and XML encoding pseudo attribute defines encoding as this is ignored completely!
- default encoding for CSS is UTF-8 now if not other HTTP info is given. charset encoding information is **not** used by encutils!
- log output for mismatch uses ``!=`` instead of ``<>`` now
- fixed testcases which were not all tested :(most embarrassing)

+ **BUGFIX**: Fixed Bitbucket 21 http://code.google.com/p/cssutils/issues/detail?id=21. Definition of valid values for property `background-position` was wrong. Still mixed values like ``background-position: 0 top`` are invalid although most browsers accept them. But the CSS 2.1 spec defines it the above way. CSS3 backgrounds is not implemented yet in cssutils.

0.9.6a2

+ **API CHANGE**: :class:`cssutils.profiles.Profiles` (introduced in 0.9.6a1) has been refactored:

- ``cssutils.profile`` (a ``cssutils.profiles.Profiles`` object) is now preset and available used for all validation
- moved variable ``cssutils.profiles.defaultprofile`` to attribute ``Profiles.defaultProfiles`` (and so also available as ``cssutils.profile.defaultProfiles``)
- renamed ``Profiles.CSS_BOX_LEVEL_3`` to ``Profiles.CSS3_BOX`` and ``Profiles.CSS_COLOR_LEVEL_3`` to ``Profiles.CSS3_COLOR``
- renamed ``Profiles.basicmacros`` to ``Profiles._TOKEN_MACROS`` and ``Profiles.generalmacros`` to ``Profiles._MACROS``. As these two are always added to your property definitions there is no need to use these predefined macro dictionaries in your code.
- renamed ``Profiles.knownnames`` to ``Profiles.knownNames``
- ``Profiles.validateWithProfile`` returns ``valid, matching, profiles`` now
- renamed named parameter in ``cssutils.css.Property.validate(profiles=None)`` from ``profile`` to ``profiles``
- ``cssutils.profiles.properties`` (and new ``cssutils.profiles.macros``) use as keys the predefined constants in Profiles, like e.g. ``Profiles.CSS_LEVEL_2`` now. If you want to use some of the predefind macros you may e.g. use ``cssutils.profiles.macros[Profiles.CSS_LEVEL_2]['family-name']`` (in addition to the always available ``Profiles._TOKEN_MACROS`` and ``Profiles._MACROS``).

+ **CHANGE**: Reporting levels of properties have changed. Please see :meth:`cssutils.css.Property.validate` for details. E.g. valid properties in the current profile are only reported on DEBUG and not INFO level anymore. The log output has been changed too, context information is provided now (line, column and name of the relevant property)

- FEATURE: Added new properties as profile ``Profiles.CSS3_PAGED_MEDIA``: *fit*, *fit-position*, *image-orientation*, *page*, *size* and relevant properties already defined in ``Profiles.CSS_LEVEL_2``

+ **BUGFIX**: ``p.valid == False`` is now set for Properties not valid in the current profile even if they are valid in a different profile
+ **BUGFIX**: Macros used when adding a new profile to ``cssutils.profile`` were polluted with ALL macros ever defined. They now correctly use the (always used) predefined macros ``Profiles._TOKEN_MACROS`` and ``PROFILES._MACROS`` in addition to the given macros (``cssutils.profile.addProfile(self, profile, properties, macros=None)``) only. If you want to use any macros defined in other profiles you need to add these to your own macros as seen in ``macros[Profiles.CSS3_BOX]``.
+ BUGFIX: If ``cssutils.ser.prefs.validOnly == True`` serializer incorrectly put a single ``;`` for invalid properties out until now.

- **IMPROVEMENT**: comments added by ``cssutils.resolveImports`` only use the import rules' href and not the absolute href of the referenced sheets anymore (might have been a possible security hole when showing a full local path to a sheet in a combined but not minified sheet)

- IMPROVEMENT: IE specific `alpha` values like ``filter: alpha(opacity=80)`` are parsed and kept now.

Page 13 of 21

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.