Modify

Ticket #63 (closed defect: invalid)

Opened 7 years ago

Last modified 7 years ago

% character cannot start a scalar value token

Reported by: sproaticus Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords:
Cc:

Description

A scalar value cannot start with a % (percent sign) character, though the YAML specification only reserves that character at the beginning of a non-indented line for directives and tags (see  http://yaml.org/spec/current.html#id2523453 and  http://yaml.org/spec/current.html#id2524297 ). This character should be legal as the first character of a scalar value, e.g. for Python %s-style string substitution and templates.

>>> yaml.load('yaml: %')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/PIL/__init__.py", line 66, in load
    
  File "build/bdist.linux-i686/egg/yaml/constructor.py", line 38, in get_data
  File "build/bdist.linux-i686/egg/yaml/composer.py", line 27, in get_node
  File "build/bdist.linux-i686/egg/yaml/composer.py", line 34, in compose_document
  File "build/bdist.linux-i686/egg/yaml/composer.py", line 63, in compose_node
  File "build/bdist.linux-i686/egg/yaml/composer.py", line 112, in compose_mapping_node
  File "build/bdist.linux-i686/egg/yaml/composer.py", line 43, in compose_node
  File "build/bdist.linux-i686/egg/yaml/parser.py", line 95, in check_event
  File "build/bdist.linux-i686/egg/yaml/parser.py", line 446, in parse_block_mapping_value
  File "build/bdist.linux-i686/egg/yaml/scanner.py", line 116, in check_token
  File "build/bdist.linux-i686/egg/yaml/scanner.py", line 257, in fetch_more_tokens
yaml.scanner.ScannerError: while scanning for the next token
found character '%' that cannot start any token
  in "<string>", line 1, column 7:
    yaml: %
          ^

Environment:

  • Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
  • PyYAML-3.05-py2.5.egg

Attachments

Change History

comment:1 Changed 7 years ago by xi

  • Status changed from new to closed
  • Resolution set to invalid

It is not so: the % sign is an indicator character and cannot start a plain scalar, see the productions ns-plain-first-char and c-indicator in the spec:

 http://yaml.org/spec/cvs/current.html#ns-plain-first-char(c)  http://yaml.org/spec/cvs/current.html#c-indicator

You request to allow it to start an indented scalar value may be reasonable, but I'd prefer that the matter is discussed on the yaml-core list before making any changes in the parser code.

comment:2 Changed 7 years ago by sproaticus

Whoops. I thought I read over that part, but I now see that you are correct. Thanks for clarifying that.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.