Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping an item while iterating is undefined #572

Open
SuperSonicHub1 opened this issue May 2, 2023 · 1 comment
Open

Skipping an item while iterating is undefined #572

SuperSonicHub1 opened this issue May 2, 2023 · 1 comment

Comments

@SuperSonicHub1
Copy link

The URL Standard, when parsing percent-encoded bytes while percent-decoding, makes use of an undefined byte sequence method "skip" on L430. It seems to get a variable number of items from an iterator and immediately dispose of them, like in the following Python code:

def skip(iterator: iterator, n: int):
    for i in range(n):
        next(iterator)

It would seem that the byte sequence input holds a reference to the iterator instance, as implied by the language Skip the next two bytes in <var>input</var>.

As the creation of an iterator is currently implicit in the Infra Standard, I believe explicitly defining a generic iterator data structure, implementing the "skip" method for it, and changing all "iterate" and "for each" definitions to use iterators would be the best course of action. If this were to go through, the URL Standard would then have to wait for #571 to be resolved.

An initial concern with the approach described above is the edge case of handling a skip on an empty iterator: would we throw an exception or have skipping be a no-op?

On the other hand, this one step in the URL Standard is the only place where this method is used; if "skip" were to be left undefined, it would then be on the URL Standard to revise the percent-encoding algorithm.

@annevk
Copy link
Member

annevk commented May 3, 2023

@SuperSonicHub1 thanks for filing this. Could you also file this against the URL Standard? Might be worth looking into a local fix if this is causing confusion as I'm not sure this pattern is particularly common in web standards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants