StringScanner#skip returns nil inside an invalid character in non-UTF-8 strings (was an exception in 3.1.6)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 54/100
Línea de trabajo
Start by comparing StringScanner#skip behavior in the reported strscan versions for the Shift_JIS and UTF-16LE examples, then inspect the implementation and tests for skip on non-UTF-8 strings. Decide whether returning nil is intended or should raise consistently with the prior behavior; done means the behavior is specified and covered by regression tests, including the reported encodings.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Thanks for maintaining strscan.
On Ruby master (strscan 3.1.9.dev), StringScanner#skip returns nil when the scan position is inside an invalid or misaligned character in a non-UTF-8 string. strscan 3.1.6 (Ruby 4.0.9) raises there:
require "strscan"
[["/\xFF".dup.force_encoding("Shift_JIS"), "Shift_JIS"], ["/a".encode("UTF-16LE"), "UTF-16LE"]].each do |str, name|
s = StringScanner.new(str)
s.pos = 1
p [name, (s.skip(/./) rescue $!.class)]
end
# master (strscan 3.1.9.dev): ["Shift_JIS", nil] ["UTF-16LE", nil]
# 4.0.9 (strscan 3.1.6): ["Shift_JIS", ArgumentError] ["UTF-16LE", Encoding::CompatibilityError]
The same input as UTF-8 ("/\xFF", pos 1) raises ArgumentError on both.
Is returning nil here intended? We noticed it because Rails' route-path scanner advances with pos += 1 and then relies on skip(/./) either matching or raising. With nil, its loop never advances, so ActionDispatch::Journey::Parser.parse hangs on master for paths such as "/\xFF|bc" in Shift_JIS. Such paths are rare, and Rails could guard its loop. We'd just like to know whether the new result is deliberate before we propose anything there.
Found while comparing Rails' request path on Ruby master and Ruby 4.0.9 (record, part of my research project Lowrail).
- Lenguaje dominante
- C
- Estrellas
- 88
- Forks
- 51
- Merge medio
- 5 d 2 h
- PR fusionados (30 d)
- 2
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ruby/strscan
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Caret lost its meaningAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Todos los issues de ruby/strscan
Issues similares
-
Memory leak: "Add to Playlist" (`CMD_EVENT_ADD_TO_PLAYLIST`) never frees the playlist it loadsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Signed/unsigned mix in the EOCD backward scan rejects valid archives with a 65535-byte commentAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenXiangShan/NEMU#1287 ·
Los mantenedores suelen responder en 1 día
-
area: recompiler area: runtime kind: bug preview-effort: small priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día