Page MenuHomePhabricator

mw.uri.new() produces a run-time error if port is out of range
Closed, DeclinedPublic

Description

A call like mw.uri.new( 'https://www.abc.com:80800/index.html' ) produces a run-time error because the port 80800 is out of range.

A message like the following is given:

Lua-Fehler in mw.uri.lua, Zeile 142: invalid .port

Ablaufrückverfolgung:

[C]: in der Funktion „error“
mw.uri.lua:570: in der Funktion „parse“
mw.uri.lua:142: in der Funktion „new“
Konsoleneingabe:8: ?
[C]: ?

mw.uri.new() should not produce run-time errors but should return an error code which can be analyzed by a script.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 3 2017, 5:53 AM
Anomie closed this task as Declined.Nov 3 2017, 1:33 PM
Anomie added a subscriber: Anomie.

Use pcall() or xpcall() if you need to catch errors.

RolandUnger reopened this task as Open.Nov 3 2017, 3:19 PM

Of cause we can run all Scribunto scripts within a pcall. But this is not comfortable because you will not get the cause of a run-time error.

In case of mw.uri.new() call the opportunity of run-time errors is not documented and maybe also not intended. All people think that a given uri is transformed into an uri object to validate it later with mw.uri.validate( table ). A code corrections seems necessary to me.

Anomie closed this task as Declined.Nov 3 2017, 3:19 PM