Page MenuHomePhabricator

Potentially unsafe "href" attribute value
Closed, ResolvedPublic1 Estimated Story PointsPRODUCTION ERROR

Description

Spotted in production:

  14 Fatal error: exception 'OOUI\Exception' with message 'Potentially unsafe 'href' attribute value' in /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php:316
   Stack trace:
#0 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(358): OOUI\Tag->toString()
#1 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(336): OOUI\Tag->__toString()
#2 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Element.php(274): OOUI\Tag->toString()
#3 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(358): OOUI\Element->toString()
#4 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(336): OOUI\Tag->__toString()
#5 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Element.php(274): OOUI\Tag->toString()
#6 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(358): OOUI\Element->toString()
#7 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(336): OOUI\Tag->__toString()
#8 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Element.php(274): OOUI\Tag->toString()
#9 /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php(358): OOUI\Element->toString()
#10 /srv/mediawiki/php-1.25wmf23/includes/OutputPage.php(1515): OOUI\Tag->__toString()
#11 /srv/mediawiki/php-1.25wmf23/extensions/Collection/Collection.body.php(387): OutputPage->addHTML()
#12 /srv/mediawiki/php-1.25wmf23/extensions/Collection/Collection.body.php(71): SpecialCollection->renderBookCreatorPage()
#13 /srv/mediawiki/php-1.25wmf23/includes/specialpage/SpecialPage.php(384): SpecialCollection->execute()
#14 /srv/mediawiki/php-1.25wmf23/includes/specialpage/SpecialPageFactory.php(581): SpecialPage->run()
#15 /srv/mediawiki/php-1.25wmf23/includes/MediaWiki.php(268): SpecialPageFactory::executePath()
#16 /srv/mediawiki/php-1.25wmf23/includes/MediaWiki.php(571): MediaWiki->performRequest()
#17 /srv/mediawiki/php-1.25wmf23/includes/MediaWiki.php(422): MediaWiki->main()
#18 /srv/mediawiki/php-1.25wmf23/index.php(46): MediaWiki->run()
#19 /srv/mediawiki/w/index.php(3): include()
#20 {main} in /srv/mediawiki/php-1.25wmf23/vendor/oojs/oojs-ui/php/Tag.php on line 360

Event Timeline

demon raised the priority of this task from to Medium.
demon updated the task description. (Show Details)
demon subscribed.

Change 203968 had a related patch set uploaded (by Chad):
More useful debugging information on unsafe tag attributes

https://gerrit.wikimedia.org/r/203968

Change 203968 merged by jenkins-bot:
More useful debugging information on unsafe tag attributes

https://gerrit.wikimedia.org/r/203968

Jdforrester-WMF moved this task from Backlog to Doing on the OOUI board.
Jdforrester-WMF moved this task from Doing to Reviewing on the OOUI board.
Jdforrester-WMF set Security to None.

This isn't resolved.

Just an update since there was some confusion here and on IRC: the bug isn't fixed yet. The debugging commits attached above should be going out with 1.26wmf4 and we'll be able to find a little more info for fixing the root bug.

So, did we discover what is causing this?

That's a much better error:

'Potentially unsafe 'href' attribute value. Scheme: ''; value: '/wiki/%D9%85%D9%84%D8%AD%D9%82:1930'.'

Hmm… so apparently parse_url considers that a "seriously malformed URL" and thus returns false (which turns into an empty string in the error message). We should probably explicitly check for and allow relative URLs, rather than rely on parse_url to recognize them.

matmarex raised the priority of this task from Medium to High.May 13 2015, 8:36 AM
hashar added subscribers: Jdforrester-WMF, hashar.

@Jdforrester-WMF this has been reopened. Chad simply enhanced the log message to be more useful.

Meh, I guess I'm the primary maintainer now.

Change 215052 had a related patch set uploaded (by Bartosz Dziewoński):
Avoid 'Potentially unsafe "href" attribute value' exceptions for relative URLs

https://gerrit.wikimedia.org/r/215052

Change 215052 merged by jenkins-bot:
Avoid 'Potentially unsafe "href" attribute value' exceptions for relative URLs

https://gerrit.wikimedia.org/r/215052

Reopening till this is applied to production and effectively get rid of the error messages we see.

Reopening till this is applied to production and effectively get rid of the error messages we see.

That's what the child bug is for.

I can confirm the message is gone from the logs.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM