René's URL Explorer Experiment


Title: DiffLine.rawContent() returns string instead of Buffer, causing non-UTF-8 encoding corruption · Issue #2038 · nodegit/nodegit · GitHub

Open Graph Title: DiffLine.rawContent() returns string instead of Buffer, causing non-UTF-8 encoding corruption · Issue #2038 · nodegit/nodegit

X Title: DiffLine.rawContent() returns string instead of Buffer, causing non-UTF-8 encoding corruption · Issue #2038 · nodegit/nodegit

Description: Description Thanks to the nodegit maintainers for this excellent library! This issue was debugged with the assistance of Cursor and Opus 4.5. Current Behavior DiffLine.rawContent() returns a JavaScript string type, but the underlying lib...

Open Graph Description: Description Thanks to the nodegit maintainers for this excellent library! This issue was debugged with the assistance of Cursor and Opus 4.5. Current Behavior DiffLine.rawContent() returns a JavaSc...

X Description: Description Thanks to the nodegit maintainers for this excellent library! This issue was debugged with the assistance of Cursor and Opus 4.5. Current Behavior DiffLine.rawContent() returns a JavaSc...

Opengraph URL: https://github.com/nodegit/nodegit/issues/2038

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"DiffLine.rawContent() returns string instead of Buffer, causing non-UTF-8 encoding corruption","articleBody":"## Description\n\nThanks to the nodegit maintainers for this excellent library! \n\nThis issue was debugged with the assistance of Cursor and Opus 4.5.\n\n### Current Behavior\n\n`DiffLine.rawContent()` returns a JavaScript `string` type, but the underlying libgit2 `git_diff_line.content` is a raw byte pointer (`const char *`) that is **not NUL-terminated** and may contain non-UTF-8 encoded content (e.g., GBK, GB18030).\n\nThe current implementation in `lib/diff_line.js`:\n\n```javascript\nvar _rawContent = DiffLine.prototype.content;  // Save original native method\n\nDiffLine.prototype.content = function() {\n  // ...\n  this._cache.content = Buffer.from(this.rawContent())\n    .slice(0, this.contentLen())\n    .toString(\"utf8\");\n  return this._cache.content;\n};\n\nDiffLine.prototype.rawContent = function() {\n  return _rawContent.call(this);  // Calls native binding\n};\n```\n\nThe problem is that `_rawContent` (the native binding) already converts `const char *` to a JavaScript string, presumably using `v8::String::NewFromUtf8()` or similar, which **assumes UTF-8 encoding**.\n\n### Expected Behavior\n\n`rawContent()` should return a `Buffer` containing the original bytes, allowing users to detect and decode the encoding themselves:\n\n```javascript\nDiffLine.prototype.rawContent = function() {\n  // Return Buffer instead of string\n  return _rawContent.call(this);  // Should return Buffer\n};\n\nDiffLine.prototype.content = function() {\n  // ... existing implementation\n  return this.rawContent()\n    .slice(0, this.contentLen())\n    .toString(\"utf8\");\n};\n```","author":{"url":"https://github.com/liangjingyang","@type":"Person","name":"liangjingyang"},"datePublished":"2026-01-13T01:51:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2038/nodegit/issues/2038"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4aa5495e-7d58-7056-3c0a-c5d711e9472a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE9B4:2713AA:109351:1687BB:696FFACB
html-safe-nonce63b0aa7371efeb4c8ed02b513323ce7300a9f941074083c6493a9c183cfc99a1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUI0OjI3MTNBQToxMDkzNTE6MTY4N0JCOjY5NkZGQUNCIiwidmlzaXRvcl9pZCI6IjQ5NzY5NTkzNjkzNzk4Mzg2NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmace3a28dfeee176dc9ae6855c2004e5ca9b77a046b645d4e854364cf0f4d191648
hovercard-subject-tagissue:3806716122
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodegit/nodegit/2038/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7e45ae34e9f53149789c536aa83a9c0e2c46bdc7e82a853a799e673506c8855b/nodegit/nodegit/issues/2038
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7e45ae34e9f53149789c536aa83a9c0e2c46bdc7e82a853a799e673506c8855b/nodegit/nodegit/issues/2038
og:image:altDescription Thanks to the nodegit maintainers for this excellent library! This issue was debugged with the assistance of Cursor and Opus 4.5. Current Behavior DiffLine.rawContent() returns a JavaSc...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameliangjingyang
hostnamegithub.com
expected-hostnamegithub.com
None0366807b865cee6776368231232f84d6c8096e6bce43f701a4fb28ea795ec427
turbo-cache-controlno-preview
go-importgithub.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git
octolytics-dimension-user_id657068
octolytics-dimension-user_loginnodegit
octolytics-dimension-repository_id1383170
octolytics-dimension-repository_nwonodegit/nodegit
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1383170
octolytics-dimension-repository_network_root_nwonodegit/nodegit
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release33f356bb2fb58726ccb2f26395bf8ddc9a2d9eaa
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/nodegit/nodegit/issues/2038#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodegit%2Fnodegit%2Fissues%2F2038
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodegit%2Fnodegit%2Fissues%2F2038
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodegit%2Fnodegit
Reloadhttps://patch-diff.githubusercontent.com/nodegit/nodegit/issues/2038
Reloadhttps://patch-diff.githubusercontent.com/nodegit/nodegit/issues/2038
Reloadhttps://patch-diff.githubusercontent.com/nodegit/nodegit/issues/2038
nodegit https://patch-diff.githubusercontent.com/nodegit
nodegithttps://patch-diff.githubusercontent.com/nodegit/nodegit
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fnodegit%2Fnodegit
Fork 697 https://patch-diff.githubusercontent.com/login?return_to=%2Fnodegit%2Fnodegit
Star 5.8k https://patch-diff.githubusercontent.com/login?return_to=%2Fnodegit%2Fnodegit
Code https://patch-diff.githubusercontent.com/nodegit/nodegit
Issues 343 https://patch-diff.githubusercontent.com/nodegit/nodegit/issues
Pull requests 19 https://patch-diff.githubusercontent.com/nodegit/nodegit/pulls
Actions https://patch-diff.githubusercontent.com/nodegit/nodegit/actions
Projects 0 https://patch-diff.githubusercontent.com/nodegit/nodegit/projects
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/nodegit/nodegit/security
Please reload this pagehttps://patch-diff.githubusercontent.com/nodegit/nodegit/issues/2038
Insights https://patch-diff.githubusercontent.com/nodegit/nodegit/pulse
Code https://patch-diff.githubusercontent.com/nodegit/nodegit
Issues https://patch-diff.githubusercontent.com/nodegit/nodegit/issues
Pull requests https://patch-diff.githubusercontent.com/nodegit/nodegit/pulls
Actions https://patch-diff.githubusercontent.com/nodegit/nodegit/actions
Projects https://patch-diff.githubusercontent.com/nodegit/nodegit/projects
Security https://patch-diff.githubusercontent.com/nodegit/nodegit/security
Insights https://patch-diff.githubusercontent.com/nodegit/nodegit/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/nodegit/nodegit/issues/2038
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/nodegit/nodegit/issues/2038
DiffLine.rawContent() returns string instead of Buffer, causing non-UTF-8 encoding corruptionhttps://patch-diff.githubusercontent.com/nodegit/nodegit/issues/2038#top
https://github.com/liangjingyang
https://github.com/liangjingyang
liangjingyanghttps://github.com/liangjingyang
on Jan 13, 2026https://github.com/nodegit/nodegit/issues/2038#issue-3806716122
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.