C and Pure parser accept invalid UTF-8 strings, the Java parser doesn't.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Riproduci prima l’esempio Ruby, poi leggi java/src/json/ext/ByteListTranscoder.java e confronta il comportamento dei parser C, Pure e Java per UTF-8 non valido. Chiarisci quale comportamento dovrebbe corrispondere a MRI prima di modificare il parser; il lavoro è completato quando le implementazioni producono un risultato concordato e coerente per questo input.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I know, I know...if it's bad content it's bad content. But this represents a difference from MRI.
Here's the case, again a reduced version of one I got from @rkh:
# encoding: utf-8
require 'json'
x = "{\"foo\":\"\xC3\"}"
h = JSON.parse(x)
p h['foo']
p h['foo'].encoding
So basically there's a bad byte in a UTF-8 string, and the MRI version walks right by it and allows it to come through to the resulting parsed json structure.
I have a totally broken patch for this:
diff --git a/java/src/json/ext/ByteListTranscoder.java b/java/src/json/ext/ByteListTranscoder.java
index ed9e54b..a7e42ba 100644
--- a/java/src/json/ext/ByteListTranscoder.java
+++ b/java/src/json/ext/ByteListTranscoder.java
@@ -78,9 +78,10 @@ abstract class ByteListTranscoder {
return head;
}
if (head <= 0xbf) { // 0b10xxxxxx
- throw invalidUtf8(); // tail byte with no head
+ return head; //throw invalidUtf8(); // tail byte with no head
}
if (head <= 0xdf) { // 0b110xxxxx
+ if (pos + 1 > srcEnd) return head;
ensureMin(1);
int cp = ((head & 0x1f) << 6)
| nextPart();
Again, I'm not sure this is actually something that needs to be fixed, but because the MRI version of json does not blow up on this content, there's something to be addressed.
- Lingua principale
- Ruby
- Stelle
- 782
- Fork
- 383
- Merge medio
- 1g 18h
- PR unite (30g)
- 10
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ruby/json
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
Output formatting differences between jRuby 10.0.0.1 and Ruby 3.4 when converting Float to JSON. Apertajruby
-
jruby
Issue simili
-
SyncEm always forwards a dummy block, so wrapped methods lose their no-block/Enumerator behavior Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
endoflife-date/endoflife.date#11086 ·
-
internal
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Kong/developer.konghq.com#7322 ·
-
bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100