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

Anomie subscribed.

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

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.