简体   繁体   中英

Google Apps Script debugger hangs when working with a specific string

I've run into a very peculiar bug and can't quite figure out what's wrong with it.

Here's the code that reproduces this issue:

function testDoubleQuote() {
  var xmlString = '<file><text>Ehf asor nkles pov ujfemniuea zeïerasvrtrw er Beaetrgfbvcyu Nbv., jei of asverqzsda vsdrersza vd. &lt;br /&gt;&lt;br /&gt;Ba erq vazerqhg nba lake erqybfa zvay rv asehgr va erqbu: “Er zhfa veqhazf qeyrreqgf?” Rq mnbsr ojgbeq pliyt mnbver zvae htwe nbrefpuk kj bmaner er mejreplrqv mneuijerbvce qtcx xi xghte hrfd erzemnbuyrewzsdez.</text></file>';
  var xml = XmlService.parse(xmlString);
  var content = xml.getAllContent();
  var text = content[0].getValue();
  console.log(text);
}

GAS hangs on the line with getValue(); Other attempts to get the text don't seem to work as well. However, if I manually remove from the string either ï, “ or ” it seems to work. If I remove any two characters, it works again. What's going on? Is there a character limit to the string? Something else at work? The debugger just hangs.

A script I wrote to make a Javascript object from the XML object after parsing "works" in the sense that it creates the object. However, when attempting to view the text content of the object,the debugger never stops loading it. When I go through the process step by step, it hangs on getValue() or getText() or getChildText(name) when getting that specific text value. I guess it creates it because GAS largely runs asynchronously and the functions for those specific values just never return but that's for some reason ignored.

I can't seem to get any more info from GAS on what's going on. Is this caused by XmlService.parse()?

function testDoubleQuote() {
  var xmlString = '<file><text>Ehf asor nkles pov ujfemniuea zeïerasvrtrw er Beaetrgfbvcyu Nbv., jei of asverqzsda vsdrersza vd. &lt;br /&gt;&lt;br /&gt;Ba erq vazerqhg nba lake erqybfa zvay rv asehgr va erqbu: “Er zhfa veqhazf qeyrreqgf?” Rq mnbsr ojgbeq pliyt mnbver zvae htwe nbrefpuk kj bmaner er mejreplrqv mneuijerbvce qtcx xi xghte hrfd erzemnbuyrewzsdez.</text></file>';
  var xml = XmlService.parse(xmlString);
  var content = xml.getAllContent();
  //Logger.log(content.length);
  var text = content[0].getValue();
  Logger.log(text);
}

Execution log
1:52:09 PM  Notice  Execution started
1:52:10 PM  Info    Ehf asor nkles pov ujfemniuea zeïerasvrtrw er Beaetrgfbvcyu Nbv., jei of asverqzsda vsdrersza vd. <br /><br />Ba erq vazerqhg nba lake erqybfa zvay rv asehgr va erqbu: “Er zhfa veqhazf qeyrreqgf?” Rq mnbsr ojgbeq pliyt mnbver zvae htwe nbrefpuk kj bmaner er mejreplrqv mneuijerbvce qtcx xi xghte hrfd erzemnbuyrewzsdez.
1:52:10 PM  Notice  Execution completed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM