Open Bug 1227296 Opened 9 years ago Updated 2 years ago

NS_ConvertUTF8toUTF16 and NS_ConvertUTF16toUTF8 do not preserve voidness

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

People

(Reporter: mconley, Unassigned)

Details

Attachments

(1 file)

The IsVoid flag on a string should probably be preserved when converting across encodings.

I've written a failing test case which I will attach.
Bug 1227296 - Regression test.
Attachment #8691005 - Flags: review?(nfroyd)
FWIW, when scc added the concept of Void to the string code to meet some DOM nullability requirements (that probably no longer exist with new bindings?!), he was tempted to call it "Purple" rather than "Void" to avoid people making assumptions about what it should do.  It was designed for the very limited usecase of DOM needing to support string-or-null return values.  Now that we have Nullable (dom/bindings/Nullable.h), we really shouldn't need that anymore.

I'm curious what people are using it for and whether we can remove those uses of Void on strings and then remove the concept completely.
(In reply to David Baron [:dbaron] ⌚UTC-8 from comment #2)
> FWIW, when scc added the concept of Void to the string code to meet some DOM
> nullability requirements (that probably no longer exist with new
> bindings?!)
Paris bindings very much use void ns*Strings.

Looks like that is not too well documented in all the cases, but 
https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#ByteString at least.
Yeah, the basic problem is that we left the null domstring setup as-is in webidl bindings because we didn't want to audit all the callees at the time.

That said, we could definitely switch "DOMString?" return values to Nullable<nsString> or some such, and "DOMString?" in params to "const Nullable<nsAString>" and write those two specializations.

Apart from bindings code, the main consumers of this flag in Gecko seem to be places that are in fact trying to represent "string or null" for whatever reason.
Comment on attachment 8691005 [details]
MozReview Request: Bug 1227296 - Regression test.

https://reviewboard.mozilla.org/r/26045/#review23919

Always happy to r+ tests.
Attachment #8691005 - Flags: review?(nfroyd) → review+
I'm not fully in tune with the conversation that occurred between comment 2 and comment 5... I think I'm missing some context. At any rate, is this still worth fixing?
Flags: needinfo?(bugs)
I think yes

I haven't seen anyone filing a bug to convert all our void string usage to
Nullable<ns*String>. (That would be rather massive, yet mostly mechanical change.)
Flags: needinfo?(bugs)
Component: String → XPCOM
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: