Last modified: 2011-04-18 12:26:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30416, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28416 - YAML output fails to literalize strings which start with \n
YAML output fails to literalize strings which start with \n
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Roan Kattouw
: easy
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-04 14:13 UTC by kahrl
Modified: 2011-04-18 12:26 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description kahrl 2011-04-04 14:13:43 UTC
If a string starts with a newline but does trigger any other condition in Spyc::_needLiteral(), Spyc fails to write it to the YAML output as a literal (i.e. starting with |- and properly escaped). This is because strpos( $value, "\n" ) returns 0, which is interpreted as false. This bug causes Perl's YAML module and possibly other loaders to choke on the YAML.

The trivial fix is to change line 167 of phase3/includes/libs/spyc.php from
        strpos( $value, "\n" ) || 
to
        strpos( $value, "\n" ) !== false || 


Example of a query that triggers this bug:

http://de.guttenplag.wikia.com/api.php?action=query&format=yaml&prop=revisions&rvprop=content&titles=Benutzer:Kahrl/YamlBug

Example of a query that triggers but does not show this bug (because there's also a # in the string):

http://de.guttenplag.wikia.com/api.php?action=query&format=yaml&prop=revisions&rvprop=content&titles=Benutzer:Kahrl/YamlBug2
Comment 1 kahrl 2011-04-04 14:16:48 UTC
s/does trigger/does not trigger/, of course.
Comment 2 kahrl 2011-04-18 12:08:12 UTC
Probably no longer needed due to r86302.
Comment 3 Sam Reed (reedy) 2011-04-18 12:12:30 UTC
I'm CC'd to this bug and didn't even know it existed.

http://de.guttenplag.wikia.com/api.php?action=query&format=jsonfm&prop=revisions&rvprop=content&titles=Benutzer:Kahrl/YamlBug

JSON output looks WFM

Marking fixed
Comment 4 Niklas Laxström 2011-04-18 12:14:43 UTC
Is this reported to spyc?
Comment 5 kahrl 2011-04-18 12:26:21 UTC
(In reply to comment #4)
> Is this reported to spyc?

It seems this has already been fixed upstream. http://code.google.com/p/spyc/source/browse/trunk/spyc.php uses "strpos($value,"\n") !== false" in _dumpNode().

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links