WindowFeatures parseWindowFeatures(StringView featuresString) { // The IE rule is: all features except for channelmode and fullscreen default to YES, but // if the user specifies a feature string, all features default to NO. (There is no public // standard that applies to this method.) // // <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp> // We always allow a window to be resized, which is consistent with Firefox. WindowFeatures features; if (featuresString.isEmpty()) return features; features.menuBarVisible = false; features.statusBarVisible = false; features.toolBarVisible = false; features.locationBarVisible = false; features.scrollbarsVisible = false; processFeaturesString(featuresString, [&features](StringView key, StringView value) { setWindowFeature(features, key, value); }); return features; }
WindowFeatures::WindowFeatures(const String& features) : xSet(false) , ySet(false) , widthSet(false) , heightSet(false) , fullscreen(false) , dialog(false) { /* The IE rule is: all features except for channelmode and fullscreen default to YES, but if the user specifies a feature string, all features default to NO. (There is no public standard that applies to this method.) <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp> We always allow a window to be resized, which is consistent with Firefox. */ if (features.length() == 0) { menuBarVisible = true; statusBarVisible = true; toolBarVisible = true; locationBarVisible = true; scrollbarsVisible = true; resizable = true; return; } menuBarVisible = false; statusBarVisible = false; toolBarVisible = false; locationBarVisible = false; scrollbarsVisible = false; resizable = true; // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior. int keyBegin, keyEnd; int valueBegin, valueEnd; int i = 0; int length = features.length(); String buffer = features.lower(); while (i < length) { // skip to first non-separator, but don't skip past the end of the string while (i < length && isWindowFeaturesSeparator(buffer[i])) i++; keyBegin = i; // skip to first separator while (i < length && !isWindowFeaturesSeparator(buffer[i])) i++; keyEnd = i; ASSERT_WITH_SECURITY_IMPLICATION(i <= length); // skip to first '=', but don't skip past a ',' or the end of the string while (i < length && buffer[i] != '=') { if (buffer[i] == ',') break; i++; } ASSERT_WITH_SECURITY_IMPLICATION(i <= length); // skip to first non-separator, but don't skip past a ',' or the end of the string while (i < length && isWindowFeaturesSeparator(buffer[i])) { if (buffer[i] == ',') break; i++; } valueBegin = i; ASSERT_WITH_SECURITY_IMPLICATION(i <= length); // skip to first separator while (i < length && !isWindowFeaturesSeparator(buffer[i])) i++; valueEnd = i; ASSERT_WITH_SECURITY_IMPLICATION(i <= length); String keyString(buffer.substring(keyBegin, keyEnd - keyBegin)); String valueString(buffer.substring(valueBegin, valueEnd - valueBegin)); setWindowFeature(keyString, valueString); } }