urlpurify 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -45
- package/dist/clean.d.mts +1 -0
- package/dist/clean.mjs +56 -20
- package/dist/defaults.d.mts +7 -1
- package/dist/defaults.mjs +160 -3
- package/dist/index.d.mts +79 -4
- package/dist/index.mjs +79 -4
- package/dist/node_modules/entities/dist/decode-codepoint.mjs +2 -2
- package/dist/node_modules/entities/dist/decode.mjs +262 -247
- package/dist/node_modules/entities/dist/generated/decode-data-html.mjs +8 -4
- package/dist/node_modules/entities/dist/internal/decode-data-format.mjs +116 -0
- package/dist/node_modules/trousse/dist/is.mjs +7 -1
- package/dist/node_modules/trousse/dist/locales.mjs +21 -0
- package/dist/node_modules/trousse/dist/matching.mjs +23 -13
- package/dist/node_modules/trousse/dist/urls.mjs +203 -51
- package/dist/pathTarget.mjs +2 -2
- package/dist/tracking/clickAttribution.mjs +26 -1
- package/dist/tracking/housekeeping.mjs +13 -1
- package/dist/tracking/session.d.mts +2 -0
- package/dist/tracking/session.mjs +12 -0
- package/dist/types.d.mts +7 -1
- package/dist/unwraps/a8Net.mjs +1 -1
- package/dist/unwraps/acast.mjs +1 -1
- package/dist/unwraps/accesstrade.mjs +1 -1
- package/dist/unwraps/aceml.mjs +2 -2
- package/dist/unwraps/adcell.mjs +1 -1
- package/dist/unwraps/addThis.d.mts +2 -0
- package/dist/unwraps/addThis.mjs +17 -0
- package/dist/unwraps/addToAny.d.mts +2 -0
- package/dist/unwraps/addToAny.mjs +21 -0
- package/dist/unwraps/addToAnySubscribe.d.mts +2 -0
- package/dist/unwraps/addToAnySubscribe.mjs +8 -0
- package/dist/unwraps/addToMyYahoo.d.mts +2 -0
- package/dist/unwraps/addToMyYahoo.mjs +29 -0
- package/dist/unwraps/adfly.mjs +1 -1
- package/dist/unwraps/admitad.mjs +1 -1
- package/dist/unwraps/affilae.mjs +3 -1
- package/dist/unwraps/affiliatesOne.mjs +1 -1
- package/dist/unwraps/allblog.mjs +1 -1
- package/dist/unwraps/amazonAffiliate.mjs +5 -4
- package/dist/unwraps/amazonSes.mjs +2 -2
- package/dist/unwraps/ampCache.mjs +4 -3
- package/dist/unwraps/ampCacheImage.mjs +1 -1
- package/dist/unwraps/anchor.mjs +1 -1
- package/dist/unwraps/anonymouse.mjs +1 -1
- package/dist/unwraps/antennaPod.d.mts +2 -0
- package/dist/unwraps/antennaPod.mjs +15 -0
- package/dist/unwraps/anytimePlayer.d.mts +2 -0
- package/dist/unwraps/anytimePlayer.mjs +17 -0
- package/dist/unwraps/apptrkr.mjs +3 -2
- package/dist/unwraps/archiveToday.mjs +2 -2
- package/dist/unwraps/arquivo.mjs +1 -1
- package/dist/unwraps/arttrack.mjs +1 -1
- package/dist/unwraps/augure.mjs +3 -3
- package/dist/unwraps/awesound.mjs +1 -1
- package/dist/unwraps/axigen.mjs +2 -1
- package/dist/unwraps/bacLacWebArchive.mjs +1 -1
- package/dist/unwraps/bananatag.mjs +1 -1
- package/dist/unwraps/big5Gate.mjs +1 -1
- package/dist/unwraps/bing.mjs +7 -7
- package/dist/unwraps/bingAds.mjs +4 -4
- package/dist/unwraps/bitrix.mjs +2 -1
- package/dist/unwraps/bitrixBanner.mjs +2 -1
- package/dist/unwraps/blinkList.d.mts +2 -0
- package/dist/unwraps/blinkList.mjs +8 -0
- package/dist/unwraps/bloggerBlogThis.d.mts +2 -0
- package/dist/unwraps/bloggerBlogThis.mjs +16 -0
- package/dist/unwraps/bloggerImageProxy.mjs +2 -1
- package/dist/unwraps/bloglines.d.mts +2 -0
- package/dist/unwraps/bloglines.mjs +21 -0
- package/dist/unwraps/bridgyFed.mjs +1 -1
- package/dist/unwraps/buffer.d.mts +2 -0
- package/dist/unwraps/buffer.mjs +23 -0
- package/dist/unwraps/buybox.mjs +1 -1
- package/dist/unwraps/buzzstream.mjs +1 -1
- package/dist/unwraps/cake.mjs +2 -2
- package/dist/unwraps/checkPointHarmony.mjs +2 -2
- package/dist/unwraps/cjNetwork.mjs +3 -3
- package/dist/unwraps/claritas.mjs +2 -2
- package/dist/unwraps/cleverbridge.mjs +3 -3
- package/dist/unwraps/cloudhq.mjs +1 -1
- package/dist/unwraps/cloze.mjs +1 -1
- package/dist/unwraps/cohst.mjs +1 -1
- package/dist/unwraps/contactMonkey.mjs +3 -2
- package/dist/unwraps/convertiser.mjs +1 -1
- package/dist/unwraps/cse360.mjs +1 -1
- package/dist/unwraps/dasBlog.mjs +1 -1
- package/dist/unwraps/datalifeEngine.mjs +5 -4
- package/dist/unwraps/delicious.d.mts +2 -0
- package/dist/unwraps/delicious.mjs +15 -0
- package/dist/unwraps/deployer.mjs +3 -3
- package/dist/unwraps/derefMail.mjs +4 -3
- package/dist/unwraps/deviantartOutgoing.mjs +1 -1
- package/dist/unwraps/diasporaShare.d.mts +2 -0
- package/dist/unwraps/diasporaShare.mjs +16 -0
- package/dist/unwraps/diggSubmit.d.mts +2 -0
- package/dist/unwraps/diggSubmit.mjs +11 -0
- package/dist/unwraps/digikala.mjs +3 -3
- package/dist/unwraps/diigoPost.d.mts +2 -0
- package/dist/unwraps/diigoPost.mjs +12 -0
- package/dist/unwraps/disqus.mjs +2 -1
- package/dist/unwraps/drupalOembed.mjs +3 -5
- package/dist/unwraps/dstats.mjs +2 -2
- package/dist/unwraps/eClick.mjs +1 -1
- package/dist/unwraps/easyMarketing.mjs +3 -3
- package/dist/unwraps/ebayRover.mjs +1 -1
- package/dist/unwraps/ebuzzing.mjs +1 -1
- package/dist/unwraps/edgepilot.mjs +1 -1
- package/dist/unwraps/effiliation.mjs +1 -1
- package/dist/unwraps/elasticEmail.mjs +3 -2
- package/dist/unwraps/epn.mjs +1 -1
- package/dist/unwraps/eulerian.mjs +1 -1
- package/dist/unwraps/evernoteClip.d.mts +2 -0
- package/dist/unwraps/evernoteClip.mjs +8 -0
- package/dist/unwraps/exciteTranslate.mjs +1 -1
- package/dist/unwraps/facebook.mjs +1 -1
- package/dist/unwraps/facebookShare.d.mts +2 -0
- package/dist/unwraps/facebookShare.mjs +25 -0
- package/dist/unwraps/feed2js.d.mts +2 -0
- package/dist/unwraps/feed2js.mjs +16 -0
- package/dist/unwraps/feedStatistics.mjs +2 -2
- package/dist/unwraps/feedValidator.d.mts +2 -0
- package/dist/unwraps/feedValidator.mjs +12 -0
- package/dist/unwraps/feedblitz.mjs +4 -5
- package/dist/unwraps/feedland.d.mts +2 -0
- package/dist/unwraps/feedland.mjs +12 -0
- package/dist/unwraps/feedly.d.mts +2 -0
- package/dist/unwraps/feedly.mjs +28 -0
- package/dist/unwraps/feedsportal.mjs +1 -1
- package/dist/unwraps/finalsite.mjs +2 -2
- package/dist/unwraps/firebaseDynamicLinks.mjs +3 -2
- package/dist/unwraps/firstory.mjs +3 -3
- package/dist/unwraps/fiveByFive.mjs +2 -2
- package/dist/unwraps/flattrSubmit.d.mts +2 -0
- package/dist/unwraps/flattrSubmit.mjs +8 -0
- package/dist/unwraps/flipboardShare.d.mts +2 -0
- package/dist/unwraps/flipboardShare.mjs +15 -0
- package/dist/unwraps/fortimail.mjs +3 -2
- package/dist/unwraps/friendFeed.d.mts +2 -0
- package/dist/unwraps/friendFeed.mjs +18 -0
- package/dist/unwraps/gabCompose.d.mts +2 -0
- package/dist/unwraps/gabCompose.mjs +8 -0
- package/dist/unwraps/genericCarrier.d.mts +2 -0
- package/dist/unwraps/genericCarrier.mjs +31 -0
- package/dist/unwraps/gfnLinkProxy.mjs +3 -3
- package/dist/unwraps/godcaster.mjs +2 -2
- package/dist/unwraps/googleAmpViewer.mjs +2 -2
- package/dist/unwraps/googleBookmarks.d.mts +2 -0
- package/dist/unwraps/googleBookmarks.mjs +8 -0
- package/dist/unwraps/googleBuzz.d.mts +2 -0
- package/dist/unwraps/googleBuzz.mjs +8 -0
- package/dist/unwraps/googleNewsModern.mjs +2 -3
- package/dist/unwraps/googlePlusShare.d.mts +2 -0
- package/dist/unwraps/googlePlusShare.mjs +11 -0
- package/dist/unwraps/googlePodcasts.d.mts +2 -0
- package/dist/unwraps/googlePodcasts.mjs +27 -0
- package/dist/unwraps/googleReader.d.mts +2 -0
- package/dist/unwraps/googleReader.mjs +20 -0
- package/dist/unwraps/googleTranslate.mjs +13 -13
- package/dist/unwraps/govdelivery.mjs +3 -2
- package/dist/unwraps/hackerNewsSubmit.d.mts +2 -0
- package/dist/unwraps/hackerNewsSubmit.mjs +8 -0
- package/dist/unwraps/hasoffers.mjs +3 -2
- package/dist/unwraps/hatenaBookmark.d.mts +2 -0
- package/dist/unwraps/hatenaBookmark.mjs +22 -0
- package/dist/unwraps/hirkereso.mjs +1 -1
- package/dist/unwraps/horde.mjs +1 -1
- package/dist/unwraps/hubspotSidekick.mjs +1 -1
- package/dist/unwraps/impact.mjs +2 -2
- package/dist/unwraps/indexHu.mjs +2 -1
- package/dist/unwraps/inoreader.d.mts +2 -0
- package/dist/unwraps/inoreader.mjs +22 -0
- package/dist/unwraps/instapaperSave.d.mts +2 -0
- package/dist/unwraps/instapaperSave.mjs +11 -0
- package/dist/unwraps/invisionNoExternalLinks.mjs +1 -1
- package/dist/unwraps/involveAsia.mjs +1 -1
- package/dist/unwraps/jive.mjs +2 -1
- package/dist/unwraps/klook.mjs +2 -1
- package/dist/unwraps/lazada.mjs +1 -1
- package/dist/unwraps/letscast.mjs +1 -1
- package/dist/unwraps/lineShare.d.mts +2 -0
- package/dist/unwraps/lineShare.mjs +25 -0
- package/dist/unwraps/linkA.mjs +1 -1
- package/dist/unwraps/linkedin.mjs +1 -1
- package/dist/unwraps/linkedinShare.d.mts +2 -0
- package/dist/unwraps/linkedinShare.mjs +15 -0
- package/dist/unwraps/linksynergy.mjs +2 -2
- package/dist/unwraps/linktrust.mjs +3 -3
- package/dist/unwraps/linkwise.mjs +1 -1
- package/dist/unwraps/livedoorReader.d.mts +2 -0
- package/dist/unwraps/livedoorReader.mjs +12 -0
- package/dist/unwraps/locWebArchive.mjs +1 -1
- package/dist/unwraps/locaweb.mjs +3 -1
- package/dist/unwraps/logicboard.mjs +1 -1
- package/dist/unwraps/magellan.mjs +1 -1
- package/dist/unwraps/mail2easy.mjs +1 -1
- package/dist/unwraps/mailchimp.mjs +1 -1
- package/dist/unwraps/mailinblack.mjs +6 -4
- package/dist/unwraps/mailstat.mjs +1 -1
- package/dist/unwraps/mailtrack.mjs +1 -1
- package/dist/unwraps/mandrill.mjs +3 -3
- package/dist/unwraps/medium.mjs +5 -5
- package/dist/unwraps/meneameSubmit.d.mts +2 -0
- package/dist/unwraps/meneameSubmit.mjs +11 -0
- package/dist/unwraps/meweShare.d.mts +2 -0
- package/dist/unwraps/meweShare.mjs +8 -0
- package/dist/unwraps/mimecast.mjs +1 -1
- package/dist/unwraps/ministryCloud.mjs +1 -1
- package/dist/unwraps/mintDownloads.mjs +1 -1
- package/dist/unwraps/mintFeeder.mjs +3 -2
- package/dist/unwraps/mohtwize.mjs +6 -4
- package/dist/unwraps/morss.d.mts +2 -0
- package/dist/unwraps/morss.mjs +13 -0
- package/dist/unwraps/mozillaOutgoing.mjs +3 -3
- package/dist/unwraps/myAolFeeds.d.mts +2 -0
- package/dist/unwraps/myAolFeeds.mjs +8 -0
- package/dist/unwraps/narrativ.mjs +1 -1
- package/dist/unwraps/natlibNz.mjs +1 -1
- package/dist/unwraps/ncls.mjs +2 -1
- package/dist/unwraps/ndlWarp.mjs +2 -2
- package/dist/unwraps/netaffiliation.mjs +1 -1
- package/dist/unwraps/netvibes.d.mts +2 -0
- package/dist/unwraps/netvibes.mjs +7 -0
- package/dist/unwraps/newsGator.d.mts +2 -0
- package/dist/unwraps/newsGator.mjs +17 -0
- package/dist/unwraps/newswire.mjs +3 -3
- package/dist/unwraps/nicoMs.mjs +1 -1
- package/dist/unwraps/nimble.mjs +1 -1
- package/dist/unwraps/nlaWebarchive.mjs +3 -3
- package/dist/unwraps/okRu.mjs +3 -2
- package/dist/unwraps/okShare.d.mts +2 -0
- package/dist/unwraps/okShare.mjs +23 -0
- package/dist/unwraps/op3.mjs +1 -1
- package/dist/unwraps/outlookSafelinks.mjs +1 -1
- package/dist/unwraps/pageflakes.d.mts +2 -0
- package/dist/unwraps/pageflakes.mjs +8 -0
- package/dist/unwraps/pagefreezer.mjs +2 -2
- package/dist/unwraps/partnerAds.mjs +2 -2
- package/dist/unwraps/pbs.mjs +1 -1
- package/dist/unwraps/pinterestPin.d.mts +2 -0
- package/dist/unwraps/pinterestPin.mjs +85 -0
- package/dist/unwraps/pipedrive.mjs +1 -1
- package/dist/unwraps/playerFm.d.mts +2 -0
- package/dist/unwraps/playerFm.mjs +16 -0
- package/dist/unwraps/pocketSave.d.mts +2 -0
- package/dist/unwraps/pocketSave.mjs +15 -0
- package/dist/unwraps/podcastAddict.d.mts +2 -0
- package/dist/unwraps/podcastAddict.mjs +14 -0
- package/dist/unwraps/podcastReady.d.mts +2 -0
- package/dist/unwraps/podcastReady.mjs +8 -0
- package/dist/unwraps/podcorn.mjs +1 -1
- package/dist/unwraps/podkite.mjs +1 -1
- package/dist/unwraps/podscribe.mjs +1 -1
- package/dist/unwraps/podsights.mjs +1 -1
- package/dist/unwraps/podup.mjs +2 -3
- package/dist/unwraps/postAffiliatePro.mjs +1 -1
- package/dist/unwraps/postmark.mjs +1 -1
- package/dist/unwraps/prNewswire.mjs +2 -2
- package/dist/unwraps/prezly.mjs +1 -1
- package/dist/unwraps/proofpointV2.mjs +1 -1
- package/dist/unwraps/proofpointV3.mjs +3 -3
- package/dist/unwraps/prweb.mjs +2 -2
- package/dist/unwraps/prxPlayer.d.mts +2 -0
- package/dist/unwraps/prxPlayer.mjs +16 -0
- package/dist/unwraps/qqMailReader.d.mts +2 -0
- package/dist/unwraps/qqMailReader.mjs +8 -0
- package/dist/unwraps/qualityClick.mjs +4 -3
- package/dist/unwraps/qzoneShare.d.mts +2 -0
- package/dist/unwraps/qzoneShare.mjs +8 -0
- package/dist/unwraps/rakutenAffiliate.mjs +3 -3
- package/dist/unwraps/redditOut.mjs +1 -1
- package/dist/unwraps/redditSubmit.d.mts +2 -0
- package/dist/unwraps/redditSubmit.mjs +19 -0
- package/dist/unwraps/researchgate.mjs +1 -1
- package/dist/unwraps/reviveAdserver.mjs +4 -4
- package/dist/unwraps/rssBoardValidator.d.mts +2 -0
- package/dist/unwraps/rssBoardValidator.mjs +8 -0
- package/dist/unwraps/salesdoubler.mjs +1 -1
- package/dist/unwraps/saleshandy.mjs +1 -1
- package/dist/unwraps/segmentfault.mjs +2 -2
- package/dist/unwraps/serendipity.mjs +4 -4
- package/dist/unwraps/shareaholic.d.mts +2 -0
- package/dist/unwraps/shareaholic.mjs +12 -0
- package/dist/unwraps/slashdotBookmark.d.mts +2 -0
- package/dist/unwraps/slashdotBookmark.mjs +11 -0
- package/dist/unwraps/smartredirect.mjs +1 -1
- package/dist/unwraps/sophos.mjs +2 -2
- package/dist/unwraps/soundOn.mjs +1 -1
- package/dist/unwraps/stay22.mjs +1 -1
- package/dist/unwraps/streamsend.mjs +1 -1
- package/dist/unwraps/stumbleuponSubmit.d.mts +2 -0
- package/dist/unwraps/stumbleuponSubmit.mjs +14 -0
- package/dist/unwraps/subscribeByEmail.d.mts +2 -0
- package/dist/unwraps/subscribeByEmail.mjs +10 -0
- package/dist/unwraps/subscribeOnAndroid.d.mts +2 -0
- package/dist/unwraps/subscribeOnAndroid.mjs +10 -0
- package/dist/unwraps/subscribeRu.mjs +1 -1
- package/dist/unwraps/substack.mjs +2 -3
- package/dist/unwraps/surly.mjs +1 -1
- package/dist/unwraps/swap.mjs +1 -1
- package/dist/unwraps/symantecClicktime.mjs +1 -1
- package/dist/unwraps/symplicity.mjs +1 -1
- package/dist/unwraps/teacup.mjs +3 -2
- package/dist/unwraps/technoratiFaves.d.mts +2 -0
- package/dist/unwraps/technoratiFaves.mjs +10 -0
- package/dist/unwraps/telegramShare.d.mts +2 -0
- package/dist/unwraps/telegramShare.mjs +18 -0
- package/dist/unwraps/theRegister.mjs +1 -1
- package/dist/unwraps/threadsIntent.d.mts +2 -0
- package/dist/unwraps/threadsIntent.mjs +16 -0
- package/dist/unwraps/toucharcade.mjs +1 -1
- package/dist/unwraps/tracdelight.mjs +3 -2
- package/dist/unwraps/trxHub.mjs +1 -1
- package/dist/unwraps/tumblrShare.d.mts +2 -0
- package/dist/unwraps/tumblrShare.mjs +13 -0
- package/dist/unwraps/twitterIntent.d.mts +2 -0
- package/dist/unwraps/twitterIntent.mjs +17 -0
- package/dist/unwraps/twoCheckout.mjs +4 -3
- package/dist/unwraps/ukWebArchive.mjs +1 -1
- package/dist/unwraps/ukgwa.mjs +1 -1
- package/dist/unwraps/unescoWebArchive.mjs +1 -1
- package/dist/unwraps/unisender.mjs +4 -4
- package/dist/unwraps/upAudio.mjs +1 -1
- package/dist/unwraps/vadeSecure.mjs +1 -1
- package/dist/unwraps/valuePress.mjs +2 -2
- package/dist/unwraps/vanilla.mjs +1 -1
- package/dist/unwraps/vbulletin.mjs +1 -1
- package/dist/unwraps/vefsafn.mjs +2 -2
- package/dist/unwraps/vgWort.mjs +1 -1
- package/dist/unwraps/vkShare.d.mts +2 -0
- package/dist/unwraps/vkShare.mjs +16 -0
- package/dist/unwraps/vocus.mjs +1 -1
- package/dist/unwraps/voxnest.mjs +1 -1
- package/dist/unwraps/w3cFeedValidator.d.mts +2 -0
- package/dist/unwraps/w3cFeedValidator.mjs +8 -0
- package/dist/unwraps/webArchive.mjs +5 -5
- package/dist/unwraps/webcitation.mjs +1 -1
- package/dist/unwraps/webharvest.mjs +1 -1
- package/dist/unwraps/weiboShare.d.mts +2 -0
- package/dist/unwraps/weiboShare.mjs +8 -0
- package/dist/unwraps/weserv.mjs +2 -2
- package/dist/unwraps/wikizero.mjs +2 -2
- package/dist/unwraps/windowsLive.d.mts +2 -0
- package/dist/unwraps/windowsLive.mjs +13 -0
- package/dist/unwraps/windowsLiveFavorites.d.mts +2 -0
- package/dist/unwraps/windowsLiveFavorites.mjs +8 -0
- package/dist/unwraps/worldNomads.mjs +2 -1
- package/dist/unwraps/wpPoczta.mjs +2 -2
- package/dist/unwraps/wykop.d.mts +2 -0
- package/dist/unwraps/wykop.mjs +11 -0
- package/dist/unwraps/xengentr.mjs +4 -3
- package/dist/unwraps/xianguo.d.mts +2 -0
- package/dist/unwraps/xianguo.mjs +8 -0
- package/dist/unwraps/xiaoyuzhou.mjs +1 -1
- package/dist/unwraps/ximalaya.mjs +3 -3
- package/dist/unwraps/xingShare.d.mts +2 -0
- package/dist/unwraps/xingShare.mjs +16 -0
- package/dist/unwraps/yahooBookmarks.d.mts +2 -0
- package/dist/unwraps/yahooBookmarks.mjs +38 -0
- package/dist/unwraps/yahooJapan.mjs +2 -3
- package/dist/unwraps/yahooJapanAmpViewer.mjs +2 -2
- package/dist/unwraps/yahooMailImage.mjs +2 -1
- package/dist/unwraps/yahooSearch.mjs +2 -2
- package/dist/unwraps/yamm.mjs +2 -1
- package/dist/unwraps/yandexMail.mjs +4 -3
- package/dist/unwraps/yandexTranslate.mjs +1 -1
- package/dist/unwraps/yandexTurbo.mjs +4 -4
- package/dist/unwraps/yesware.mjs +2 -2
- package/dist/unwraps/yourMembership.mjs +3 -2
- package/dist/unwraps/zencastr.mjs +1 -1
- package/dist/unwraps/zix.mjs +1 -1
- package/dist/unwraps/zscalerIsolation.mjs +1 -1
- package/dist/utils.mjs +9 -42
- package/package.json +4 -4
- package/dist/node_modules/entities/dist/internal/bin-trie-flags.mjs +0 -50
- package/dist/node_modules/entities/dist/internal/decode-shared.mjs +0 -143
|
@@ -1,58 +1,27 @@
|
|
|
1
1
|
import { codePointToString } from "./decode-codepoint.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { htmlDecodeData } from "./generated/decode-data-html.mjs";
|
|
3
|
+
import { BUCKET_HASH_1, BUCKET_HASH_2, CHAR_REMAP, initDecodeData, pairIndex } from "./internal/decode-data-format.mjs";
|
|
4
4
|
// node_modules/entities/dist/decode.js
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
|
|
14
|
-
CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
|
|
15
|
-
})(CharCodes || (CharCodes = {}));
|
|
5
|
+
const CHAR_AMP = 38;
|
|
6
|
+
const CHAR_NUM = 35;
|
|
7
|
+
const CHAR_SEMI = 59;
|
|
8
|
+
const CHAR_EQUALS = 61;
|
|
9
|
+
const CHAR_ZERO = 48;
|
|
10
|
+
const CHAR_LOWER_A = 97;
|
|
11
|
+
const CHAR_LOWER_X = 120;
|
|
12
|
+
const CHAR_UPPER_A = 65;
|
|
16
13
|
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
17
14
|
const TO_LOWER_BIT = 32;
|
|
18
|
-
const CONSUMED_SHIFT = 21;
|
|
19
|
-
const CODE_POINT_MASK = 2097151;
|
|
20
|
-
/**
|
|
21
|
-
* Reserved consumed field for counts of at least 2047 characters after `&`.
|
|
22
|
-
* The true count is in `longNumericConsumed`.
|
|
23
|
-
*/
|
|
24
|
-
const CONSUMED_OVERFLOW = 2047;
|
|
25
|
-
/**
|
|
26
|
-
* Side channel for numeric entities of at least 2048 characters including
|
|
27
|
-
* `&`. Set by `parseNumericEntity` when its consumed count reaches the
|
|
28
|
-
* reserved value `CONSUMED_OVERFLOW`; callers read the true count from here.
|
|
29
|
-
* A module-level slot avoids a tuple allocation on the hot path.
|
|
30
|
-
*/
|
|
31
|
-
let longNumericConsumed = 0;
|
|
32
|
-
/**
|
|
33
|
-
* Extract the consumed count from a `parseNumericEntity` packed result,
|
|
34
|
-
* recovering the true length from `longNumericConsumed` when the packed
|
|
35
|
-
* field contains the sentinel. Read it before the next `parseNumericEntity`
|
|
36
|
-
* call, which may overwrite the side channel. This helper owns that protocol.
|
|
37
|
-
* @param packed Packed result of `parseNumericEntity`.
|
|
38
|
-
*/
|
|
39
|
-
function unpackConsumed(packed) {
|
|
40
|
-
const consumed = packed >>> CONSUMED_SHIFT;
|
|
41
|
-
return consumed === CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
|
|
42
|
-
}
|
|
43
15
|
/**
|
|
44
16
|
* Unsigned subtraction trick: (code - lo) >>> 0 wraps negatives to large
|
|
45
17
|
* values, so a single `<=` covers the entire [lo..hi] range check.
|
|
46
18
|
* @param code Code point to check.
|
|
47
19
|
*/
|
|
48
20
|
function isNumber(code) {
|
|
49
|
-
return code -
|
|
21
|
+
return code - CHAR_ZERO >>> 0 <= 9;
|
|
50
22
|
}
|
|
51
|
-
function
|
|
52
|
-
return (code | TO_LOWER_BIT) -
|
|
53
|
-
}
|
|
54
|
-
function isAlpha(code) {
|
|
55
|
-
return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
|
|
23
|
+
function isAlphaNumeric(code) {
|
|
24
|
+
return isNumber(code) || (code | TO_LOWER_BIT) - CHAR_LOWER_A >>> 0 <= 25;
|
|
56
25
|
}
|
|
57
26
|
/**
|
|
58
27
|
* Checks if the given character is a valid end character for an entity in an attribute.
|
|
@@ -62,16 +31,8 @@ function isAlpha(code) {
|
|
|
62
31
|
* @param code Code point to check.
|
|
63
32
|
*/
|
|
64
33
|
function isEntityInAttributeInvalidEnd(code) {
|
|
65
|
-
return code ===
|
|
34
|
+
return code === CHAR_EQUALS || isAlphaNumeric(code);
|
|
66
35
|
}
|
|
67
|
-
var EntityDecoderState;
|
|
68
|
-
(function(EntityDecoderState) {
|
|
69
|
-
EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
|
|
70
|
-
EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
|
|
71
|
-
EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
|
|
72
|
-
EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
|
|
73
|
-
EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
|
|
74
|
-
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
75
36
|
/**
|
|
76
37
|
* Decoding mode for named entities.
|
|
77
38
|
*/
|
|
@@ -84,231 +45,285 @@ var DecodingMode;
|
|
|
84
45
|
/** Entities in attributes have limitations on ending characters. */
|
|
85
46
|
DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
|
|
86
47
|
})(DecodingMode || (DecodingMode = {}));
|
|
48
|
+
/** Decode data for HTML entities. */
|
|
49
|
+
const htmlDecode = /* #__PURE__ */ initDecodeData(htmlDecodeData);
|
|
50
|
+
const htmlKeys = /* #__PURE__ */ (() => htmlDecode.keys)();
|
|
51
|
+
const htmlBuckets = /* #__PURE__ */ (() => htmlDecode.buckets)();
|
|
52
|
+
const htmlSlotMidOff = /* #__PURE__ */ (() => htmlDecode.slotMidOff)();
|
|
53
|
+
const htmlLengthBits = /* #__PURE__ */ (() => htmlDecode.lengthBits)();
|
|
54
|
+
const htmlMiddles = /* #__PURE__ */ (() => htmlDecode.middles)();
|
|
55
|
+
/** Hoisted for the specialized HTML cores; see `emitHtmlValue`. */
|
|
56
|
+
const htmlSlotValue = /* #__PURE__ */ (() => htmlDecode.slotValue)();
|
|
57
|
+
const htmlValues = /* #__PURE__ */ (() => htmlDecode.values)();
|
|
87
58
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
59
|
+
* The replacement string for a packed `slotValue` entry. Most values need
|
|
60
|
+
* just one UTF-16 code unit.
|
|
61
|
+
* @param packed Replacement offset, legacy flag, and length from `htmlSlotValue`.
|
|
62
|
+
*/
|
|
63
|
+
function emitHtmlValue(packed) {
|
|
64
|
+
const off = packed >> 2;
|
|
65
|
+
return (packed & 1) === 0 ? htmlValues.charAt(off) : htmlValues.slice(off, off + (packed & 1) + 1);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Find the slot matching `text[start..start+length)`, or -1. A match proves
|
|
69
|
+
* every character of the span (exact key + middle comparison).
|
|
70
|
+
* @param text Input text.
|
|
71
|
+
* @param start Start of the span in `text`.
|
|
72
|
+
* @param length Length of the span.
|
|
98
73
|
*/
|
|
99
|
-
function
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
74
|
+
function findSlotHtml(text, start, length) {
|
|
75
|
+
const c0 = text.charCodeAt(start);
|
|
76
|
+
const c1 = text.charCodeAt(start + 1);
|
|
77
|
+
const c2 = text.charCodeAt(start + length - 2);
|
|
78
|
+
const c3 = text.charCodeAt(start + length - 1);
|
|
79
|
+
if ((c0 | c1 | c2 | c3) > 127) return -1;
|
|
80
|
+
const key = c0 << 25 | c1 << 18 | c2 << 11 | CHAR_REMAP[c3] << 5 | length;
|
|
81
|
+
let slot = 2 * ((Math.imul(key, BUCKET_HASH_1) >>> 16) * htmlBuckets >>> 16);
|
|
82
|
+
for (let attempt = 0;; attempt++) {
|
|
83
|
+
if (htmlKeys[slot] === key && (length <= 4 || isMidMatchHtml(slot, text, start, length))) return slot;
|
|
84
|
+
if (htmlKeys[slot + 1] === key && (length <= 4 || isMidMatchHtml(slot + 1, text, start, length))) return slot + 1;
|
|
85
|
+
if (attempt === 1) return -1;
|
|
86
|
+
slot = 2 * ((Math.imul(key, BUCKET_HASH_2) >>> 16) * htmlBuckets >>> 16);
|
|
108
87
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Compare the middle characters (positions 2..length-3) of the candidate at
|
|
91
|
+
* `slot` against the input. The key already proves the outer characters and
|
|
92
|
+
* the length. Names of length at most four are accepted by the caller.
|
|
93
|
+
* @param slot Slot of the candidate.
|
|
94
|
+
* @param text Input text.
|
|
95
|
+
* @param start Start of the span in `text`.
|
|
96
|
+
* @param length Length of the span.
|
|
97
|
+
*/
|
|
98
|
+
function isMidMatchHtml(slot, text, start, length) {
|
|
99
|
+
let wordIndex = htmlSlotMidOff[slot];
|
|
100
|
+
let index = start + 2;
|
|
101
|
+
const end = start + length - 2;
|
|
102
|
+
while (index + 1 < end) {
|
|
103
|
+
if ((text.charCodeAt(index) | text.charCodeAt(index + 1) << 16) !== htmlMiddles[wordIndex++]) return false;
|
|
104
|
+
index += 2;
|
|
116
105
|
}
|
|
117
|
-
return
|
|
106
|
+
return index === end || text.charCodeAt(index) === (htmlMiddles[wordIndex] & 65535);
|
|
118
107
|
}
|
|
119
108
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
109
|
+
* `parseNumericEntity` packs its two results into one integer:
|
|
110
|
+
* `(consumed << CONSUMED_SHIFT) | codePoint`. The code point occupies the low
|
|
111
|
+
* 21 bits (max 0x110000, clamped before packing); `consumed` takes the upper
|
|
112
|
+
* 11 bits and is read back with `>>> CONSUMED_SHIFT`, so the sign bit set by a
|
|
113
|
+
* large `consumed` is harmless. The maximum consumed field is reserved for
|
|
114
|
+
* long references, whose full length is stored in `longNumericConsumed`.
|
|
115
|
+
* A zero return means "no numeric entity".
|
|
125
116
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
const NUMERIC_CONSUMED_SHIFT = 21;
|
|
118
|
+
const NUMERIC_CODE_POINT_MASK = 2097151;
|
|
119
|
+
const NUMERIC_CONSUMED_OVERFLOW = 2047;
|
|
120
|
+
/** Full length, including `&`, when the packed consumed field overflows. */
|
|
121
|
+
let longNumericConsumed = 0;
|
|
122
|
+
/**
|
|
123
|
+
* Recover the consumed count before the next numeric parse can overwrite
|
|
124
|
+
* `longNumericConsumed`. This avoids allocating a tuple for each reference.
|
|
125
|
+
* @param packed Packed result of `parseNumericEntity`.
|
|
126
|
+
*/
|
|
127
|
+
function unpackConsumed(packed) {
|
|
128
|
+
const consumed = packed >>> NUMERIC_CONSUMED_SHIFT;
|
|
129
|
+
return consumed === NUMERIC_CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
|
|
130
130
|
}
|
|
131
|
+
/** ASCII digit values; 0xff marks characters outside the hexadecimal range. */
|
|
132
|
+
const numericDigits = /* #__PURE__ */ (() => {
|
|
133
|
+
const digits = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
134
|
+
for (let digit = 0; digit < 10; digit++) digits[CHAR_ZERO + digit] = digit;
|
|
135
|
+
for (let digit = 0; digit < 6; digit++) {
|
|
136
|
+
digits[CHAR_UPPER_A + digit] = digit + 10;
|
|
137
|
+
digits[CHAR_LOWER_A + digit] = digit + 10;
|
|
138
|
+
}
|
|
139
|
+
return digits;
|
|
140
|
+
})();
|
|
131
141
|
/**
|
|
132
|
-
* Parse a numeric entity
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* the packing
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* `EntityDecoder#stateNumericDecimal` / `#stateNumericHex`. Digit parsing
|
|
141
|
-
* matches those methods; only this packed result needs a value clamp.
|
|
142
|
-
* @param input The input string.
|
|
143
|
-
* @param numberStart Index of the `#` character.
|
|
144
|
-
* @param inputLength Cached `input.length`.
|
|
142
|
+
* Parse a numeric entity starting right after the `#`. In legacy mode the
|
|
143
|
+
* terminating semicolon is optional. Returns the number of characters
|
|
144
|
+
* consumed (counting the `&` and `#`) packed with the code point (see
|
|
145
|
+
* the packing constants above), or 0 if there is no valid numeric entity at this
|
|
146
|
+
* position.
|
|
147
|
+
* @param input Input string.
|
|
148
|
+
* @param offset Index right after the `#`.
|
|
149
|
+
* @param isStrict Whether a terminating semicolon is required.
|
|
145
150
|
*/
|
|
146
|
-
function parseNumericEntity(input,
|
|
147
|
-
|
|
148
|
-
let
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
function parseNumericEntity(input, offset, isStrict) {
|
|
152
|
+
const inputLength = input.length;
|
|
153
|
+
let index = offset;
|
|
154
|
+
let codePoint = 0;
|
|
155
|
+
let digitsStart;
|
|
156
|
+
if ((input.charCodeAt(index) | TO_LOWER_BIT) === CHAR_LOWER_X) {
|
|
157
|
+
index += 1;
|
|
158
|
+
digitsStart = index;
|
|
159
|
+
while (index < inputLength) {
|
|
160
|
+
const char = input.charCodeAt(index);
|
|
161
|
+
if (char >= 128) break;
|
|
162
|
+
const digit = numericDigits[char];
|
|
163
|
+
if (digit <= 15) {
|
|
164
|
+
codePoint = codePoint * 16 + digit;
|
|
165
|
+
index++;
|
|
166
|
+
} else break;
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
digitsStart = index;
|
|
170
|
+
while (index < inputLength) {
|
|
171
|
+
const char = input.charCodeAt(index);
|
|
172
|
+
if (char >= 128) break;
|
|
173
|
+
const digit = numericDigits[char];
|
|
174
|
+
if (digit <= 9) {
|
|
175
|
+
codePoint = codePoint * 10 + digit;
|
|
176
|
+
index++;
|
|
177
|
+
} else break;
|
|
159
178
|
}
|
|
160
|
-
} else while (offset < inputLength) {
|
|
161
|
-
const digit = input.charCodeAt(offset) - CharCodes.ZERO;
|
|
162
|
-
if (digit >>> 0 > 9) break;
|
|
163
|
-
cp = cp * 10 + digit;
|
|
164
|
-
offset += 1;
|
|
165
179
|
}
|
|
166
|
-
if (
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (
|
|
180
|
+
if (index === digitsStart) return 0;
|
|
181
|
+
if (codePoint > 1114111) codePoint = 1114112;
|
|
182
|
+
let consumed = index - offset + 2;
|
|
183
|
+
if (index < inputLength && input.charCodeAt(index) === CHAR_SEMI) consumed += 1;
|
|
184
|
+
else if (isStrict) return 0;
|
|
185
|
+
if (consumed >= NUMERIC_CONSUMED_OVERFLOW) {
|
|
171
186
|
longNumericConsumed = consumed;
|
|
172
|
-
consumed =
|
|
187
|
+
consumed = NUMERIC_CONSUMED_OVERFLOW;
|
|
173
188
|
}
|
|
174
|
-
return consumed <<
|
|
189
|
+
return consumed << NUMERIC_CONSUMED_SHIFT | codePoint;
|
|
175
190
|
}
|
|
176
191
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* the
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* @param
|
|
184
|
-
* @param isStrict Only match semicolon-terminated entities.
|
|
185
|
-
* @param isAttribute Whether to apply attribute-specific parsing rules (disallowing certain non-semicolon terminators).
|
|
186
|
-
* @returns The decoded string.
|
|
192
|
+
* Find the longest legacy (semicolon-less) match for the name starting at
|
|
193
|
+
* `start`, using the per-class legacy length bits. Returns
|
|
194
|
+
* `slot << 3 | matchLength`, or -1 if there is no match. Only called after
|
|
195
|
+
* the exact probes failed (the miss path).
|
|
196
|
+
* @param input Input text.
|
|
197
|
+
* @param start Start of the name.
|
|
198
|
+
* @param maxLength Number of available run characters.
|
|
187
199
|
*/
|
|
188
|
-
function
|
|
189
|
-
|
|
200
|
+
function findLegacySlot(input, start, maxLength) {
|
|
201
|
+
let legacy = htmlLengthBits[pairIndex(input.charCodeAt(start), input.charCodeAt(start + 1))] >>> 16 & 31;
|
|
202
|
+
while (legacy !== 0) {
|
|
203
|
+
const top = 31 - Math.clz32(legacy);
|
|
204
|
+
legacy ^= 1 << top;
|
|
205
|
+
if (top + 2 > maxLength) continue;
|
|
206
|
+
const slot = findSlotHtml(input, start, top + 2);
|
|
207
|
+
if (slot >= 0 && (htmlSlotValue[slot] & 2) !== 0) return slot << 3 | top + 2;
|
|
208
|
+
}
|
|
209
|
+
return -1;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Match a class containing long names without probing all its shorter lengths.
|
|
213
|
+
* The 32-character window bounds the scan even for invalid or unterminated runs.
|
|
214
|
+
* Returns `(slot << 6) | consumed`, excluding the `&`, or -1 on a miss.
|
|
215
|
+
* @param input Input containing the candidate name.
|
|
216
|
+
* @param start Start of the name.
|
|
217
|
+
* @param mode Decoding mode, including the rules for legacy matches.
|
|
218
|
+
*/
|
|
219
|
+
function findLongClassMatch(input, start, mode) {
|
|
220
|
+
const length = input.slice(start, start + 32).indexOf(";");
|
|
221
|
+
if (length - 2 >>> 0 <= 29) {
|
|
222
|
+
const slot = findSlotHtml(input, start, length);
|
|
223
|
+
if (slot >= 0) return slot << 6 | length + 1;
|
|
224
|
+
}
|
|
225
|
+
if (mode !== DecodingMode.Strict) {
|
|
226
|
+
const packed = findLegacySlot(input, start, Math.min(31, input.length - start));
|
|
227
|
+
if (packed >= 0) {
|
|
228
|
+
const length = packed & 7;
|
|
229
|
+
if (mode !== DecodingMode.Attribute || start + length >= input.length || !isEntityInAttributeInvalidEnd(input.charCodeAt(start + length))) return packed >> 3 << 6 | length;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return -1;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The next `&` to resume from after emitting a replacement, given the index
|
|
236
|
+
* just past it. A leaf the decoders call after every emit: the common
|
|
237
|
+
* adjacent-entity case (`&<`) skips the `indexOf` C++ call.
|
|
238
|
+
* @param input Input text.
|
|
239
|
+
* @param last Index just past the entity that was emitted.
|
|
240
|
+
*/
|
|
241
|
+
function nextOffset(input, last) {
|
|
242
|
+
if (last >= input.length) return -1;
|
|
243
|
+
return input.charCodeAt(last) === CHAR_AMP ? last : input.indexOf("&", last);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Synchronous HTML decoder, shared by all three decoding modes.
|
|
247
|
+
* @param input String to decode.
|
|
248
|
+
* @param mode Decoding mode for named entities.
|
|
249
|
+
*/
|
|
250
|
+
function decodeHtmlText(input, mode) {
|
|
251
|
+
const isLegacyAllowed = mode !== DecodingMode.Strict;
|
|
190
252
|
let offset = input.indexOf("&");
|
|
191
253
|
if (offset < 0) return input;
|
|
192
254
|
const inputLength = input.length;
|
|
193
|
-
let chunkStart = 0;
|
|
194
255
|
let result = "";
|
|
195
|
-
|
|
196
|
-
const rootJumpOffset = root & BinTrieFlags.JUMP_TABLE;
|
|
197
|
-
const rootBranchCount = (root & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
256
|
+
let last = 0;
|
|
198
257
|
do {
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
consumed =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
nodeIndex = stored === 0 ? -1 : rootBranchCount + stored & 65535;
|
|
216
|
-
} else nodeIndex = -1;
|
|
217
|
-
let bestNodeIndex = 0;
|
|
218
|
-
let bestValueLength = 0;
|
|
219
|
-
let current = nodeIndex < 0 ? 0 : decodeTree[nodeIndex];
|
|
220
|
-
let index = entityStart + 1;
|
|
221
|
-
trie: while (index < inputLength) {
|
|
222
|
-
while ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0) {
|
|
223
|
-
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
224
|
-
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
225
|
-
if (branchCount === 0) {
|
|
226
|
-
if (input.charCodeAt(index) !== jumpOffset) break trie;
|
|
227
|
-
nodeIndex += 1;
|
|
228
|
-
} else {
|
|
229
|
-
const slot = input.charCodeAt(index) - jumpOffset;
|
|
230
|
-
if (slot >>> 0 >= branchCount) break trie;
|
|
231
|
-
const stored = decodeTree[nodeIndex + 1 + slot];
|
|
232
|
-
if (stored === 0) break trie;
|
|
233
|
-
nodeIndex = nodeIndex + branchCount + stored & 65535;
|
|
234
|
-
}
|
|
235
|
-
current = decodeTree[nodeIndex];
|
|
236
|
-
index += 1;
|
|
237
|
-
if (index >= inputLength) break trie;
|
|
238
|
-
}
|
|
239
|
-
if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
|
|
240
|
-
const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
241
|
-
if (input.charCodeAt(index) !== (current & BinTrieFlags.JUMP_TABLE)) break;
|
|
242
|
-
index += 1;
|
|
243
|
-
const remaining = runLength - 1;
|
|
244
|
-
let wordIndex = nodeIndex + 1;
|
|
245
|
-
let charIndexInPacked = 0;
|
|
246
|
-
for (; charIndexInPacked + 1 < remaining; charIndexInPacked += 2) {
|
|
247
|
-
const packed = decodeTree[wordIndex];
|
|
248
|
-
if (input.charCodeAt(index) !== (packed & 255)) break trie;
|
|
249
|
-
index += 1;
|
|
250
|
-
if (input.charCodeAt(index) !== (packed >> 8 & 255)) break trie;
|
|
251
|
-
index += 1;
|
|
252
|
-
wordIndex += 1;
|
|
253
|
-
}
|
|
254
|
-
if (charIndexInPacked < remaining) {
|
|
255
|
-
if (input.charCodeAt(index) !== (decodeTree[wordIndex] & 255)) break;
|
|
256
|
-
index += 1;
|
|
257
|
-
}
|
|
258
|
-
nodeIndex += 1 + (runLength >> 1);
|
|
259
|
-
current = decodeTree[nodeIndex];
|
|
260
|
-
continue;
|
|
261
|
-
}
|
|
262
|
-
const valueLength = current >>> 14;
|
|
263
|
-
const char = input.charCodeAt(index);
|
|
264
|
-
if (valueLength !== 0) {
|
|
265
|
-
if (char === CharCodes.SEMI) {
|
|
266
|
-
consumed = index - entityStart + 1;
|
|
267
|
-
value = valueLength === 1 ? String.fromCharCode(current & BinTrieFlags.VALUE_MASK) : readTrieValue(decodeTree, nodeIndex, valueLength);
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
271
|
-
consumed = index - entityStart;
|
|
272
|
-
bestNodeIndex = nodeIndex;
|
|
273
|
-
bestValueLength = valueLength;
|
|
274
|
-
}
|
|
275
|
-
if (valueLength === 1) break;
|
|
276
|
-
}
|
|
277
|
-
const next = determineBranch(decodeTree, current, nodeIndex + (valueLength || 1), char);
|
|
278
|
-
if (next < 0) break;
|
|
279
|
-
nodeIndex = next;
|
|
280
|
-
current = decodeTree[nodeIndex];
|
|
281
|
-
index += 1;
|
|
258
|
+
const start = offset + 1;
|
|
259
|
+
if (start + 1 >= inputLength) break;
|
|
260
|
+
const c0 = input.charCodeAt(start);
|
|
261
|
+
if (c0 === CHAR_AMP) {
|
|
262
|
+
offset = start;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (c0 === CHAR_NUM) {
|
|
266
|
+
const packed = parseNumericEntity(input, start + 1, !isLegacyAllowed);
|
|
267
|
+
const consumed = unpackConsumed(packed);
|
|
268
|
+
if (consumed === 0) offset = input.indexOf("&", start);
|
|
269
|
+
else {
|
|
270
|
+
if (last !== offset) result += input.slice(last, offset);
|
|
271
|
+
result += codePointToString(packed & NUMERIC_CODE_POINT_MASK);
|
|
272
|
+
last = offset + consumed;
|
|
273
|
+
offset = nextOffset(input, last);
|
|
282
274
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const bits = htmlLengthBits[pairIndex(c0, input.charCodeAt(start + 1))];
|
|
278
|
+
if ((bits & 32768) !== 0) {
|
|
279
|
+
const packed = findLongClassMatch(input, start, mode);
|
|
280
|
+
if (packed >= 0) {
|
|
281
|
+
if (last !== offset) result += input.slice(last, offset);
|
|
282
|
+
result += emitHtmlValue(htmlSlotValue[packed >> 6]);
|
|
283
|
+
last = start + (packed & 63);
|
|
284
|
+
offset = nextOffset(input, last);
|
|
285
|
+
} else offset = input.indexOf("&", start);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
let probed = bits & 32767;
|
|
289
|
+
let matched = -1;
|
|
290
|
+
while (probed !== 0) {
|
|
291
|
+
const low = probed & -probed;
|
|
292
|
+
probed ^= low;
|
|
293
|
+
const length = 33 - Math.clz32(low);
|
|
294
|
+
const end = start + length;
|
|
295
|
+
if (end > inputLength) break;
|
|
296
|
+
const isTerminated = end < inputLength && input.charCodeAt(end) === CHAR_SEMI;
|
|
297
|
+
if (!(isTerminated || isLegacyAllowed && (bits >>> length + 14 & 1) !== 0)) continue;
|
|
298
|
+
const slot = findSlotHtml(input, start, length);
|
|
299
|
+
if (slot < 0) continue;
|
|
300
|
+
if (isTerminated) {
|
|
301
|
+
matched = slot << 6 | 32 | length + 1;
|
|
302
|
+
break;
|
|
291
303
|
}
|
|
292
|
-
|
|
293
|
-
consumed = 0;
|
|
294
|
-
value = "";
|
|
304
|
+
if ((htmlSlotValue[slot] & 2) !== 0) matched = slot << 6 | length;
|
|
295
305
|
}
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
if (
|
|
299
|
-
|
|
300
|
-
|
|
306
|
+
if (matched >= 0) {
|
|
307
|
+
const length = matched & 31;
|
|
308
|
+
if ((matched & 32) !== 0 || mode !== DecodingMode.Attribute || start + length >= inputLength || !isEntityInAttributeInvalidEnd(input.charCodeAt(start + length))) {
|
|
309
|
+
if (last !== offset) result += input.slice(last, offset);
|
|
310
|
+
result += emitHtmlValue(htmlSlotValue[matched >> 6]);
|
|
311
|
+
last = start + length;
|
|
312
|
+
offset = nextOffset(input, last);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
301
315
|
}
|
|
302
|
-
|
|
316
|
+
offset = input.indexOf("&", start + 1);
|
|
303
317
|
} while (offset >= 0);
|
|
304
|
-
return result + input.slice(
|
|
318
|
+
return result + input.slice(last);
|
|
305
319
|
}
|
|
306
320
|
/**
|
|
307
|
-
* Decodes an HTML string, requiring all entities to be terminated by a
|
|
321
|
+
* Decodes an HTML string, requiring all entities to be terminated by a
|
|
322
|
+
* semicolon.
|
|
308
323
|
* @param htmlString The string to decode.
|
|
309
324
|
* @returns The decoded string.
|
|
310
325
|
*/
|
|
311
326
|
function decodeHTMLStrict(htmlString) {
|
|
312
|
-
return
|
|
327
|
+
return decodeHtmlText(htmlString, DecodingMode.Strict);
|
|
313
328
|
}
|
|
314
|
-
export { DecodingMode, decodeHTMLStrict
|
|
329
|
+
export { DecodingMode, decodeHTMLStrict };
|